Skip to content

qwen4_exp: no final RMSNorm after the hyper-connection mixer (split from #91) - #111

Merged
AzeezIsh merged 2 commits into
mainfrom
fix/qwen4exp-final-norm
Sep 27, 2026
Merged

AzeezIsh merged 2 commits into
mainfrom
fix/qwen4exp-final-norm

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Split out of #91 so the fix can land before the EXL3 work. Both commits are @andrew-vogulkin's, cherry-picked unchanged with authorship kept: 0fcb18bd4 → 4de31c095 and 8860eddee → 98fbc6320.

The bug

  • On qwen4_exp (Qwen3.8-Flash-Next), the last layer's model-level hyper-connection mixer is already the model's final normalization.
  • Atlas still ran the model-level final RMSNorm before every LM head, through the ones-filled placeholder weight and the (1 + w) kernel. That rescaled each position's logits by 2 / rms(x).
  • Argmax survives, so greedy output and greedy gates (ST-995 runs at temp 0) never saw it.
  • Every probability was wrong: sampled output, logprobs, and every ppl.py / kl_drift measurement on Flash-Next.
  • Measured in Qwen3.8-Flash-Next: serve EXL3 checkpoints on GB10 (M1–M4 of #65) #91: teacher-forced wikitext perplexity on the RadixArk NVFP4 pack was 4.28 in Atlas vs 2.29 in vLLM on the same weights. On the EXL3 checkpoint it was 8.391 before the fix and 3.636 after (exllamav3 reference: 3.590).

The change

  • final_norm_rows replaces the 18 final-norm call sites: prefill last-token, prompt logprobs, decode, batched decode, and the verify paths. It does a stream-ordered D2D copy when final_norm_identity is set, and the unchanged RMSNorm otherwise.
  • ModelConfig::final_norm_is_identity is the single source of truth. It's true only for qwen4_exp.
  • The invariant is checked at model build: the last layer must be full attention with hyper-connections, or the build refuses and names the layer.
  • Every other model takes the same path as before.

Evidence from #91

  • NVFP4 speed A/B against main 5b07b953: decode 19.70 = 19.70 tok/s, 2,048-token time-to-first-token 3.15 = 3.15 s.
  • Unit tests cover the predicate and the invariant.

Gate for this PR

  • Greedy output byte-identical to main on the Flash-Next recipe. Argmax is unchanged by construction, so any diff is a bug.
  • Teacher-forced perplexity before and after on current main.
  • It runs as one GB10 job; the result gets posted here.

Follow-up

Every Flash-Next perplexity number quoted in #74 and #70 was measured on rescaled logits. Relative A/B verdicts should hold, but magnitudes need a re-baseline after this merges.

Refs #91, #65.

🤖 Generated with Claude Code

andrew-vogulkin and others added 2 commits September 27, 2026 01:54
qwen4_exp's last layer runs the model-level hyper-connection mixer, whose
hc_norm is the model's final normalization; the reference feeds the mixer
output straight to lm_head. Atlas still ran the model-level final RMSNorm
before every LM head, with the ones-filled placeholder weight through the
(1 + w) kernel, so each position's logits were rescaled by 2 / rms(x): the
argmax survived (greedy output looked right) but every probability was
wrong. Teacher-forced wikitext perplexity on the RadixArk NVFP4 pack was 4.28
in Atlas against 2.29 in vLLM on the same weights.

final_norm_rows replaces the 18 final-norm call sites (prefill last-token,
prompt logprobs, decode, batched decode, verify paths): a stream-ordered
copy when final_norm_identity is set (qwen4_exp only), the unchanged RMSNorm
otherwise. The loader comment that called the placeholder unreachable is
corrected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…f truth

Review follow-ups on the final-norm fix:

- The predicate moves to ModelConfig::final_norm_is_identity, next to the
  other per-model switches (skip_lm_head_quantization), instead of a string
  match inside the model module.
- The identity is only correct when the last layer runs the hyper-connection
  mixer that collapses the streams into hidden_size rows; only attention
  layers call hc_head_site. check_final_norm_identity now refuses, at model
  build, a config without hyper-connections or whose last layer is not full
  attention, naming the layer, instead of silently feeding an un-mixed stream
  slice to lm_head.
- final_norm_rows names its BF16 element size, documents its precondition and
  skips the copy when input and output alias.
- Tests exercise the invariant (mixer layer last, GDN last, no hyper-
  connections, unaffected models) instead of a string equality.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

GB10 gate, part 1 (reiner job 527): PASS. main d234fcd14 vs this PR 98fbc6320, Flash-Next NVFP4 campaign serve (util 0.88, bf16 KV), 8 × 12k wikitext windows:

main #111 Δ
teacher-forced ppl, first 2,051 tokens (dense) 7.711 4.416 −42.7 %
teacher-forced ppl, above the QSA bound 4.384 2.581 −41.1 %
windows better / worse 8 / 0
greedy needle probes (40 / 1,400 / 5,500 words) SEVEN-CORAL-NINE ×3 identical byte-identical
ERROR / watchdog lines 0 / 0 0 / 0

Argmax is unchanged, as expected: every per-position logit scale is positive. The probabilities are what was wrong.

Part 2 (merge gate), reiner job 538, next after the train job: ST-995 via --pull-request-gate, paired McNemar vs job 464 (84.92 / 84.93), then the 2.5 h agentic perf leg vs job 465 (1007/1007, score 0.491). Greedy gates can still move, because any card-default presence penalty is applied on the rescaled logits. This merges only after both pass.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Merge gate, part 2 (reiner job 538).

ST-995: PASS, and better than main. 86.23 / 86.81 against bars of 82.72 / 81.65. Paired against main's job 464 (84.92 / 84.93, same recipe, verify-active): +1.31 points; 24 fixed vs 11 broken; exact McNemar p = 0.041. Greedy picks did move, as expected: the recipe's presence penalty now applies on correctly scaled logits.

Perf leg: INVALID (a harness transport failure, not the engine). Re-running.

  • 647 / 1007 turns succeeded, then the Mac→reiner SSH tunnel stalled at 11:36:38Z.
  • The server's last request completed normally. No further request ever reached the server: 0 ERROR lines, 0 KV-exhausted, 0 watchdog, idle until SIGINT.
  • 72 s later (the keepalive timeout) the harness failed the in-flight turn. It then dropped the rest of that conversation and the 7 conversations still pending: 360 client-side failures.
  • The driver's single-shot tunnel is now a reconnect loop (perf_leg_gb10_rc.sh).
  • Re-run: reiner job 595, next after the train gate (570). Reference: job 465, 1007/1007, score 0.491.

This merges when the perf leg is valid and clean.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Perf leg rerun (reiner job 595): invalid again, for a transport reason, not the server. The Mac client lost its network at 18:07Z (Tailscale reported `Network is unreachable`). At that point 207 of 1007 turns had completed, and every turn after that failed on the client side. On the server side: 209 requests done, 0 errors, 0 watchdog events, 0 KV exhaustion, and 202 of 207 prefix hits restored from a snapshot. It was still answering `/v1/models` afterwards.

I've installed the endpoints harness on reiner itself (same tree and `uv.lock`) and requeued the leg as `596z-perf-legs-local`, with the client running on the same box as the server. This removes the Mac hop that has now broken two runs. One caveat for the comparison against job 465 (0.491): that run's client sat behind the Mac→reiner tunnel, so this one sees slightly lower per-request latency.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Both gates pass. Merging.

Gate Result Reference
ST-995 (job 538) 86.23 / 86.81 main job 464: 84.92. Paired, net +13, exact McNemar p = 0.041
Agentic perf 2.5h (job 596z, client on reiner) 1007/1007, 0 failed, score 0.5053 job 465: 0.491
Perf-leg serve 1008 requests, 0 ERROR, 0 panics, 0 watchdog events
ppl (job 527) dense 7.711 → 4.416; above-bound 4.384 → 2.581; 8/8 windows better

About the red checks:

  • Compliance reports all_turns_observed 1006 vs 1007. That's a harness quirk: every clean baseline run shows the same off-by-one, including main's 53f4a3d3a and main-27b-mtp, and no_dropped_turns passes.
  • The PR benchmark gate failure is the repo-wide stale-record invalidation (records from 9da215a), and main's last three runs fail it the same way.

The perf client for this run ran on the same box as the server, while job 465's ran through the Mac tunnel. Part of the +0.014 may come from that lower client latency, so I'm not claiming a speedup. Correctness is the claim.

@AzeezIsh
AzeezIsh merged commit fdf94c7 into main Sep 27, 2026
25 of 26 checks passed
AzeezIsh added a commit that referenced this pull request Sep 28, 2026
andrew-vogulkin added a commit to andrew-vogulkin/atlas that referenced this pull request Sep 28, 2026
A merge rather than a rebase: other people use this branch, so no
force-push. The two final-norm commits (Atlas-Inf#111) are now on main, so they
drop out of this PR's diff against main; their duplicates stay in the
branch history.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
andrew-vogulkin added a commit to andrew-vogulkin/atlas that referenced this pull request Sep 28, 2026
…) into Atlas-Inf#100

Carries main into this PR through Atlas-Inf#91, again as a merge (no
force-push). The final-norm fix is on main now, so it drops out of the
diff against main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh
AzeezIsh deleted the fix/qwen4exp-final-norm branch September 29, 2026 06:01
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.

2 participants