Skip to content

[Kernel][WIP] Optimize exact single-request Qwen3.8 QSA and router - #507

Closed
yangzhuxinyzx wants to merge 3 commits into
codex/v100-qwen38-hc-15ms-20260905-1702from
codex/v100-qwen38-qsa-router-exact-20260905-105924
Closed

[Kernel][WIP] Optimize exact single-request Qwen3.8 QSA and router#507
yangzhuxinyzx wants to merge 3 commits into
codex/v100-qwen38-hc-15ms-20260905-1702from
codex/v100-qwen38-qsa-router-exact-20260905-105924

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Purpose

Implement three lossless follow-ups to the measured single-request no-MTP TP4
V100 baseline: current-source QSA decode top-k runtime parity, 32-bit FP16
router ordering keys, and pre-resolved sparse KV addresses.

Stacked on #506 to retain the 96.411 tok/s HC baseline. Final integration is
main at base755baae1d075ee04fa9096b23fc0225b23589a86. Does not duplicate batched
HC/QSA #504 or Page4 ordering #494: this scope is M1, exact existing FP16
arithmetic/order, and source-overlay runtime binding.

AI assistance: OpenAI Codex. Human review/testing is required. Keep Draft until
endpoint/quality gates pass; operator speedups are not endpoint claims.

Test Plan

  • Bitwise router IDs/weights/metadata over raw half encodings, ties and invalid
    rows, followed by changed-input/poisoned CUDA Graph replays.
  • QSA selector old/current-header exact comparison through lengths65536 and
    the2304/2305 specialization boundary; M2 generic fallback unchanged.
  • Sparse-address production A/B at8K/32K/256K cache sizes, preserving logical
    order, invalid entries, page relocations and attention/merge arithmetic.
  • Same-contract combined whole-model baseline/trace; short and261632-token
    natural-output checks plus262143-input/1-output boundary case. No resident API.

Test Result

  • Production/model source d2c8401; evidence/test head bbdf0af.
    Targeted Ruff passes, CPU49 passed/1 GPU-only skip.
  • Router1280 rows bitwise and16 changing graph replays; interleaved/warmed
    48-call control0.252652 ->candidate0.203530ms.
  • QSA72 exact cases and16 changing graph replays;12-call
    control0.258196 ->decode0.111665ms.
  • Sparse address candidate passes8 changing graph scenarios at each length.
    12-call attention/merge including resolver:8K0.345016 ->0.318909ms,
    32K0.384205 ->0.367094ms,256K0.365860 ->0.323968ms.
  • Actual installed-old QSA oracle also passes72 cases/16 replays. Additional
    changing-length graph test:128 replays/1536 row comparisons, exact through
    fast/fallback boundaries, ReLU ties, close/nonfinite scores and padded rows.
  • Actual interleaved K/V stride gate passes8 graph scenarios at8K/32K/256K.
    The earlier timing table uses separate K/V buffers; the new test is quality-only.
  • Combined model source d2c8401:98.939675/98.977150/98.978711 tok/s,
    aggregate98.965175, TPOT10.104565ms. Frozen baseline96.411020/10.372258ms;
    observed0.267694ms/token improvement, not a fully deterministic A/B claim.
  • Real trace proves specialized QSA top-k + resolver runtime hits. QSA
    top-k0.307393 ->0.175693ms; router0.486903 ->0.356512; sparse partial+merge
    plus resolver0.553787 ->0.527498ms. These are diagnostic GPU service sums,
    not additive endpoint wall time. Keep the recorded rank-skew outlier.
  • Two short plus261632-token natural-EOS/thinking checks pass.262143+1
    exact boundary completes. These are health/boundary checks, not retrieval.
  • IMPORTANT: three candidate greedy repeats are not bitwise equal. A single
    clean old-source4ae6 control reproduces the same early-EOS513-token hash,
    even BEFORE the long request. It also varies after the long request.
    This proves that symptom exists without these optimizations, not that all
    output drift is harmless. Old control96.107235/96.083709 tok/s before/after.
    Existing open PR [Bugfix][SM70] Stabilize QSA page4 order under KV relocation #494 is a relevant allocation-order suspect, not a proven
    cause for every NVFP4 difference. Keep Draft pending the integration/quality gate.
  • Exactly two model initializations: combined candidate, then isolated old
    repeatability control. All workers/samplers/operator jobs/queues exited;
    GPU0–3 released, unrelated GPU4–7 service untouched. No main merge or API.
    -100 tok/s and the previous complete-HC1.5ms target remain unmet.

See docs/design/sm70_qwen38_exact_decode_followup.md for contracts, rejected
drifting first timing, sidecar hashes, public reproduction scripts and evidence.

Assisted-by: OpenAI Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Assisted-by: OpenAI Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Assisted-by: OpenAI Codex
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Integration audit requested by the repository owner: the complete head bbdf0af is already an ancestor of main 95205a2 through #525 (verified with git merge-base --is-ancestor). Closing this stale stacked Draft as already integrated, not rejected. Its base is still the old HC feature branch; merging it there would not deliver anything new to main. #532 supplies the missing current-source runtime builder and reproducibility acceptance; #510 remains a separate unaccepted experiment.

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