bdh.py: add extend_freqs() for phase-preserving latent-width growth - #12
Open
asb-42 wants to merge 1 commit into
Open
bdh.py: add extend_freqs() for phase-preserving latent-width growth#12asb-42 wants to merge 1 commit into
asb-42 wants to merge 1 commit into
Conversation
RoPE frequencies are exponent-normalized by the neuron count (theta ** (-i/n)), so recomputing get_freqs(n_new) after growing the latent width silently rewrites the phases of every existing neuron and corrupts the model. extend_freqs() keeps the existing frequency table verbatim and appends entries for new neurons at the new scale, making width growth phase-preserving for all pre-existing neurons. Includes tests covering exact prefix preservation, the naive-recompute pitfall, and Attention construction with an extended table.
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.
Problem
RoPE frequencies are exponent-normalized by the neuron count (
theta ** (-i/n)inget_freqs). Any code that grows the latent width (progressive networks, upsizingexperiments, model editing) and simply recomputes
get_freqs(n_new)therefore**silently rewrites the phases of every existing neuron** and corrupts the trained model —
even though all actual weights are untouched.
We hit this while building a continual-learning growth mechanism on top of \BDH{}: a grown
model evaluated zero steps after width extension already behaved like an untrained model,
and the root cause was exactly this frequency-table renormalization.
Fix
extend_freqs(freqs, n_new)keeps the existing frequency table verbatim and appendsentries for new neurons computed at the new scale. Width growth becomes phase-preserving for
all pre-existing neurons by construction.
Verification
New
test_bdh.pycovers:assert_close);Attentionbuilds with an extended table.All three pass.
Scope
Deliberately minimal: one helper + docstring warning on
get_freqs+ tests. A fullcontinual-learning suite (phase-ordered training, growth/routing/consolidation mechanisms)
is being maintained separately in asb-42/bdh and can be
discussed separately if of interest.