Add early structural triage to kill degenerate experiments at 60s#204
Open
a-nom-ali wants to merge 1 commit intokarpathy:masterfrom
Open
Add early structural triage to kill degenerate experiments at 60s#204a-nom-ali wants to merge 1 commit intokarpathy:masterfrom
a-nom-ali wants to merge 1 commit intokarpathy:masterfrom
Conversation
Computes effective rank (spectral entropy of weight matrix SVDs) and gradient coherence (cosine similarity of consecutive layer gradients) at the 1-minute mark. If effective rank has collapsed below 50% of its initial value, the experiment is killed early instead of running the full 5-minute budget. Two configurable hyperparameters: TRIAGE_TIME (seconds, 0 to disable) and TRIAGE_KILL (fraction threshold). Rank retention is reported in the final summary alongside val_bpb. Zero new dependencies — pure PyTorch (torch.linalg.svdvals, F.cosine_similarity). ~50ms one-shot cost at the checkpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TRIAGE_TIME)exit(1)) if effective rank has collapsed below 50% of its initial value (TRIAGE_KILLthreshold)eff_rank_init,eff_rank_final, andrank_retentionin the final summary alongsideval_bpbMotivation
The existing fast-fail check (
loss > 100) only catches catastrophic divergence. Effective rank collapse — where the model's weight matrices lose expressivity — is a subtler failure mode that predicts bad finalval_bpbbut doesn't necessarily spike the loss. Catching it at 60s saves 4 minutes per degenerate hyperparameter configuration.Implementation
structural_triage(model)— iterates all 2D parameters ≥64 in min dimension, computes SVD, returns mean effective rank and gradient coherencetorch.linalg.svdvalsandF.cosine_similarityTRIAGE_TIME = 0to disable entirelyTest plan
Initial effective rank: X.Xprints at startup[triage@60s]checkpoint fires at ~60s with rank ratio and coherenceeff_rank_init,eff_rank_final,rank_retentionappear in final summaryTRIAGE_KILL = 0.99(should kill immediately)TRIAGE_TIME = 0(no triage output)🤖 Generated with Claude Code