Pull requests / #856

#856 hip: RDNA3 (gfx1100) WMMA kernel for the QSA block-score select/scorer (opt-in STRATA_SELECT_WMMA, gfx12/gfx11)

closed · @xyzzing · 0 评论 · 在 GitHub 查看

BenchmarksAMD / HIP

描述

Companion to #786: the same RDNA3 WMMA treatment for the QSA **select/scorer** path, which the profiler puts at ~12-14% of 128K prefill on gfx1100.

**What**
- `qsa_block_scores_wmma`: a gfx11 (RDNA3) WMMA block-scorer arm. Dispatch in `qsa_block_scores_tc` (qsa_select.cu) tries the gfx12 WMMA kernel first, then this arm under `STRATA_SELECT_WMMA` (opt-in; default unchanged). The tail block keeps the warp kernel's arithmetic (shared `block_scores_tail_kernel`, bitwise) and the `+1e9` dead-tail rule is exact.
- Parity harness `src/kernels/qsa_select_wmma_parity.cpp` (new): ragged query/block tiles, whole tiles, an x8-magnitude FP16-headroom case, degenerate n_kv=0, one-hot lane/store-adversarial case.

**Arithmetic contract and parity** (pre-derived before the kernel, rollout records §18): WMMA arm = FP16 inputs / FP32 accumulation; bound per entry **B = 2^-9.5·S + 8·2^-24·|score|** against a float64 oracle (S = the |k·q| magnitude sum, computed in f64 in the harness). Measured on the 10.2 nightly SDK: worst bound utilisation **11.0%** across all cases, **0 differing selection IDs** (top-k over warp vs WMMA scores, near-tie-gap guard), tail block **bitwise** the warp arm's, write-set canaries intact, negative control (+2.5·B perturbation) fails as required. The warp arm's host-model contraction pin (7.1.1-era: fma-left) no longer fits the nightly clang's `v_fmac` interleaving; the harness now enumerates six contraction shapes and reports the best fit as a diagnostic, with the oracle bound + selection agreement + tail check as the hard gates.

**Measured, paired A/B** (RX 7900 XTX, 0.1.39 + #786 arm-on in BOTH arms, arms differ only in `STRATA_SELECT_WMMA`; 5 pairs × 1k/32k/128k, odd pairs a-first):
| tier | prefill tok/s a→b (median) | Δ | decode tok/s a→b (median) | Δ |
|---|---|---|---|---|
| 128K | 1506 → 1675 | **+11.2%** | 66.0 → 69.3 | +4.9% |
| 32K | 1595 → 1689 | +5.9% | 73.6 → 74.4 | +1.1% |
| 1K | 764 → 791 | +3.5% | 72.0 → 72.0 | -0.0% |

Mechanism: the `qsa select` phase drops 10249 ms → 1952 ms (5.25×; 11.8% → 2.4% of 128K prefill). Consistent with the earlier 0.1.33 measurement (+9.8% @128K, scorer microbench 11.6×). Decode: no regression in any tier (medians; the one 51.9 tok/s outlier in b-128k-p2 does not move the median).

**Opt-in only.** `STRATA_SELECT_WMMA=1` enables the arm; the default path and the gfx12 arm are untouched.

站内延伸阅读

链到安装、模型与版本说明,便于 SEO/GEO,非官方 issue 正文。