Repository navigation
Use one beta per head in the Gated DeltaNet code - #1119
Open
Medamineelkhattabi wants to merge 1 commit into
Open
Medamineelkhattabi wants to merge 1 commit into
Medamineelkhattabi wants to merge 1 commit into
Conversation
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.
Follow-up to #1115.
In the
GatedDeltaNetcode inch04/08_deltanet/README.md,W_betamaps tod_out, so the write strength β is computed per channel. Qwen3-Next and the Gated DeltaNet paper use one β per head (in_proj_boutputsnum_v_heads, thenbeta = b.sigmoid()inmodeling_qwen3_5.py).This changes
W_betatonn.Linear(d_in, num_heads)and keeps β as(b, num_tokens, num_heads, 1), sodelta = (v_t - kv_mem) * b_tbroadcasts over the head dimension. The recurrence loop and the snippet further down the README are unchanged.I checked it by running the README class and comparing its recurrence with HF's
torch_recurrent_gated_delta_ruleon random inputs (same q, k, v, decay and β): max abs difference 3.7e-9. With the previous per-channel β the two can't be compared directly, since the shapes differ.