Skip to content

[draft] flydsl mxfp4 gemm2: pipeline fp4-out epilog LDS reads (lgkmcnt -68%, … - #3840

Merged
coderfeli merged 1 commit into
ROCm:dev/randomflow_prfrom
RadeonFlow:flydsl_gemm2_epilog_pipeline
Jun 22, 2026
Merged

[draft] flydsl mxfp4 gemm2: pipeline fp4-out epilog LDS reads (lgkmcnt -68%, …#3840
coderfeli merged 1 commit into
ROCm:dev/randomflow_prfrom
RadeonFlow:flydsl_gemm2_epilog_pipeline

Conversation

@benenzhu

@benenzhu benenzhu commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

gemm2 846->778us @ M=16384)

3% e2e for fp4-out path.
eleminate the back2back stall of 2xds_read & lgkmcnt(1) issue.
image

@benenzhu
benenzhu marked this pull request as draft June 22, 2026 06:38
@coderfeli
coderfeli marked this pull request as ready for review June 22, 2026 06:48
@coderfeli
coderfeli merged commit e90d47f into ROCm:dev/randomflow_pr Jun 22, 2026
ColorsWind pushed a commit to RadeonFlow/up-aiter that referenced this pull request Jun 22, 2026
…3861 conflicts)

Base (dev/randomflow_pr) rewrote fused_moe.py (~1340 lines); this branch's
only fused_moe.py change is the "gate gemm2 mxfp4-out solely on
AITER_MXFP4_INTERMEDIATE" commit. Resolution:

- aiter/fused_moe.py: take base's rewritten structure, re-apply the single
  semantic change -- drop the `mxfp4out and` term from the mxfp4-out gate in
  _mxfp4_a4w4_stage2 so it gates on AITER_MXFP4_INTERMEDIATE=="1" alone.
- aiter/ops/flydsl/kernels/mxfp4_gemm2.py: keep this branch's abs-fold epilog
  (llvm.fabs.f32 + maxnumf amax); drop base's now-dead `i7fff` integer-mask
  declaration. The ROCm#3840 LDS pipelining is identical on both sides.
@fsx950223

