Skip to content

[Kernel] Finalize the audited TP2 DFlash2 31/29 ms endpoint - #566

Merged
yangzhuxinyzx merged 17 commits into
mainfrom
codex/v100-quasar-dflash2-tp2-baseline-20260908-092504
Sep 9, 2026
Merged

yangzhuxinyzx merged 17 commits into
mainfrom
codex/v100-quasar-dflash2-tp2-baseline-20260908-092504

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Purpose

Finalize the user-accepted TP2 QUASAR + DFlash2 endpoint: 31.884546 ms on release1k and 29.279787 ms on MBPP28 per complete B1/q8 round. The user ended further tuning on 2026-09-10 and authorized audit and merge; 25 ms is no longer the target for this PR.

This PR adds the opt-in revision-2 E4M3 scalar decoder with ordered PV unroll eight, a separate TP2 q8 BV2 GDN schedule, focused numerical tests, and a reproducible matched QPN2 builder. It preserves FP32 partials/state/logits, E4M3 KV, scale rounding, K64 partition order, sampling and natural EOS. Unsupported shapes keep the existing path.

The branch incorporates main at 80545c010bbf6f5ed06458d992c189d75d0eff8f, including #556's FP32-beta and strided-QKV repairs. Conflict resolution retains both TP2/TP4 dispatch limits, nonoverlapping row strides and the TP4 fallback. The public benchmark now requires the actually accepted native revision 2. The later TP2 combined-copy experiment was withdrawn from source before finalization; its failed harness and local results remain recorded.

This scope extends the TP4 work in #556 rather than duplicating it. AI assistance was used for implementation and the user-requested audit. The existing PR is retained; no duplicate PR is opened.

Test Plan

Keep TP2/B1/q8 on physical V100 GPUs 4/7, CUDA 12.8, Torch 2.10.0+cu128, frozen model revisions, maximum context 262144, memory utilization 0.8, T1/k20/p0.95 and natural EOS. Separate diagnostic results from unprofiled round timing. Validate the merged source and rebuilt native module before merge.

Test Result

The accepted campaign uses three independent startups, five alternating pairs after warmup per fixture:

Metric release1k control / candidate MBPP28 control / candidate
Complete round, ms 32.934885 / 31.884546 29.830193 / 29.279787
Candidate round p50/p90/p99, ms 31.876 / 32.370 / 34.244 29.229 / 29.913 / 31.149
Candidate warm TTFT, ms 591.596 164.810
Candidate pure decode, tokens/s 94.089 155.623
Accepted drafts per round, both arms 2.010638 3.569231
Emitted tokens per round, both arms 3.010638 4.569231

All fifteen pairs and warmups preserve token IDs, acceptance counters and EOS. A separate two-rank full-model shadow preserves hidden states, full local-vocabulary FP32 logits and valid acceptance records under different invalid-tail sentinels. Accepted runtime source is ca0ea462c1877525fb231faf4f817d7929a3a64a; native SHA256 is 9d0fe7186bfe82ccd0b58f0795b9f0b4a70eb7ecf8dc9caf345efb4055752cdf.

  • Attention gates: 15 passed, covering exhaustive E4M3 bytes, graph changes through 262144, FP64 reference, padding, fallback and stale-library rejection. Historical native memcheck at 1025/3297/262144 has zero errors; bounded racecheck at 1025/3297 has zero hazards. The 262144 racecheck timed out and remains excluded.
  • Merged-source GDN tests: .venv/bin/python -m pytest --confcutdir=tests/kernels tests/kernels/test_sm70_dflash2_packed_gdn_fp32.py -q: 8 passed, including TP4 fallback, all eight acceptance selectors, changing graph operands, retired rows and strided state.
  • Merged-source stale-library tests: 2 passed. The QPN2 builder regenerates byte-identical tested source, SHA256 139ff11214d1fb49062efe1e6d9dc824588e5f2f14439435154d30b43915fc62.
  • The merged native module builds successfully, SHA256 a50e87abde5ca52d6be560448ed70220d2ce60c31f54facdf49b5732ca2123ac. Its 15 GPU attention tests pass; combined with the 8 GDN cases this gives 23 merged-source GPU tests. Full-model integration shadow passes both fixtures and both ranks, preserving complete FP32 logits, hidden states and valid acceptance/EOS records.
  • Targeted lint/type/license checks pass after formatting the changed lines. Conflict resolution was reviewed against both parents.

