feat(gemma4): global decoder layer and its HF golden oracle probes - #877
Merged
FeathBow merged 1 commit intoAug 14, 2026
Merged
Conversation
Signed-off-by: Feathbow <feathbow@gmail.com>
Collaborator
Author
|
@codex review please |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
This was referenced Aug 14, 2026
Closed
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.
Description
Closes #876
The global (full-attention) decoder layer at head_dim 512, forward only — everything downstream of attention was already kind-agnostic and is now one shared epilogue. The differences from the local kind are the ones the checkpoint and the reference pin:
v_projon anyfull_attentionlayer (the loader enforces it; this layer refuses one that carries it), and the reference forks value offk_proj's raw output BEFOREk_normand RoPE touch K — after the norms the two tensors differ bitwise.rotate_halfpairs(d, d + 256)across the whole head — so the prep kernel runs atrotary_dim = head_dimand the partiality lives in the tables. Passing the intuitive 128 rotates the wrong pairs entirely; a control below shows the oracle catches exactly that. The rope contract is parsed and validated once on the typed config — each family's declaredrope_typeis asserted against the implemented algorithm, theta must be positive, andpartial_rotary_factor * global_head_dimmust land on a positive even width within the head — and the table builder re-checks its inputs at the seam. The global forward range-checks positions on the host before upload, because its batched prep kernel__trap()s on out-of-range positions instead of returning an error (the hd256 prefill wrapper rejects them itself).scaling = 1.0) through the hd512 single-prefill's explicitsm_scale, and the layer is prefill-from-zero only (start_pos > 0rejected), like the local kind.The oracle extends to both global boundaries — indices from the layer-map parse, cross-checked against the fixture metadata's own parse — eight comparisons in one checkpoint load. The last global layer's input is the sliding side's output cut: the fixture dedups adjacent cuts by depth, and that adjacency is asserted rather than assumed.
Test Env
Single GPU (sm_89, x86_64), CUDA 12.9, against the pinned 12B checkpoint.
Verification
layer_scalarexactly; the tables and the scale are gated by the nine-token comparisons and the controls below.sm_scalepinned torsqrt(512)fails exactly the two multi-token global comparisons; the V fork moved after the norms fails both multi-token global comparisons while one-token stays in tolerance (the weightless norm cancelsk_norm's magnitude until multi-key softmax amplifies the residue — why the multi-token probe exists);rotary_dim = 128— the intuitive reading — fails both multi-token global comparisons; rebuilding the tables withrotary_dimas exponent denominator fails the first global comparison.Type of Change