fsx950223 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Performance regression between e90d47f and 46ecc44,
image
git history:
e90d47f (origin/dev/randomflow_pr) flydsl mxfp4 gemm2: pipeline fp4-out epilog LDS reads (lgkmcnt -68%, gemm2 846->778us @ M=16384) (#3840)
05567f6 [RadeonFlow] Integrate HIP Sort/Quant in MoE Pipeline (#3827)
b242ba6 [RadeonFlow] flydsl mxfp4 a4w4 MoE: bring gemm1/gemm2 to parity with the HIP backend (#3828)
46ecc44 Port flydsl a4w4 MoE onto randomflow_pr (coexist with HIP #3470) (#3788)
benchmark script:bench_up_moe_v2.py
git branch: flydsl-gemm1-py-compare-ops

@fsx950223

Copy link
Copy Markdown
Contributor

Original performance:

model (NE/H/INTER/TOPK) M=4 M=8 M=16 M=32 M=64 M=128 M=256 min cos
kimi_k2.5 (385/7168/512/9) 41.7 61.2 98.1 148.5 201.7 252.9 303.2 1.0000
dsv3_a (32/7168/2048/8) 89.0 103.2 122.1 144.6 156.0 186.6 343.0 0.9443
dsv3_b (257/7168/512/9) 43.7 58.6 92.9 120.1 173.0 203.3 261.7 1.0000
dsv3_c (257/7168/256/9) 34.6 38.8 48.2 65.9 95.3 107.0 150.3 1.0000
kimik2_a (384/7168/512/8) 45.1 53.5 93.4 140.9 184.0 230.6 323.6 1.0000
kimik2_b (385/7168/256/9) 35.2 44.9 52.9 88.6 108.6 145.5 171.2 1.0000
minimax_a (256/3072/1536/8) 45.4 69.3 96.4 142.1 201.0 240.6 333.3 0.9790
minimax_b (256/3072/768/8) 26.0 43.0 53.1 73.6 100.1 125.6 169.9 1.0000
qwen35_397b (512/4096/256/10) 25.3 30.3 45.4 61.2 77.3 100.7 133.6 1.0000
dsv4_ep8 (48/7168/3072/6) 107.1 160.1 219.3 269.4 279.0 297.3 505.4 0.9556
dsv4_tp2 (384/7168/1536/6) 67.1 113.6 216.8 306.2 459.2 573.6 796.7 0.9812
dsv4_tp4 (384/7168/768/6) 44.8 61.0 102.2 154.8 235.7 307.5 412.9 1.0000
dsv4_tp6 (384/7168/512/6) 37.6 46.3 84.0 105.8 155.1 205.2 279.7 1.0000
dsv4_tp8 (384/7168/384→512/6) 36.2 42.1 80.3 97.4 144.2 197.5 262.8 1.0000
dsv4_lite (256/4096/256/6) 20.7 22.6 26.8 38.7 55.7 61.6 76.1 1.0000

@ftyghome

Copy link
Copy Markdown
Contributor

Hi @fsx950223 ,

The regression seems to be caused by our recent code refactor. The latest code in randomflow_pr branch should align with the previous flydsl performance (though not 100% sure).

Here is the result in randomflow_pr branch, the test script is bench.py.

Test Results

model (NE/H/INTER/TOPK) backend M=4 M=8 M=16 M=32 M=64 M=128 M=256 M=512 M=1024 M=2048 finite
kimi_k2.5 (385/7168/512/9) a4w4-port 41.3 60.7 97.7 148.7 201.0 252.4 306.6 386.5 480.3 630.0
dsv3_a (32/7168/2048/8) a4w4-port 91.1 103.0 125.6 145.7 164.5 239.0 274.9 423.1 538.2 924.8
dsv3_b (257/7168/512/9) a4w4-port 44.0 56.5 96.0 118.4 161.0 206.9 240.0 302.7 378.1 534.5
dsv3_c (257/7168/256/9) a4w4-port 33.4 43.0 51.0 66.7 98.1 111.8 144.2 197.7 265.1 415.5
kimik2_a (384/7168/512/8) a4w4-port 39.0 55.2 92.6 140.2 177.5 234.7 303.6 363.9 468.3 592.2
kimik2_b (385/7168/256/9) a4w4-port 34.3 39.9 52.5 90.1 107.7 146.8 184.0 233.4 302.2 465.7
minimax_a (256/3072/1536/8) a4w4-port 44.7 69.9 96.0 140.6 190.9 238.3 304.0 364.6 421.8 533.8
minimax_b (256/3072/768/8) a4w4-port 25.5 41.9 52.7 76.5 103.6 128.4 169.6 203.7 245.0 340.7
qwen35_397b (512/4096/256/10) a4w4-port 24.9 29.7 42.6 60.4 79.4 103.7 155.5 176.9 223.0 331.2
dsv4_ep8 (48/7168/3072/6) a4w4-port 109.1 165.8 207.3 236.6 277.6 358.0 408.8 575.1 688.1 1113.3
dsv4_tp2 (384/7168/1536/6) a4w4-port 66.0 111.4 197.7 301.5 419.9 571.9 723.7 897.7 1148.5 1424.2
dsv4_tp4 (384/7168/768/6) a4w4-port 45.0 60.1 102.6 154.8 216.5 304.0 388.0 464.8 612.9 787.0
dsv4_tp6 (384/7168/512/6) a4w4-port 35.9 46.6 85.8 107.0 151.9 204.6 279.1 336.6 438.4 544.6
dsv4_tp8 (384/7168/384/6) default/ck 34.6 44.1 81.9 102.3 144.8 195.1 261.7 315.6 404.7 518.3
dsv4_lite (256/4096/256/6) a4w4-port 20.8 23.8 27.1 34.9 57.1 63.3 92.5 118.1 138.2 200.8

@fsx950223

Copy link
Copy Markdown
Contributor

dsv4_tp8 should use a4w4-port too

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.

4 participants