Skip to content

[Kernel] Preserve DFlash2 sampling precision and repair QUASAR TP2 - #517

Merged
yangzhuxinyzx merged 10 commits into
mainfrom
codex/v100-quasar-dflash2-operator-audit-20260905-172402
Sep 6, 2026
Merged

yangzhuxinyzx merged 10 commits into
mainfrom
codex/v100-quasar-dflash2-operator-audit-20260905-172402

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Purpose

Integrate the QUASAR + DFlash2 output-precision repairs and their audit record into main. TP2 GDN output width 8240 was accepted with insufficient alignment and produced corrupt TurboMind results; physical width 8256 restores the operator contract. Tied top-k/top-p cutoffs could produce incorrect candidate sets, and conditional lookup agreement incorrectly rewrote the probability of the random prefix used to select that lookup. Both sampling defects are repaired.

The precision path independently supports FP32 candidate/dense logits on TP2/TP4 and explicit E4M3 grouped q8 verification. It also retains optional context/metadata CUDA graphs and deferred accepted-slot writes, with the recorded numerical and latency controls. Diagnostic tensor ownership, TP rank detection and reference weight sharding are repaired.

  • Integration base: 95205a2d9952813aa7469f63ff65b8f2813c027a (onecat/main).
  • Reviewed and tested integration head: 0b793e1fc5068cac4ac79d4d3516b111a1f89726.
  • The only merge conflict was the append-only migration ledger; both histories are preserved. Main's independent QSA, HC/router, AWQ and PP changes remain integrated.
  • VLLM_SM70_DFLASH2_FP32_LOGITS, VLLM_SM70_DFLASH2_CONTEXT_PIPELINE and VLLM_SM70_DFLASH2_CONTEXT_KV_GRAPH remain opt-in. Target E4M3 requires explicit --kv-cache-dtype fp8_e4m3 and a rebuilt Flash-V100 library. TP2 QPN2 is not promoted.

This extends the existing repair PR rather than creating a duplicate. Related prefill race/alignment PRs #202/#226 already exist in main and in the previously measured library. QSA #494/#525 is a different model route. The unadmitted FP32-partial experiment #524 is not included.

Test Plan

Rebuild Flash-V100 from the integrated source for physical SM70, then run scoped operator, CUDA Graph, sampling, TP2 admission, reference-sharding and routing regressions. Preserve the prior full-model captures, scored-output limitations and separately measured unprofiled latency. Do not treat a merge-time operator pass as a new end-to-end quality or speed result.

The exact .venv/bin/python -m pytest arguments and JUnit XML files are retained in bundle v100-dflash2-quality-mainline-20260906. Scope:

  • tests/kernels/attention/test_dflash2_context_pipeline.py, test_sm70_grouped_e4m3.py, test_sm70_flash_v100_grouped_verify.py, test_sm70_flash_v100_paged_prefill_determinism.py;
  • FP32 head and diagnostic ownership tests under tests/kernels/core, and NVFP4 output padding under tests/kernels/quantization;
  • tests/v1/sample/test_topk_topp_tied_cutoffs.py;
  • DFlash2, lookup, alignment rank and rejection utility tests under tests/v1/spec_decode;
  • FP32 head admission / TurboMind adapter, benchmark oracle and Flash-V100 routing-policy tests.

Test Result

427 distinct scoped tests passed after main synchronization.

Scope Passed
Native/kernel/graph and prefill replay 48
Sampling cutoff boundaries 14
DFlash2, lookup, rank and rejection 218
FP32 head admission and quantization adapter 19
GDN reference shard oracle 6
Attention routing policy 122

Two historical prefill tests initially could not call the current native API because the anchor arguments were missing. Their direct call now uses the public wrapper's None, 0 contract; L300/L512 direct and public paths each repeat bitwise across six launches. Failed API-validation logs are retained; no numerical assertion was relaxed. The other 46 initial kernel checks passed and were not unnecessarily repeated.

Fresh Flash-V100 build: CUDA 12.8, Torch 2.10.0+cu128, Python 3.12, SM70; GPU tests used an exclusive V100 GPU4 lease, now released. Native SHA256: 2fca94182ab26205e0bd4f65a92df8c46017c6c8ede3df3fd7ef28e9b03f78e5. The native vLLM core retains the previously validated artifact; this is not a new full-wheel build. Scoped pre-commit, mypy, clang-format, Markdown and DCO checks pass. GitHub CI passed on this exact head: run 34029576736.

