Skip to content

GatedDelta fast route: activation-dtype inputs, 9+ rows only (gemma4-qat#1693) - #10

Merged
jeethu merged 1 commit into
numen/mainfrom
gdn-fused-1693
Nov 16, 2026
Merged

jeethu merged 1 commit into
numen/mainfrom
gdn-fused-1693

Conversation

@jeethu

@jeethu jeethu commented Nov 15, 2026

Copy link
Copy Markdown
Member

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):

  1. No fp32 casts of q and k. Upstream Use the MLXFast gated delta kernel where mlx core supports it ml-explore/mlx-swift-lm#740 cast q/k to float32 because mlx core cast g and beta to the dtype of q, and a bf16 decay just below 1 rounded to 1 (Keep g and beta in float32 in gated_delta_update when the activations are bf16 ml-explore/mlx#4725). This fork's core carries Keep g and beta in float32 in gated_delta_update ml-explore/mlx#4760 (gated_delta_update: keep g and beta in float32 (port of ml-explore/mlx#4760) mlx#22, in mlx-swift prism since the #1054 sync): gated_delta_update keeps g and beta float32 whatever q is. So q, k and v now 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.
  2. 9 rows or more. mlx core's chunked kernels run only above 8 rows (chunks of 8, 16 on NAX); at 8 rows or fewer it runs its per-step kernel, the same recurrence as gated_delta_step without 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. testGatedDeltaFastRouteIsOptInAndMultiRowOnly now checks 1 and 8 rows stay bit-identical to the default and 9 rows reaches MLXFast. testGatedDeltaFastPathKeepsDecayNearOneInFloat32 (bf16 q/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 MLXLMTests run 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).

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T21:53:08.419086Z 2ffd041 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jeethu

jeethu commented Nov 15, 2026

Copy link
Copy Markdown
Member Author

Full MLXLMTests on the branch head 2ffd041 (macOS, M3 Max, xcodebuild): TEST SUCCEEDED. XCTest: 1015 tests executed, 8 skipped, 0 failures. Swift Testing ran its suites too; the MiniCPM5 CDATA known issue was recorded as expected and is not a failure. GatedDeltaTests (9 tests) all pass. The host side is gemma4-qat branch gdn-fused-1693; its PR is coming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant