feat(gemma4): full 12B forward from one token through window-edge pfill - #879
Merged
FeathBow merged 1 commit intoAug 14, 2026
Merged
Conversation
…fill Signed-off-by: Feathbow <feathbow@gmail.com>
Collaborator
Author
|
@codex review please |
|
Codex Review: Didn't find any major issues. Swish! 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 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 #878.
The full text-tower forward, prefill form: scaled embedding, all 48 layers dispatched by the parsed layer map, the final norm, the tied LM head, and the final-logit softcap — every prompt at or below the 1024-token window, where causal attention IS sliding attention. Geometry and the end constants come from the weights' own config inside the forward — one source of truth for every buffer size handed to CUDA — and token ids are bounds-checked against the embedding before upload, since the embedding kernel validates neither its output width nor the row it reads.
The end constants are the ones a from-the-paper implementation gets wrong: the embedding multiplier is the bf16 rounding of
sqrt(hidden_size)(exactly 62.0 at hidden 3840 — the reference casts the scale to the weight dtype before multiplying), derived in one place and asserted against the fixture's recorded value before use; the LM head is the embedding matrix itself; the softcap rides the typed config, validated positive at parse.The oracle compares log-probabilities at the reference's top-64 ids per position (host log-softmax over the f32 upcast, f64 accumulation for the 262k-way sum), with per-case gates declared from measurement and the window-edge gate distributional — the reasoning and the HF-self-comparison baseline are in the issue.
Test Env
Single GPU (sm_89, x86_64), CUDA 12.9, against the pinned 12B checkpoint.
Verification
Type of Change