Skip to content

Tune Qwen3.8 Flash Next TP2 TP4 decode FP8 BF16 GEMMs - #2

Merged
sammysun0711 merged 2 commits into
apinge:qwen38-flash-next-devfrom
yicyang:pr/qwen38-tp2-decode-fp8-gemm
Oct 9, 2026
Merged

sammysun0711 merged 2 commits into
apinge:qwen38-flash-next-devfrom
yicyang:pr/qwen38-tp2-decode-fp8-gemm

Conversation

@yicyang

@yicyang yicyang commented Sep 17, 2026 •

Copy link
Copy Markdown

What

Tuned decode GEMM configs for Qwen3.8 Flash Next on MI308X (gfx942, cu_num = 80).
Without them the dense decode projections fall back to the default kernel`.

All three files are keyed to the SGLang decode graph buckets
M = 1, 2, 4, 8, 12, 16, 24, 32.

Test

  • Tuned with csrc/gemm_a16w16/gemm_a16w16_tune.py (BF16) and
    csrc/ck_gemm_a8w8_bpreshuffle/gemm_a8w8_bpreshuffle_tune.py --libtype ck,cktile (FP8)
    on MI308X.
  • python3 -m unittest op_tests.tuning_tests.test_config_shape_collision passes: no
    duplicate (gfx, cu_num, M, N, K) keys across the merged config families.
  • End to end, sglang.bench_serving, 12000 input tokens, 350 output tokens, 32 prompts,
    concurrency 1:
TP Config Mean TTFT Median TTFT Mean TPOT Median TPOT QPS (32/duration)
2 without target CSV 1045.63 ms 1045.94 ms 13.63 ms 13.63 ms 0.17234
2 with target CSV 1049.24 ms 1049.41 ms 13.47 ms 13.47 ms 0.17388
4 without target CSV 840.17 ms 840.79 ms 13.02 ms 13.03 ms 0.18564
4 with target CSV 839.33 ms 839.48 ms 12.87 ms 12.87 ms 0.18758

Environment: MI308X (gfx942, 80 CUs), ROCm 7.2.4, PyTorch 2.12.0+rocm7.2.4.
Backend selections require revalidation when CK / CKTile / hipBLASLt change.

Submission Checklist

@yicyang
yicyang marked this pull request as ready for review September 18, 2026 02:21
@sammysun0711

sammysun0711 commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

Please double check that model level performance, TPOT seem slight improvement 43.80->43.22 ms for con=24 or even regression for con=1/8.

a8w8_bpreshuffle_tuned_gemm had no rows with K=2560, so every dense FP8
projection in Qwen3.8 Flash Next ran the default kernel on MI308X. Search
the three decode projections over the SGLang graph buckets and keep the
six entries that reproducibly beat the default by at least 3%.

The gains concentrate at M=24, the one bucket that is neither a power of
two nor near one: the default path costs about as much there as at M=32
(14.209 vs 14.464 us at N=8192) while M=16 costs 9.492 us, consistent
with rounding M up to 32. The retained cktile entries do not.

  N=2560 K=3072  M=4/8/12/24   4.07-4.60%
  N=6656 K=2560  M=24          6.95%
  N=8192 K=2560  M=24         21.55%

The other 18 searched shapes land within 1.5% of the default and are
deliberately left out, so the default path stays live for them.

FlyDSL candidates were excluded: that pipeline aborts the tuning worker
with "LLVM ERROR: Do not know how to expand this operator's operand!" on
llvm.amdgcn.raw.ptr.buffer.load.lds, and under --shape_grouped the crash
discards the ck/cktile results already measured for the whole group.

Also widen torch_to_c_types to accept torch.Stream. torch 2.12 passes the
generic Stream rather than torch.cuda.Stream, so the isinstance check
never matched and the ctypes bridge rejected the argument.

Measured on MI308X gfx942 80CU, ROCm 7.2.4, PyTorch 2.12.0+rocm7.2.4.
Model-level effect is below this setup's measurement resolution; see
docs/qwen3_8_flash_next_tp2_decode_fp8_gemm.md.
@apinge
apinge force-pushed the pr/qwen38-tp2-decode-fp8-gemm branch from 3df94b3 to a5f062d Compare September 23, 2026 06:46
@apinge apinge changed the title Tune Qwen3.8 Flash Next TP2 decode FP8 GEMMs Tune Qwen3.8 Flash Next TP2 TP4 decode FP8 BF16 GEMMs Sep 23, 2026
@apinge
apinge requested a review from sammysun0711 September 24, 2026 08:17
@apinge

apinge commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

@sammysun0711 Could you please help to check?

Comment thread csrc/cpp_itfs/torch_utils.py Resolved
@sammysun0711
sammysun0711 merged commit b7aed05 into apinge:qwen38-flash-next-dev Oct 9, 2026
1 check failed
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.

3 participants