Skip to content

[Kernel][SM70] Accelerate Qwen3.8 QSA paged prefill - #378

Merged
yangzhuxinyzx merged 8 commits into
mainfrom
codex/v100-qwen38-qsa-paged-prefill-20260828-041420
Aug 28, 2026
Merged

yangzhuxinyzx merged 8 commits into
mainfrom
codex/v100-qwen38-qsa-paged-prefill-20260828-041420

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Purpose

Accelerate Qwen3.8 selected sparse prefill on SM70/V100 by exposing each four-token QSA selection as a zero-copy Flash-V100 XQA page while preserving task-relevant numerical quality.

Changes

  • Convert the exact FP16 Hq6/Hkv1/D256, 2051-token QSA selection layout into locality-sorted virtual page-4 KV.
  • Route prefill batches with at least 4096 real query rows by default; retain VLLM_SM70_QSA_XQA_PAGE4=0 as an operational escape hatch.
  • Support both contiguous and interleaved K/V cache strides without copying cache data.
  • Keep the causal partial page last and validate it against the expanded QSA indices.
  • Clamp padded/stale positions to live sequence lengths and make invalid requests inert.
  • Expand the Flash-V100 per-tile page-ID capacity without reducing declared V100 occupancy.
  • Forward QSA positions/lengths, add focused route and metadata tests, and record the audit in the migration control document.
  • Include [Bugfix][QSA] Keep compressed block tables in physical-page units #381 so the compressed QSA scorer consumes scheduler-level physical page IDs before this attention fast path runs.

Test Result

  • GitHub full pre-commit on the repaired latest-main branch: passed.
  • Combined route, metadata, and [Bugfix][QSA] Keep compressed block tables in physical-page units #381 physical-page tests on V100: 15 passed.
  • Full SM70 extension build: passed with CUDA 12.0 / Torch cu128 for sm_70.
  • 4095 rows: exact Triton fallback, identical with or without forwarded metadata.
  • 4096-row interleaved-KV A/B: 27.8303 -> 8.84736 ms including table/sort (3.1456x); max abs 6.104e-5, relative L2 2.845e-4, cosine 0.99999994, all finite.
  • Nonmonotonic contiguous-page A/B: max abs 3.815e-6, relative L2 3.645e-4, cosine 1.0.
  • Tail counts 1/2/3: relative L2 at most 3.64e-4, cosine at least 0.99999988.
  • Hybrid 784/16 geometry with a nonmonotonic 128-entry page-16 table: max abs 3.815e-6, relative L2 3.631e-4, cosine 0.99999994; CUDA Graph replay is bitwise equal to eager output.
  • Page-16 context sweep at 4096 rows:
    • 64 selected tokens: 29.225 -> 1.010 ms (28.95x)
    • 512 selected tokens: 27.063 -> 3.204 ms (8.45x)
    • 2048 selected tokens: 27.835 -> 11.203 ms (2.48x)
    • every arm: relative L2 below 3.84e-4, cosine at least 0.99999994
  • Prewarmed CUDA Graph capture and two replays are bitwise equal to eager page4 output, hash 9b4c76f8420d6e349dc7d552c72d6f0a861332e7e8e8f62459a1c48f0faf278f.
  • Existing FP16 page-16/page-784 XQA-to-scalar smokes pass at relative L2 3.03e-5 / 4.10e-5.

Decision

The route is materially faster across short, medium, and saturated selected contexts, and its differences are small accumulation/order effects rather than quality regressions. It remains default-on under the project policy.

Repair chain: #382. Final candidate head: 7c4c795f5db1542ef0e496d3215afaef04b00d9f; tree: a6d9af1056de0db77294f2209f86c39e24eb5def.

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
…-latest-main-20260828-1308

[Kernel][SM70] Repair #378 on latest main
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Repair #382 is now merged into this branch. The final candidate is 7c4c795 (tree a6d9af1056de0db77294f2209f86c39e24eb5def), includes #381, and keeps the audited performance route default-on. Final full pre-commit is running on this exact head.

@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review August 28, 2026 05:32
@yangzhuxinyzx
yangzhuxinyzx merged commit e8f4026 into main Aug 28, 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