Repository navigation
GatedDelta fast route: activation-dtype inputs, 9+ rows only (gemma4-qat#1693) - #10
Merged
Merged
Conversation
…ech/gemma4-qat#1693) The fork's core carries ml-explore/mlx#4760 (numen-tech/mlx#22: gated_delta_update keeps g and beta float32 whatever the dtype of q), so fastGatedDelta drops upstream's float32 casts of q and k and feeds q, k and v as they are. The opt-in route now takes calls of gatedDeltaFastRouteMinRows (9) rows or more: at 8 rows or fewer mlx core runs its per-step kernel, not a chunked one, so those calls (decode included) keep gated_delta_step. Tests: the opt-in test covers 1 and 8 rows (custom kernel) and 9 rows (MLXFast); the decay-near-one test now checks the core's fix with bf16 q/k.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
Full |
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.
For numen-tech/gemma4-qat#1693 (fused Gated DeltaNet prefill spike, default off in the app).
Two changes to the opt-in
GatedDeltaFastRoute(#9's sync, still off unless a caller opens the task-local region):qandk. Upstream Use the MLXFast gated delta kernel where mlx core supports it ml-explore/mlx-swift-lm#740 castq/kto float32 because mlx core castgandbetato the dtype ofq, and a bf16 decay just below 1 rounded to 1 (Keepgandbetain float32 ingated_delta_updatewhen the activations are bf16 ml-explore/mlx#4725). This fork's core carries Keepgandbetain float32 ingated_delta_updateml-explore/mlx#4760 (gated_delta_update: keep g and beta in float32 (port of ml-explore/mlx#4760) mlx#22, in mlx-swiftprismsince the #1054 sync):gated_delta_updatekeepsgandbetafloat32 whateverqis. Soq,kandvnow go in as they are, and the output comes back in the activation dtype without a cast. The state is float32 inside the op either way.gated_delta_stepwithout the compensated sum. Calls of 1 to 8 rows now keep the custom kernel, bit for bit, inside an opted-in region too (gatedDeltaFastRouteMinRows = 9). That also covers short speculative verify passes if a caller ever opens the region around them.Tests (
GatedDeltaTests, 9 tests, macOS, M3 Max): all pass.testGatedDeltaFastRouteIsOptInAndMultiRowOnlynow checks 1 and 8 rows stay bit-identical to the default and 9 rows reaches MLXFast.testGatedDeltaFastPathKeepsDecayNearOneInFloat32(bf16q/k, decay 0.999 over 256 steps) still passes without the casts, which is the check that #4760 is in the pinned core.Not run here: the full
MLXLMTestsrun is queued and will be reported in a comment. Not run on NAX hardware in this repo; the gemma4-qat side measures it on devices.Nothing changes for callers that never open the region (the app's default).