The final unprofiled integration startup uses the rebuilt module and five alternating pairs after warmup per fixture. Complete-round medians are 31.826824/29.074814 ms, versus contemporaneous controls of 32.863370/29.797836 ms. All ten measured pairs and both warmups retain tokens, acceptance and natural EOS. This is an integration confirmation, not a replacement for the accepted three-startup endpoint. Evidence: final-main-1-start-pair-summary.json and tp2-final-main-shadow-1-admission.json.

Remote pre-commit CI is green for d03edb067c9683c6892972b933bc1bcf52660a5d (run). The final source audit has no remaining blocking findings. Native/runtime code is unchanged from the validated merge commit 348fd5e2f3efa96ac06ede761817171531c1feb1; the last commit only documents frozen switches.

Integration scope

The new TP2 switches stay opt-in. The full measured combination also uses the retained single-layout QPN2 and context worker harness; merging these kernel components does not enable that whole combination by default. No service API, weights, model format or sampling policy changes.

These short-context endpoint measurements are not 256K performance evidence and do not resolve historical cross-startup variation. Arithmetic candidates with distribution drift, including the draft column-GEMM candidate, remain excluded. Full evidence and retained negative results are in docs/design/sm70_dflash2_tp2_verifier.md, campaign v100-quasar-dflash2-tp2-25ms-20260908.

Keep the q8 FP32-partial route opt-in while retaining the full-round quality gate and recording measured TP2 limits.

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>
Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Optimize TP2 E4M3 scalar attention with exact decoding [Kernel] Optimize TP2 attention and preserve packed GDN precision Sep 8, 2026
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>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Optimize TP2 attention and preserve packed GDN precision [Kernel] Optimize TP2 attention and packed GDN verification Sep 8, 2026
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>
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>
Generate the CUDA source used by the admitted TP2 projection experiments without installing a serving route. Record the full-projection trace, three-start decoder results, and rejected activation-layout screen.

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Optimize TP2 attention and packed GDN verification [Kernel] Add exact TP2 DFlash2 paths and a matched QPN2 builder Sep 9, 2026
Preserve the scalar q8 reduction and rounding contract while using an exact half bit expansion and FP32 scale. Require native revision 2 when explicitly enabled and reject stale revision 1 modules.

Validate with 15 native tests, 24 graph replacements, full-length memcheck, and bounded racecheck. Record combined precision diagnostics, first paired round cost, and rejected QPN2 candidates. Long racecheck timeout remains excluded.

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Report complete-round latency, TTFT, decode rate and separate accepted/emitted lengths for the native exact decoder plus context overlap, with full QPN2 and BV2 fixed. Retain the unmet 25 ms target and unresolved cross-startup limitation.

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>
Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Withdraw the unadmitted combined-copy experiment; retain its audit history.

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Retain both TP2 and TP4 dispatch contracts, FP32 beta and nonoverlapping row strides. Require native revision2 in the public benchmark.

Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Add exact TP2 DFlash2 paths and a matched QPN2 builder [Kernel] Finalize the audited TP2 DFlash2 31/29 ms endpoint Sep 9, 2026
Assisted-by: Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review September 9, 2026 16:36

@yangzhuxinyzx yangzhuxinyzx left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final audit at d03edb0: no remaining blocking findings.

Reviewed the exact E4M3 decoder, ascending PV FMA chain, FP32 partials and dispatch guards; TP2 BV2 recurrence and TP4 fallback; merged FP32-beta/nonoverlapping-row-stride repairs; QPN2 source reproduction; and unchanged sampling/precision contract. The unadmitted TP2 combined-copy route was withdrawn. The public benchmark now rejects native revision1.

Merged-source validation: 23 GPU tests pass, full-model logits/hidden/valid-acceptance shadow is exact on both fixtures/ranks, and five unprofiled pairs per fixture retain token IDs/acceptance/EOS at 31.826824 / 29.074814 ms. CI is green. The accepted endpoint remains the earlier three-startup 31.884546 / 29.279787 ms result; new switches remain opt-in and the full measured harness is not a new production default. User requested campaign closure and merge. AI-assisted review performed at the user's request.

@yangzhuxinyzx
yangzhuxinyzx merged commit 24220ca into main Sep 9, 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