Spaces:
Sleeping
Sleeping
Commit History
-
Merge W_OV equilibrium observables into main
7939cd5 -
Add QK/OV equilibrium observables to correlations stageβ
Gated by correlation.equilibrium (off by default): compute per-head commutator, irreversibility, and symmetric/antisymmetric observables from the QK and OV operators. Extends extract_head_stores to materialize the OV operator when equilibrium is requested, and threads --equilibrium through the correlations rule and run_correlations. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1062742 -
Speed up primary element stats and cut peak memoryβ
Replace the per-head np.histogram + scipy stats with one fused pass: O(n) uniform-bin histogram, shared-central-moment mean/std/skew/kurtosis (bit-identical to scipy), and a histogram plug-in differential_entropy that drops scipy's O(n log n) Vasicek sort. ~18x faster per-head element stats. Build W_QK one head at a time instead of the full (n_heads, d_model, d_model) tensor, removing an ~838 MB transient and a pointless device round-trip (W_QK is only histogrammed on CPU). This is what relieves swap thrashing for the large models. Also add a gated svd_via_gram option (off by default) deriving W_Q/W_K U,S from the d_head Gram eigendecomposition instead of a wide MPS->CPU-fallback SVD. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>fa476b7
-
Add ultrametricity analysis stage for head-overlap matricesβ
Post-processing stage over the correlations Q_hh matrices. New module transformer_analysis.ultrametricity computes, per model and per metric (Frobenius chordal distance, Jensen-Shannon distance): - triple Rammal index u (3-point ultrametricity), per-head map, u-vs-layer-span, tight-pair co-occurrence, triangle-violation check - four-point additivity index u4 and Gromov delta-hyperbolicity - average-linkage dendrogram, cophenetic correlation, and the D=C+R residual decomposition (effective rank, eigenvalues/eigenvectors, sparsity verdict) - classical MDS / PCoA (eigenvalues + leading principal coordinates) - cophenetic correlation across linkage rules - an untrained null ensemble for the distance distribution run_ultrametricity.py reads the correlation .npz outputs (no model download), writes per-metric .npz + summary JSON, and logs to MLflow. Wired in as an optional snakemake stage (rules/ultrametricity.smk, ultrametricity_all target) with a config.yaml section. Co-Authored-By: β¦840479b
-
Namespace all outputs under experiment_dir, add MLflow run metadataβ
All pipeline outputs and sentinels now live under {output_dir}/{mlflow_experiment}/ instead of scattered across the project root and output_dir. Prevents clobbering across experiments and mirrors the MLflow hierarchy. Changes: - Snakefile: derive config["experiment_dir"], pre-create it, override eval.out dynamically; update all sentinel expand() paths - rules/*: sentinel touch paths and inter-rule deps use experiment_dir; correlations/figures dirs moved under experiment_dir - config.yaml: remove hardcoded eval.out (now derived in Snakefile) - scripts/run_*.py: add mlflow.note.content description, model tag, and DatasetInput (local source β output path) to every run Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>0bf8fb1
-
Add docstrings to all static rules for snakemake --listβ
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>fbffedd -
Add MLflow logging to correlations and eval stagesβ
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>dbd0f5c -
Add clean rules: clean, clean_transform, clean_mlflow, clean_run, clean_<family>β
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>92dcf5b -
Wire QK decomposition weight types into primary pipelineβ
W_Q_gram, W_K_gram, QK_alignment are already computed in head_analyzer.py. This commit exposes weight_types through config.yaml β run_primary.py β process_model() β primary.smk so they can be overridden at runtime. Tests updated to cover all 6 weight types; histogram test restricted to raw weight types since gram entries exceed standard bin range. compute_qk_decomposition.py removed (data now lives in primary dataset). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a07e79a -
Refactor eval to per-run parquets + merge_eval, remove -j1 constraintβ
Each eval job now writes outputs/eval/{run_key}.parquet independently. merge_eval concatenates them into the final artifact. eval_all depends on merge_eval output rather than individual sentinels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>f49060a -
Add drop_columns option to transform stage for refined dataset reductionβ
- reprocess_metrics(): drop_columns param strips named columns before saving the refined dataset; primary is never touched so columns are always recoverable - run_transform.py: --drop-columns passthrough, logged to MLflow - transform.smk: reads transform.drop_columns from config, builds --drop-columns flag - config.yaml: transform.drop_columns: [] with note on common candidates (P_w, w_bins) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>2f68beb -
Write transform output to separate _refined directoryβ
- reprocess_metrics(): rename out_dirβin_dir, add out_dir for refined output. Defaults to {dataset_path}_refined. Copies metadata.json into refined dir. - run_transform.py: add --out-dir arg (default {dataset-dir}_refined); logs out_dir to MLflow. - transform.smk: passes --out-dir {output_dir}/{run_key}_refined explicitly. - dashboard_utils.py: prefer {ds_name}_refined path when loading locally, fall back to {ds_name}. - run_merge.py: cross_model_merge prefers {dir}_refined over primary dir. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>aaaf91c -
Rename src modules for head/pair symmetry; add pair_figures.smk; split eval_metricsβ
src/transformer_analysis/: weight_analysis β head_pipeline attn_head_analysis β head_analyzer metrics β head_metrics correlation_analysis β pair_pipeline head_correlations β pair_analyzer eval_metrics.py (new β implementation extracted from compute_perplexity.py) scripts/: plot_correlations.py β plot_pair_correlations.py plot_corr_figures.py β plot_pair_correlations_batch.py compute_perplexity.py β deleted (impl in eval_metrics; thin wrapper run_eval.py) run_eval.py (new thin wrapper) rules/: correlations.smk β switched to sentinel output (consistent with other rules) pair_figures.smk (new β regenerate pair figures from .npz without re-running correlations) eval.smk β updated to call run_eval.py Snakefile: added correlations_all, pair_figures_all convenience targets Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>a81fd74 -
Add eval.smk, fix correlations input, remove superseded scriptsβ
- rules/eval.smk: wraps compute_perplexity.py per run; sentinel-based, depends on transform; eval_all convenience target in Snakefile - rules/correlations.smk: fix input to use transform sentinel instead of bare dataset directory (which Snakemake couldn't track) - config.yaml: add eval block (corpus, pile_tokens, pile_cache, out) - Delete run_weight_analysis.py, run_all_correlations.py, merge_datasets.py (superseded by run_primary.py, run_correlations.py, run_merge.py) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>6ae3047 -
feat: add Snakemake pipeline, MLflow tracking, metrics refactor, testsβ
Pipeline / workflow: - Snakefile + config.yaml orchestrate primary β transform β merge stages - rules/primary.smk, transform.smk, correlations.smk, merge.smk - Sentinel-file pattern (done/*.done) avoids directory-output conflicts - Incremental cross-model merge: appends new models without clobbering; --refresh flag for explicit replacement after re-transform - Per-model checkpoint merge rule for Pythia step-collapse CLI wrappers (scripts/): - run_primary.py β process_model() + MLflow logging - run_transform.py β reprocess_metrics() + MLflow logging (git sha tagged) - run_correlations.py β thin wrapper for run_multi_circuit_analysis() - run_merge.py β cross-model incremental merge + checkpoint merge Metrics refactor: - src/transformer_analysis/metrics.py: canonical home for all stat functions, bin configs, normality_metrics, singular_value_metrics, and adaptive binning helpers (make_weight_bins, make_sv_bins) - histogram_utils.py: backward-compat re-export shim; no logic cβ¦24e1932