You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[CK] [FlyDSL] Introduce FP8 a8w8 gemm kernel with fp32 blockscale to uplift the MI355 blockwise gemm perf - #5969
FP8 blockwise gemm with fp32 scale has low perf on MI355. The pain point is have to apply dequantization scale on the none-scale MXFP8 MFMA ISA on every K block accumulation . This PR introduce a new algorithm implementation on to solve this. Support both plain B layout and preshuffled B layout.
Technical Details
To squeeze hardware performance, design a new pipeline algo:
1, Based on 8 wave gemm pipeline, introduce a new pipelining algorithm to break the dequantization dependency on MFMA C. MFMA engine can run parallel with VALU, which make dequantization latency is hidden by MFMA.
2. Tensor A scales would be loaded into LDS and B scale directly to registers.
3. Tensor A scales use [BK, M] layout to access HBM with coalescing
4. This algorithm consume too much VGPRs. Split M further on the 8 wave algo to remove VGPRs spill.
5. Use padding not swizzling to avoid bank conflicts.
6. Precalculated vmem/lds offset to lower down VGPRs footprint and also achieve clean mainloop
7. Permute lane to store 4xDWORD per lane in epilog part.
8. Prevent v_pk_fma to ensure VAL is hidden by FMA ops.
tuned model config update
test covered 12,611 gfx950 shapes and switched 7,252 rows to FlyDSL kernel.
Across all 7,252 tested replacements, FlyDSL's calc_diff is no worse than that of the replaced kernel. The diffs are identical in 7,246 cases, and FlyDSL achieves a lower diff in the remaining 6 cases.
Config
Replacements
Identical
Old kernel max diff (FP32 ref)
FlyDSL max diff (FP32 ref)
FlyDSL max diff (BF16 ref)
ds_v3
5379
5379
1.84e-06
1.84e-06
5.9e-09
dsv4
625
625
1.79e-06
1.79e-06
4.0e-09
qwen3_next_80b
516
516
1.53e-06
1.53e-06
2.8e-09
dsv4 bpreshuffle
285
279
6.22e-06
1.79e-06
6.2e-09
bpreshuffle dsv3
202
202
1.76e-06
1.76e-06
4.0e-09
bpreshuffle qwen3.5_397b
115
115
1.53e-06
1.53e-06
3.0e-09
9 other configs
130
130
≤1.54e-06
≤1.54e-06
≤5.7e-09
No numerical-accuracy regressions were observed under the calc_diff metric in these tested replacements.
In 7,236 of the 7,252 replacements, both diff values are exactly equal.
In 10 more (old kernel cktile), they differ by at most 3.3e-14: 5 slightly higher, 5 slightly lower.
In the remaining 6 (old kernel asm), FlyDSL is clearly better.
Performance Test Result
HW platform : smci355-ccs-aus-m09-09, this platform TFLOPS has some perf gap with top performance 355. About 5% -10% gap with top perf MI355 machine.
Ideal shape perf lift up:
Choose some gemm perf friendly shape and compare performance with aiter optus, ck,cktile, asm backend. Some shapes can achieve 3000 TFlops.
M
N
K
TP
B layout
Best non-FlyDSL backend
Best non-FlyDSL time (µs)
FlyDSL time (µs)
FlyDSL uplift
FlyDSL TFLOPS
4096
4096
16384
1
plain
CKTile
338.3454
195.6127
+72.967%
2810.43
4096
4096
16384
1
preshuffle
CK
325.4680
191.9248
+69.581%
2864.43
4096
4096
32768
1
plain
CKTile
656.1298
372.3301
+76.223%
2953.06
4096
4096
32768
1
preshuffle
CK
620.3579
367.9619
+68.593%
2988.11
4096
8192
16384
1
plain
CKTile
511.0976
377.0924
+35.536%
2915.76
4096
8192
16384
1
preshuffle
CKTile
498.5045
372.3231
+33.890%
2953.11
4096
8192
32768
1
plain
CKTile
997.7722
727.9060
+37.074%
3021.03
4096
8192
32768
1
preshuffle
CKTile
990.7566
729.7929
+35.759%
3013.22
8192
4096
16384
1
plain
CKTile
513.7172
382.0318
+34.470%
2878.06
8192
4096
16384
1
preshuffle
CKTile
500.1461
374.9775
+33.380%
2932.21
8192
4096
32768
1
plain
CKTile
998.3685
746.9098
+33.667%
2944.16
8192
4096
32768
1
preshuffle
CKTile
981.6414
736.8643
+33.219%
2984.30
8192
8192
16384
1
plain
CKTile
999.7680
744.1012
+34.359%
2955.27
8192
8192
16384
1
preshuffle
CKTile
984.1253
734.5313
+33.980%
2993.78
8192
8192
32768
1
plain
CKTile
1995.1244
1493.1098
+33.622%
2945.56
8192
8192
32768
1
preshuffle
CKTile
1966.4486
1469.9134
+33.780%
2992.04
QKV fused projection uplift on some models:
tokens in [4096, 8192, 12288, 16394, 32768], tensor parallel [1,2,4,8]. compare with current AITER best backend gemm implementation and get average uplift for each model:
All standard extended tests (excludes ci:atom_full)
Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5969 --add-label <label>
One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.
PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.
github-actionsBot
changed the title
Luwei/a8w8 blockscale
[CK] [FlyDSL] Luwei/a8w8 blockscale
Sep 30, 2026
Missing coverage for raw-weight conversion behavior
aiter/fused_moe.py:1155
No test exercises this new raw-weight conversion path. Existing blockscale MoE tests preshuffle both weights before calling fused MoE, so they do not verify that two raw weights are converted exactly once, that already-marked weights are preserved, or that non-gfx950/non-separated routes remain unchanged.
Plain-layout path ignores guarded output buffer
op_tests/test_gemm_a8w8_blockscale_flydsl.py:92
The plain-layout branch does not pass out to the public API, so result uses a separate allocation while the later guard checks inspect untouched guarded_out. Consequently the advertised over-store check covers only the preshuffled API and cannot detect plain-kernel M/N-tail writes past the result buffer.
@solinzby1 , updated all model config. 7,252/12611 rows are switched to FLYDSL kernel. Since too many entries are switched, Also add some accuracy check to ensure no regression. For other non-model config, I want to apply tune changes after this PR merged. How do you think
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The local architecture probe bypasses the shared replay-aware runtime helper, and the new FP16 packing path lacks numerical coverage for both B layouts and mixed-dtype launcher-cache reuse.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The change bypasses shared AOT-aware architecture detection, lacks correctness coverage for the new FP16 path, and replaces CK selections with entries showing higher recorded latencies without paired validation.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The correctness test can pass despite numerical mismatches, while the FP16 paths lack correctness coverage and the local architecture probe bypasses shared runtime detection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
FP8 blockwise gemm with fp32 scale has low perf on MI355. The pain point is have to apply dequantization scale on the none-scale MXFP8 MFMA ISA on every K block accumulation . This PR introduce a new algorithm implementation on to solve this. Support both plain B layout and preshuffled B layout.
Technical Details
To squeeze hardware performance, design a new pipeline algo:
1, Based on 8 wave gemm pipeline, introduce a new pipelining algorithm to break the dequantization dependency on MFMA C. MFMA engine can run parallel with VALU, which make dequantization latency is hidden by MFMA.
2. Tensor A scales would be loaded into LDS and B scale directly to registers.
3. Tensor A scales use [BK, M] layout to access HBM with coalescing
4. This algorithm consume too much VGPRs. Split M further on the 8 wave algo to remove VGPRs spill.
5. Use padding not swizzling to avoid bank conflicts.
6. Precalculated vmem/lds offset to lower down VGPRs footprint and also achieve clean mainloop
7. Permute lane to store 4xDWORD per lane in epilog part.
8. Prevent v_pk_fma to ensure VAL is hidden by FMA ops.
tuned model config update
test covered 12,611 gfx950 shapes and switched 7,252 rows to FlyDSL kernel.
Across all 7,252 tested replacements, FlyDSL's
calc_diffis no worse than that of the replaced kernel. The diffs are identical in 7,246 cases, and FlyDSL achieves a lower diff in the remaining 6 cases.No numerical-accuracy regressions were observed under the
calc_diffmetric in these tested replacements.In 7,236 of the 7,252 replacements, both diff values are exactly equal.
In 10 more (old kernel cktile), they differ by at most 3.3e-14: 5 slightly higher, 5 slightly lower.
In the remaining 6 (old kernel asm), FlyDSL is clearly better.
Performance Test Result
HW platform : smci355-ccs-aus-m09-09, this platform TFLOPS has some perf gap with top performance 355. About 5% -10% gap with top perf MI355 machine.
Ideal shape perf lift up:
Choose some gemm perf friendly shape and compare performance with aiter optus, ck,cktile, asm backend. Some shapes can achieve 3000 TFlops.
QKV fused projection uplift on some models:
tokens in [4096, 8192, 12288, 16394, 32768], tensor parallel [1,2,4,8]. compare with current AITER best backend gemm implementation and get average uplift for each model:
MiMo-V2.5-Pro tokens= 16384 as example:
File github issue about fx.copy():
ROCm/FlyDSL#1339
Submission Checklist