Repository navigation
[Model][SM70][FP8] Integrate calibrated E4M3 QSA KV capacity path - #462
Merged
yangzhuxinyzx merged 7 commits intoSep 3, 2026
Merged
Conversation
Add per-layer calibrated E4M3 K/V storage to Qwen4Exp QSA for the fixed SM70, TP4, MTP0, and FP16 activation contract. The main QSA cache uses E4M3 while the raw and compressed indexer caches remain FP16. Design decisions: - Keep checkpoint loading slots at an invalid -1.0 sentinel, separate from runtime scale buffers whose upstream default remains 1.0. Finalization validates and deletes the loading slots. - Fail closed if any of the 12 layers' K/V scales is missing, non-finite, or non-positive. This intentionally replaces the upstream KV-cache warning and unit-scale fallback, and is confined to 1Cat-owned Qwen4Exp files. - Keep indexer caches FP16 so K/V quantization cannot change QSA block selection. - Use P256 for E4M3 on generic G6 XQA virtual-page4. The P1024 specialization assumes the page1568 layout and is not valid here. - Do not bundle a scale overlay. Generate an exact-checkpoint-revision- bound model-kvscales overlay with tools/qwen4_exp/qsa_kv_calibration.py; E4M3 startup rejects unless all 24 scales are explicitly loaded. Also add offline normal-inference scale collection, report and overlay generation, and matched route/selected-block comparison. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Leonccaa <166551845+Leonccaa@users.noreply.github.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Apply the pinned CUDA formatter, add the required SPDX copyright header, and express the reference attention with equivalent matmul operations so the tensor subscripts do not trigger the spelling hook. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Leonccaa <166551845+Leonccaa@users.noreply.github.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
E4M3 XQA accepts at most 16 query rows, while chunked scheduling can form non-grouped catch-up/decode batches above that limit. Route the divisible bulk through grouped page4 and split the remainder into supported XQA chunks instead of falling back to the larger Triton split-K workspace. Add routing coverage and an SM70 numerical regression for the observed 46+1+1+1 request layout. Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
The dedicated PLE offload process builds the full model structure on meta but intentionally loads only the PLE subtree. Skip QSA KV scale finalization in that process; it never runs QSA forward, while every GPU worker retains the existing 24/24 fail-closed gate. Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Route the existing QSA decoder symbol to the exact bitcast implementation. Keeping the call sites unchanged makes this optimization independent from the sibling scale-hoisting change while preserving the same Triton specialization and generated behavior validated in the combined performance tree. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Leonccaa <166551845+Leonccaa@users.noreply.github.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Fold the per-layer K scale into the post-dot softmax factor and apply the V scale after normalized accumulation. Split-K applies V scaling once after merge, while the single-split path applies it directly before the final store. This independent follow-up keeps the existing scalar E4M3 decoder unchanged, removes per-element K/V scale multiplies, and preserves the FP16 constexpr branch and calibrated scale contract. Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Leonccaa <166551845+Leonccaa@users.noreply.github.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
yangzhuxinyzx
marked this pull request as ready for review
September 3, 2026 05:02
yangzhuxinyzx
deleted the
agent/v100-qwen4exp-e4m3-kv-main-20260903-045347
branch
September 3, 2026 05:03
This was referenced Sep 3, 2026
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.
Purpose
Integrate the calibrated Qwen4Exp QSA E4M3 KV capacity path from #447 plus the independent hot-loop follow-ups #452 and #453 on current public main after #460.
This is an explicit capacity mode, not a new default. The validated contract is NVIDIA SM70, TP4, MTP0, FP16 activations, and a checkpoint-revision-bound 24-scale overlay. Unsupported combinations fail closed. Default FP16/BF16 KV and current FlashNext MTP4 serving behavior are unchanged.
Base SHA:
c4c81296874771bd8cb256899ea0eb77970a4a6c.Changes
The only source conflict with current main was an adjacent-method insertion in
qsa.py: #460 added_set_topk_indices_buffer, while #447 addedvalidate_loaded_kv_scales. The integrated tree retains both. One #460 test fixture was updated with the now-required FP16 cache config.Test Plan
Test Result
git diff --checkand Python compile checks passed.Validation boundary
Provenance
Runtime and test commits retain the original #447/#452/#453 authorship and DCO trailers. OpenAI Codex assisted with latest-main integration, conflict review, test execution, and this write-up.