Repository navigation
[AMD] Qwen4-Exp SP: tuned prefill FP8 GEMMs, zero-copy AG consumer and faster hc_combine - #108
Conversation
…e gate reduction The one-row kernel is memory-latency bound on MI308X: half the issue slots idle, two serial memory round trips per row. The two-row variant issues every load before the gate reduction and shares each inject-weight vector between two rows: 1.5-1.7x per call for 4 x 2560 rows, bit-identical. - HcCombineKernel gains a kRows2 flag that launches hc_combine_rows2_kernel with the same tensor checks. - Built and used on ROCm only, for rows of at most 4 x 2560 elements (wider rows spill registers: 0.89x at 4 x 4096); CUDA builds are unchanged. - test_hc_combine.py: rows2 vs one-row bit-identity, and AMD CI registration.
b07141c to
5f6fc8f
Compare
…eshuffle(out=) Each landed all-gather block's PTPC FP8 GEMM writes its rows of the gathered output in place, saving one full-output copy per layer. It applies only where the projection's forward is exactly aiter's PTPC GEMM (compressed-tensors per-channel FP8, no bias, no output gather, no layernorm-SP matmul) and aiter's gemm_a8w8_bpreshuffle accepts out=; otherwise the per-block copy stays. Bit-identical to the copy path. With aiter's TP2 prefill GEMM rows and C-shuffle epilogue (qwen38-flash-next-dev), TP2 c8 / c12 QPS at 12000 in / 350 out goes up 4.6 % / 4.3 %.
5f6fc8f to
5601928
Compare
Review follow-up: reuse sglang.srt.utils.is_hip, as elementwise.py next to it does, instead of a module-level torch.version.hip check.
…on gfx942 Both are measured on MI308X only, so every other device keeps the original path: no two-row wrapper is built and hc_combine runs the one-row kernel, and the AG consumer keeps the per-block GEMM + copy. Uses the existing is_gfx942_supported(). The two-row test runs on the gfx942 AMD CI runner.
MTP verify runs the lm_head on bs x 4 rows, so c12 (48 rows) fell back to hipBLASLt. Tuned 48/64 buckets for all four Qwen3.8 shards on MI308X: TP2 393/410 us vs hipBLASLt 534/549 us (TP1 734/765 vs 1007/1033, TP4 216/225 vs 298/305, TP8 126/127 vs 128/148).
Changes are
Additional CI summary metrics:
|
Summary
TP2 prefill and MTP decode on top of the SP + SDMA overlap (#89), measured on the current
qwen4_v0.5.21(with #111). The GEMM tuning lives in apinge/aiter#12 (qwen38-flash-next-dev), which this PR depends on.hc_combine(gfx942). The one-row kernel was memory-latency bound. The two-row kernel issues all loads before the gate reduction and shares the inject weight between two rows: 1.5-1.7x per call for rows of at most 4 x 2560, bit-identical. Wider rows keep the one-row kernel.aiter.gemm_a8w8_bpreshuffle(..., out=out[r0:r1]), saving one full-output copy per layer, bit-identical. It falls back to the copy for any other projection or an aiter withoutout=.rocm_bf16_gemv). MTP verify runs the lm_head on bs x 4 rows, so c12 (48 rows) fell back to hipBLASLt. New 48/64 buckets for all four Qwen3.8 shards; TP2 393 / 410 us vs hipBLASLt 534 / 549 us.apinge/aiter#12 adds:
out=;How to enable
Nothing to set:
evaluation/launch_qwen38_flash_next_fp8_mi308x_pure_tp_4_or_8_or_2.shdefaults turn everything on (SP + SDMA,MTP=1). Install aiter with apinge/aiter#12; it is Python and CSV only, so no rebuild is needed. LeaveAITER_CONFIG_GEMM_A8W8_BPRESHUFFLEunset.Non-gfx942 devices take the original paths.
E2E
MI308X TP2, launch script as is, 12000 in / 350 out, base =
qwen4_v0.5.21@ b2ff410 (#111) with aiterqwen38-flash-next-dev@ 8d9080a8d. Base and PR are interleaved, 2 rounds each per mode; every round passed the GPU-isolation guard.MTP off (
MTP=0):MTP on (
MTP=1, EAGLE 3/1/4):Accuracy
hc_combineand zero copy are bit-identical to the paths they replace. The tuned FlyDSL GEMMs differ from CK by 1 ulp on about 5e-6 of bf16 outputs.test_hc_combine.py: 22 passed;test_rocm_bf16_gemv.py: 95 passed.Notes
hc_combine. Its linear layers are BF16, so the FP8 rows and the zero copy do not apply there.Trace(Before)
AG + in_proj
out_proj
hc_combine
Trace(After)
AG + in_proj
out_proj
hc_combine