Previously measured evidence, with detailed contracts in the linked reports:

  • Problematic LM-head row sampling TV: 0.02153214 → 3.6694e-7; all 24 measured nucleus supports match the FP32 reference. Real KV conversion maximum relative L2: 0.0593241 → 0.0290236 with E4M3. These are operator/distribution improvements, not dataset-score percentages.
  • TP2 GDN: eight real shards improve from 32.68%–51.25% relative L2 to 0.0249%–0.0323% after alignment repair.
  • Conditional lookup example q(A)=q(B)=0.5, p(A)=0.8: 100,000-seed output frequency improves from 0.700270 to 0.800720. Default q8 and agreement=0 behavior are unaffected.
  • Verifier ledger: 535 target/draft head rows with no required candidate misses; 60 independent real rejection rounds match dense decisions. Ten actual context pipeline off/on boundaries match bitwise, including states, probabilities and accepted counts.
  • Historical GPU0–3 unprofiled E4M3/FP32 optimized round medians: 18.892 / 18.435 ms, with full token hashes matching that precision control. Independent GPU4–7 closure: 19.505 / 19.092 ms, each repeated three times with natural stop. Different GPU sets and output trajectories prevent pooling these as a matched performance result.

Remaining limits and merge scope

The user explicitly requested mainline merge on 2026-09-06 after these limits were reported. This records authorization to integrate the validated implementations and audit evidence, not completion of every quality investigation or a claim that the user independently reran tests.

  • The 17.6–18 ms target is not yet recovered under the retained precision contract.
  • Same-configuration fixed-prefix diagnostics still reach 4.33% TV; norm-switch comparisons reach 4.55%, so attribution remains open. Prefill already diverges before forced q8 acceptance; the first observed layer-0 GDN difference precedes output normalization. Conv/SSM state replay is the next causal gate.
  • QAT W4A4 versus SM70 W4A16 execution and the unavailable BF16 teacher remain separate questions. No broad dataset quality improvement or complete teacher-equivalence claim is made; the retained small production coding sample was Base 3/3, Plus 0/3.
  • No fresh full-model, 256K endpoint or performance claim accompanies this integration. Finite operator checks do not prove universal shortlist coverage or all-model quality.

Reports: operator audit, E4M3/FP32 precision, TP2/TP4 and QAT, fast-path numerics, verifier and prefill PR audit, latency controls.

AI assistance: OpenAI Codex. Commits retain DCO sign-off and assistance attribution. No model weights, native build products or raw captures are committed. Task GPU leases and test processes are released; canonical checkout and unrelated services are untouched.

…cles

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Bugfix] Guard DFlash2 sampling cutoffs and repair operator audit oracles [Kernel] Add E4M3 KV and FP32 logits for DFlash2 quality Sep 6, 2026
Generated-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Generated-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Add E4M3 KV and FP32 logits for DFlash2 quality [Kernel] Preserve DFlash2 precision and recover q8 latency Sep 6, 2026
Generated-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Generated-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Preserve DFlash2 precision and recover q8 latency [Kernel] Preserve DFlash2 precision and repair QUASAR TP2 execution Sep 6, 2026
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Preserve DFlash2 precision and repair QUASAR TP2 execution [Kernel] Preserve DFlash2 sampling precision and repair QUASAR TP2 Sep 6, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

本轮审计(head 53be620):数值修复值得保留,暂不整包合并,PR 继续 open。通用 apply_top_k_top_p_triton 在 top-k/top-p 启用时无条件 logits.clone()(1123 行),随后 Python if reference_rows.any()(1144 行)会读取 CUDA 标量并同步主机。这个开销不限于 QUASAR/SM70,也发生在没有回退行的普通路径。建议保持采样正确性修复,同时消除正常路径的整词表复制/主机同步,补针对性采样延迟比较;不要靠撤销数值修复通过。当前未测量其整机退速,以上是源码确认的热路径风险。

审计由 OpenAI Codex 辅助,按仓库所有者要求执行;未关闭 PR。

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Preserve both audit histories and independent mainline QSA, AWQ, and PP changes. Update the old paged-prefill regression for the current native signature.

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review September 6, 2026 11:15
@yangzhuxinyzx
yangzhuxinyzx merged commit a193c28 into main Sep 6, 2026
2 checks passed
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.

1 participant