Repository navigation
GatedDelta: opt-in float16 recurrent state storage (gemma4-qat#1697 spike) - #11
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c02e0c485
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let recState = | ||
| cache?[1] | ||
| ?? (recurrentStateDType == .float32 | ||
| ? nil : zeroStates(batch: inputs.dim(0), dtype: inputs.dtype).rec) |
There was a problem hiding this comment.
Preserve the float16 seed when replaying an initially empty cache
When float16 storage is enabled and rollback recording begins on an empty MambaCache, this seeds the forward pass with float16 zeros without putting that seed in the recorded base. If commitRollback(keepingRows:) subsequently keeps a shorter prefix, the rollback closure passes base[1] (still nil) to gatedDeltaReplayState, which defaults to float32 zeros and returns a float32 state. Subsequent forwards prefer that cached state, silently disabling float16 storage for the rest of the session and producing a different state than a direct float16 prefix pass. Have the rollback rebuild use the effective seeded recurrent state when the recorded base is nil.
Useful? React with 👍 / 👎.
… state, keeping float16 storage (numen-tech/gemma4-qat#1697, Codex P2)
|
Codex review (gemma4-qat side) found that a verify pass recorded on a cold |
|
The new test does fail without the fix. I reverted the one-line fix in the working tree for one run only, then restored it. |
Stacked on #10 (base
gdn-fused-1693). Retarget to the merged base once #10 lands.Spike for numen-tech/gemma4-qat#1697: an opt-in float16 storage dtype for the Qwen3.5 Gated DeltaNet recurrent state (
[B, Hv, Dv, Dk], float32 today). It is off unless the host asks for it.What changes:
GatedDeltaRecurrentStateStorage, a public protocol (recurrentStateDType), adopted by the LLMQwen35GatedDeltaNetand the VLMQwen35.GatedDeltaNet. The default stays.float32. The host sets it per layer before the first forward..float16:gatedDeltaUpdatekeeps an fp16 state as it is. bf16 is still widened to fp32, as before.gated_delta_stepalready reads the state into float, sums it in float with compensation and writesStT, so fp16 is storage only.Tests (
GatedDeltaTests, macOS M3 Max):testFloat16StateIsStorageOnlyOnEveryPath: the kernel, ops and MLXFast paths fed an fp16 state each return an fp16 state that equals the float32 path's state rounded to fp16, and the same output.testStateDTypeDefaultsStayFloat32.GatedDeltaTestspass. A fullMLXLMTestsrun has not been done on this branch. GatedDelta fast route: activation-dtype inputs, 9+ rows only (gemma4-qat#1693) #10's full run on its parent passed.The model-level parity, the memory saved and the greedy quality are measured on the host side (numen-tech/gemma4-qat#1697).