Repository navigation
hrx: GDN snapshot publish forms decay ratios in log space (fixes NaN after MTP rollback) - #52
Merged
bong-water-water-bong merged 1 commit intoOct 1, 2026
Conversation
…after MTP rollback) The snapshot publish path in gated_delta_net_f32_wmma.loom built the prefix decay ratio c_t/c_s by dividing the two exponentials. When a strongly forgetting head drives exp(log c_s) to 0, the later c_t is 0 as well and the ratio is 0/0 = NaN; it reaches the f16 D tile and every snapshot after the first token. The main recurrence already forms the same ratio as exp(log c_t - log c_s), so a step's own outputs stayed finite and only the published rollback states went bad. Qwen3.8-27B (Q8_0 and other files) with --mtp on HRX0: a verify batch after a 3-token rollback published NaN states, and the next verify returned NaN logits (server abort "NaN logits at vocab index 0"). Use log c_t from the gate scratch (gs_flat quad+3) and exp(log c_t - log c_s) at all 12 sites. Replay of the server's decode/rollback trace on one HRX0 context: first non-finite step 10 -> none; argmax matches the CPU on 37/37 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
|
Server-level results with the fix. Unchanged llama-server, only libggml-hrx swapped, balanced power mode:
|
bong-water-water-bong
left a comment
Author
There was a problem hiding this comment.
The change is correct. Checked against the branch head (7912b2d):
- What lane 3 holds. Lane 3 of each
gs_flatquad is%pp15, the prefix sum of the log gates (line 859). Lane 1 is%cpv = expf(%pp15)from the same value, and the stores are followed by a workgroup barrier. Soexpf(lc_t - lc_s)is the same ratio ascp_t / cp_s, without the 0/0 that occurs once both exponentials underflow. - No overflow. For t > s the prefix log sum only decreases, so
lc_t - lc_s <= 0and the newexpfstays in [0, 1]. - Coverage. No
divfon a%cp*remains anywhere in the file, including the five-token fragment path. All 12 sites in both publish branches are changed. - Results from the server (posted earlier as a comment):
- Q8_0
--mtpgives no NaN, and the no-MTP double-request memory fault is gone. - UD-Q4_K_XL
--mtpspeed is unchanged: 19.6/15.6 tok/s against 19.5/15.7, with the same draft acceptance and the same text. - In
rs_replay, the argmax matches the CPU on 37/37 rows.
- Q8_0
Follow-up, not blocking: a check case in our own file would keep this from regressing. It needs a GDN snapshot publish whose second token has a strongly negative log gate (so exp underflows to 0), with snapshots 1..n-1 required to be finite and to match an f32 reference. The fix doesn't touch the step-4 row-1 logit gap (29.41 against 30.87 on the CPU), so it's a separate precision effect worth its own look.
Approved from my side.
🤖 Generated with Claude Code
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.
Fixes NaN logits on Qwen3.8-27B with
--mtpon HRX0. The server aborts with "NaN logits at vocab index 0" a few verify steps into some prompts. Affected: Q8_0, UD-Q5_K_XL and the UD-Q6_K files; it depends on the prompt.Cause. The snapshot publish path in
gated_delta_net_f32_wmma.loomformed each prefix decay ratio c_t/c_s by dividing the two exponentials (divf %cp_t, %cp_s).exp(log c_t - log c_s), so the step's own outputs stay finite. Only the published states go bad, and the next verify that resumes from one of them returns NaN.Fix. At all 12 sites (both branches), read log c_t from the gate scratch (gs_flat quad+3, already written next to c_t) and use
exp(log c_t - log c_s). The change is limited to the snapshot path and touches nothing in the main recurrence.How it was found (with the peer session):
--mtpand the KV/recurrent state on HRX (clean with-nkvoand on Vulkan).Results (replay of the server's decode/rollback trace, Qwen3.8-27B-Q8_0, one HRX0 context, only libggml-hrx swapped):
A server-level
--mtpcheck and a speed check (12 divides become 12 exps, on the snapshot path only) are running. Results will follow in a comment before merge.The edit is a minimal change in an upstream kernel file, with no notice added.
🤖 Generated with Claude Code