[Kernel] Reduce DFlash2 weight and scale memory on SM70 - #561
Draft
yangzhuxinyzx wants to merge 7 commits into
Draft
[Kernel] Reduce DFlash2 weight and scale memory on SM70#561yangzhuxinyzx wants to merge 7 commits into
yangzhuxinyzx wants to merge 7 commits into
Conversation
Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Schedule shared-layout row blocks together and use 8-row CTAs at M9–16. Retain same-build ABBA timing and production KV allocation in the validation contract. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Keep streaming loads for larger projections and preserve all arithmetic. Record 336 bitwise checks and the production configuration control separately from the interrupted candidate. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Record the completed automatic-KV measurement, working-set timings, and the installed-binary M16/M32 discrepancy. Keep production speed acceptance on hold. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
This was referenced Sep 9, 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
DFlash2 QPN2 stores target NVFP4 codes separately from TurboMind, and FP32 LM-head serving still prepares unused FP16 packed copies. Add shared-code and compact-scale paths, and omit unused LM-head packing while retaining accelerated QPN2/QPN8 execution.
Under the production TP4 configuration, the latest follow-up reduces model loading from 8.203934 to 6.286138 GiB/rank after code sharing, saving 7.671183 GiB across TP4. Automatic KV budget increases from 15.76 to 17.70 GiB/rank. The original dual-code loading measurement was 11.08 GiB/rank.
VLLM_SM70_NVFP4_QPN2_SHARED_WEIGHT=1reads TurboMind codes directly, removing 2.835693 GiB/rank of duplicate target codes. Shared scheduling/cache recovery retains the existing arithmetic and dynamic-M fallback.VLLM_SM70_NVFP4_QPN2_SHARED_SCALES=1keeps QPN2 E4M3 scales and restores exact FP16 scales temporarily for TurboMind fallback. Small-M QPN2 decode and bounded dense prefill are unchanged. Admission requires rebuilt operators, shared codes, the DFlash2 TP4 q7/no-DBO contract, and graph capture sizes <=32. Larger graphs retain persistent scales to avoid capturing a separate temporary for every projection. Both switches default off.Base:
e5d63c51f0fcc1ddf75d229e3df06bf52df206f5ononecat/main. Head:d26804a9ccce2f2ac3fa4f3a69874575c1aa98e1. This extends the existing memory recovery PR rather than creating a duplicate. AI assistance was used; human review remains pending. Keep this PR Draft.Test Plan
Verify loader aliases, capability and graph-size gates, explicit packed top1, warmup dispatch, real checkpoint scale/output bits, and changed-input CUDA Graph replay. Measure operator costs independently from whole-model throughput. Preserve production serving: 4×V100-SXM2-32GB, Torch2.10.0+cu128/CUDA12.8, TP4, FP16 model/draft KV, maxlen262144, utilization0.8, automatic E4M3 KV, chunk4096, maxseq4, DFlash2 q7/probabilistic, FP32 logits, context pipeline/KV graph and CUDA Graph. Sampling remains temperature1/top_p0.95/top_k20/seed0, xhigh thinking and natural EOS.
Test Result
.venv/bin/python -m pytest tests/quantization/test_sm70_warmup.py tests/quantization/test_sm70_nvfp4_qpn2.py tests/model_executor/layers/test_sm70_lm_head.py -q: 43 passed.benchmark_sm70_nvfp4_shared_weight.py --compact-scalesreproduces the comparison against shared codes with persistent scales.Latest completed production allocation:
All four ranks agree. Census operations do not change allocated bytes. Both unused head matrices and persistent TurboMind scales are absent; the QPN8 acceleration copy remains. Idle snapshots show no active/waiting requests and zero KV usage. Automatic KV capacity grows12.29%, so total residency stays near the existing memory budget.
The latest MBPP28 warmup/three measured requests match all 754 tokens of the archived shared-code cohort; MBPP0 matches all 1093 tokens. Both finish naturally with nonempty answers. Median pure decode is 225.66tok/s, verification round 19.068ms, TTFT 107.95ms. Archived same-output values were221.40tok/s,19.435ms and112.37ms. No focused slowdown appears, but these are not contemporaneous controls; do not claim the approximately2% difference as a speedup.
Remaining acceptance and evidence boundaries
The current paired control was terminated during compilation and has no endpoint result. Earlier source-aligned cohorts produced different tokens; the latest archived-cohort match does not explain those differences or admit broader concurrency/long context. The switches remain opt-in and this PR remains Draft.
A benchmark-only sidecar option aligns legacy/shared QPN2 native implementations. The older installed core dispatched M9–32 to TurboMind despite newer Python route logs; that validation gap is separately documented. Failed lane mapping, old Flash-V100 extension, harness import/inference-mode errors, interrupted services and excluded fixed2GiB/8K/E5M2 diagnostics remain recorded.
docs/design/sm70_dflash2_shared_nvfp4.mdand the migration ledger retain contracts, reproduction, storage accounting, measured deltas and rejected variants. Task artifacts contain commands, manifests, source/diff and binary hashes, allocation stacks, operator samples and endpoint responses. Test services have exited and released their locks.Latest speed and quality follow-up
Inference source remains 2d683cc; the latest commit adds evidence only. The two completed candidate final answers pass MBPP base and EvalPlus hidden tests (2/2 each, dataset hash ee43ecabebf20deef4bb776a405ac5b1).
Two current same-source A/B attempts were interrupted before candidate execution, after six speed requests and only two/three quality requests. The latest parent received SIGINT and its cleanup sent SIGTERM to the child; there was no logged OOM or CUDA computation failure, and the sender remains unidentified. The planned 32-task and four-concurrent checks have no passing result.
Controls retaining old scales and head layouts show restart variation: MBPP28 returns 270 versus 634 tokens, first differing at zero-based token 8, while each process repeats its own output identically six times. Different-output decode medians 233.57/253.62 tokens/s are not a memory-optimization speed comparison. No new overall speed or broad quality parity is claimed. Preserve the interrupted cohorts, resolve uninterrupted GPU ownership and control reproducibility, and keep this PR Draft. No owned GPU/API or scorer processes remain.