Conversation
Add the typed inference operator, prepared-bank decoder, FP32 reduction kernels and standalone GPU tests without changing model dispatch. Keep 3B scalar loading here so cooperative metadata access can be reviewed separately. Assisted-by: OpenAI Codex <noreply@openai.com> Signed-off-by: Leonccaa <166551845+Leonccaa@users.noreply.github.com> (cherry picked from commit 27a27d3)
Fresh exact-head SM70 regression (2026-09-06 UTC)Rebuilt and tested standalone head On V100 / SM70 / CUDA 12.8:
The old relative-only gate still has its documented tiny-value exception: A small real-checkpoint layer-1 / rank-0 graph timing check (12 ABBA pairs, The final public stack also passed 209 adjacent tests in a complete native Full-model runtime-selection/quality results belong to #521; this PR alone AI assistance: Codex performed the source audit, isolated builds, test |
|
本轮源码已通过后继 PR #521/#522 和集成 #526 纳入 main,优化没有丢失。核对 main@4366d9d5fe 与本 PR:QPN 核心差异仅为后继的 W13 合作元数据读取;原 GPU 回归测试内容相同。 本 PR 的 5b4135f 是独立提交,后继分支采用了另一份 kernel 提交 9ae1a29,因此 GitHub 没有自动将 #519 标成 merged;直接合并会产生 kernel/docs 的 add/add 冲突。本轮遵照“没合并的继续 open”保留该 PR,不关闭、不把新主线退回旧的标量读取实现。后续只需处理提交历史/重叠整合,不需要重新发明或重复叠加这个加速。 |
Purpose
Add a native SM70 operator for the Qwen3.8 TP4 / native-group-32 / E512 / top-k 10 AWQ single-token (M=1) routed-expert step:
_C::awq_moe_qpn_m1_sm70_out, exposed asvllm._sm70_ops.awq_moe_qpn_m1_sm70_out, with an independent GPU test and a design/contract document.On 4x V100 the current AWQ M=1 path runs W13 and W2 through the generic TurboMind GEMM: M padded to 8, N320 padded to 384, a 2-stage shared-memory pipeline and a serial cross-CTA split-K. Isolated profiling of the real layer-1 weights showed AWQ W13 at about 1.9x the time of the NVFP4 M=1 kernel while reading 4% fewer DRAM bytes, i.e. an execution-structure gap rather than a format cost. This operator applies the existing quadpair-N
m8n8k4M=1 dataflow (mxfp4_qpn_m1_sm70.cu, v100-skinny lineage, retainedLICENSE.v100-skinnynotice) to AWQ's existing prepared banks, and closes most of that gap at the operator level.The operator is self-contained: it consumes the prepared banks that the AWQ loader already produces, needs no repack or extra weight copy, and can be benchmarked and validated on its own. It registers nothing in the model runtime and changes no default route.
What it does
(10, 160)FP16 intermediate.(1, 2560)FP16 output. No atomic FP16 reduction.half_fma(q, scale, half(-zero * scale))boundary; it does not substitutehalf((q - zero) * scale). Both existing metadata layouts are supported: 4-byte{FP16 scale, FP16 bias}and 3-byte{FP16 scale, u8 zero}.torch.compile.The CTA-local reduction changes FP32 summation order relative to the legacy split-K route, so bitwise equality with the legacy path is not promised and neither path is treated as the mathematical reference. Weight decoding is bitwise identical to the legacy path on the sampled real weights (3.27M values); on layer-1 W13 outputs, 194 of 76,800 values differ in the last FP16 bit, max absolute difference about 3.05e-5.
Operator results
Real layer-1 AWQ weights, TP4 rank 0, M=1, top-k 10, K2560/N320 (W13) and K160/N2560 (W2). CUDA Graph replay of 48 calls, 7 samples, medians in ms per 48 calls. "Hot" reuses the same 10 experts; "rotating" cycles through 480 experts so the working set exceeds L2. The NVFP4 column is the existing native NVFP4 M=1 kernel on the same skeleton, as a reference, not a target.
These are operator timings, not model throughput. Evidence root:
qwen38-c1-qpn-awq-20260905/evidence-r1(W13) andevidence-r2(W2).What is deliberately not in this PR
Runtime dispatch is not included. Selecting this operator changes model behavior (reduction order, hence sampled-token trajectories at near-ties) and has to be judged with its own full-model quality evidence, whereas the operator itself can be reviewed as a kernel against a fixed contract. An opt-in, default-off dispatch on top of this operator will be proposed separately; a full-model C1x64K measurement with that dispatch already exists and will be presented there.
Also not included: any change to prepared weight layout, loader, prefill, grouped decode, router, shared experts, attention or defaults.
Duplicate-work check
Open-PR searches on 2026-09-06 in
1CatAI/1Cat-vLLMfor "AWQ QPN", "QPN M1", "awq_qpn", "SM70 AWQ single-token", "AWQ M1" and "Qwen3.8 AWQ decode" found no competing native AWQ M=1 operator. Hits were #509 (conversion-cache release), #349 (PP2/TP4 FP8 tactics), #431 and #410, which are unrelated. #510 tunes the NVFP4 M=1 kernel and does not implement an AWQ decoder. Base ismain@755baae1d0; the commit applies cleanly.Test plan and results
tests/kernels/test_sm70_awq_qpn_m1.pypassed 2/2. It independently constructs both prepared layouts and the N32/K8 nibble order, checks one-hot boundary reads at K indices 0/31/32/2559 against exact expectations, an FP64 W2 dot reference with an explicit FP16 rounding allowance, changing CUDA Graph inputs, invalid and duplicate expert IDs, aliased/misaligned/wrong-dtype argument rejection, and the registered fake op undertorch.compile. A CPU skip is not a GPU pass.git diff --check: clean.Provenance
Fork review draft: Leonccaa#10 (same commit, rebased onto
mainwithout changes).AI assistance was used. OpenAI Codex implemented the operator, tests and evidence under Leon's direction; Claude Code performed an independent line-by-line review of the kernel, the rebase onto
main, the pre-commit run and this submission. Human review is still required.🤖 Generated with Claude Code