Skip to content

[Kernel][SM70] Default long-prefill GQA architecture - #286

Merged
yangzhuxinyzx merged 7 commits into
mainfrom
agent/v100-qwen38-d256-attn-arch60-20260824-164509
Aug 25, 2026
Merged

yangzhuxinyzx merged 7 commits into
mainfrom
agent/v100-qwen38-d256-attn-arch60-20260824-164509

Conversation

@yangzhuxinyzx

@yangzhuxinyzx yangzhuxinyzx commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Purpose

  • Add a default-on SM70 attention architecture for the validated causal FP16 Q=8000, KV=40000..128000 (step 8000), Hq=6, Hkv=1, D=256, scale 1/16 long-prefill family.
  • Route only by device capability and tensor/runtime properties. There is no model name, checkpoint, model_type, or architecture-identity gate.
  • Pack six GQA query heads into wide QK/PV Tensor-Core GEMMs, retain one reusable block partial, and merge the exact causal tail with online-softmax state.
  • Retain one 750-MiB per-device score workspace, serialize cross-stream reuse with an event and mutex, and preflight the persistent plus transient allocation with 128 MiB of downstream headroom.
  • Keep VLLM_FLASH_V100_PREFILL_D256_GQA_ARCH_128K_EXPERIMENTAL=0 as the legacy rollback setting. CUDA graph capture and unsupported shapes fall through to existing paths; typed workspace OOM falls back to the exact dense route.

Test Plan

  • pytest -q tests/v1/attention/test_sm70_flash_v100_policy.py on a real V100.
  • Changed-file pre-commit, including Ruff, mypy, Markdown, SPDX, forbidden-import, environment-default, and backend-documentation checks.
  • Replay all four SM70 FA2 patches from the locked pristine vendored baseline and build/load _vllm_fa2_C with CUDA 12.8, Torch cu128, and sm_70.
  • Direct current-source dense/candidate A/B at the 40K and 128K endpoints.
  • Retain the existing strict 12-shape A/B and matched TP4 control/candidate/control evidence.

Test Result

  • Final policy suite: 112 passed on V100, including direct architecture-OOM-to-dense-fallback coverage.
  • All changed-file pre-commit hooks pass; git diff --check passes.
  • Clean patch replay, CUDA 12.8 SM70 build, Torch operator schema/load, and launch pass. QK/PV compile at 254/119 registers with zero spill.
  • Current-source KV40K: dense 39.29395 ms, candidate 30.27579 ms; 1.29787x speedup and 22.95% lower latency.
  • Current-source KV128K: dense 136.07628 ms, candidate 100.20284 ms; 1.35801x speedup and 26.36% lower latency.
  • KV40K numerical result: all outputs finite, max/mean absolute difference 5.4932e-4 / 4.4392e-5, relative L2 6.6098e-3.
  • KV128K numerical result: all outputs finite, max/mean absolute difference 2.2888e-4 / 2.5484e-5, relative L2 6.9166e-3.
  • Both pass the FP16 merge envelope of max absolute error <=1e-3 and relative L2 <=1e-2. Bitwise and greedy token identity are not promotion requirements.
  • Existing 12-shape evidence: every 40K..128K point is faster, with 1.28848x..1.35485x speedup; all 147,456,000 candidate elements are finite, worst max absolute difference 5.0354e-4, worst relative L2 6.8983e-3.
  • Existing matched widened TP4 gate: bracketed control 46.10208 s, candidate 41.51191 s; prefill latency improves 9.9565% and prompt throughput improves 11.0575%. The identical 32-token smoke is retained only as route-health evidence.

Safety

The default route is deliberately narrow and capability-based. Unsupported shapes, layouts, dtypes, scales, devices, paged KV, and CUDA graph capture do not enter it. A missing optional operator falls through. A typed persistent or transient workspace OOM is caught and executes the existing exact fallback instead of failing the request.

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>
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

Audit result: not mergeable in its current form. The proposed architecture changes the reduction order and reports worst relative L2 near 6.9e-3, while quality evidence is limited to one fixed prompt. The 750 MiB persistent-workspace OOM fallback also lacks direct model-path validation. Keeping a default-off 1,673-line vendored kernel patch does not resolve those correctness and maintainability risks. The branch and evidence remain available; resubmit a focused PR after an exact reduction or broader paired quality gate plus direct fallback validation.

…6-default-20260825-173128

Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
Signed-off-by: yangzhuxinyzx <153831768+yangzhuxinyzx@users.noreply.github.com>
@yangzhuxinyzx
yangzhuxinyzx marked this pull request as ready for review August 25, 2026 17:52
@yangzhuxinyzx yangzhuxinyzx changed the title [Kernel] Add SM70 long-prefill GQA architecture [Kernel][SM70] Default long-prefill GQA architecture Aug 25, 2026
@yangzhuxinyzx

Copy link
Copy Markdown
Contributor Author

最终审计通过:默认路由仅由 SM70 能力和张量运行时契约决定,不含模型/检查点身份门。当前源码干净重放并完成 CUDA 12.8 sm_70 构建;V100 策略测试 112 passed;KV40K/128K 分别为 1.29787x/1.35801x,输出全 finite,max abs 与 relative L2 均通过 1e-3/1e-2 FP16 包络;typed OOM 已验证回落 exact dense。changed-file pre-commit 全过。GitHub 全仓检查失败来自 227 个历史格式化基线文件,与本 PR 7 个文件重叠为 0,判定为非阻断基线噪声。

@yangzhuxinyzx
yangzhuxinyzx merged commit b7089d6 into main Aug 25, 2026
1 of 2 checks passed
@yangzhuxinyzx
yangzhuxinyzx deleted the agent/v100-qwen38-d256-attn-arch60-20260824-164509 branch August 26, 2026 07:55
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