Skip to content

[MoE] Support Qwen3.5-122B TP8 and Qwen3.5-35B TP4 - #3400

Merged
yixionghuo merged 3 commits into
ROCm:Qwen3.5_devfrom
apinge:qwen3_5_122b_tp8_35b_tp4
May 29, 2026
Merged

yixionghuo merged 3 commits into
ROCm:Qwen3.5_devfrom
apinge:qwen3_5_122b_tp8_35b_tp4

Conversation

@apinge

@apinge apinge commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Following the approach in PR #3309 , this PR optimizes prefill and decoding
for Qwen3.5-122B (PTPC FP8 MoE, TP8) and Qwen3.5-35B (PTPC FP8 MoE, TP4).

Technical Details

  1. co source code pyhip moe_prefill_fp8_308 branch commit tingqli/pyhip@65a0262, test code in test_moe.py
    steps for gen co and tune configs
  2. generate co and csv
# clone code and install pyhip
git clone https://github.com/tingqli/pyhip/ -b moe_prefill_fp8_308
cd pyhip && pip install -e .
# update test according to the case see pyhip test example below
...

# run pyhip and generate co
rm ~/.pyhip/ -rf
cd pyhip/tests/contrib/moe
PYHIP_SIMPLE_GEN_FILENAME=1 python3 test_moe.py
cp ~/.pyhip/*.co aiter/hsa/gfx942/fmoe_asmjit/

# tune
python3 csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py -i aiter/configs/model_configs/qwen3_5_122b_fp8_ptpc_untuned_fmoe.csv -o aiter/configs/model_configs/qwen3_5_122b_fp8_ptpc_tuned_fmoe.csv --timeout 300 -v --all --e2e_tune

python3 csrc/ck_gemm_moe_2stages_codegen/gemm_moe_tune.py -i aiter/configs/model_configs/qwen3_5_35b_fp8_ptpc_untuned_fmoe.csv -o aiter/configs/model_configs/qwen3_5_35b_fp8_ptpc_tuned_fmoe.csv --timeout 300 -v --all --e2e_tune
 
  1. If you direct test the cases with pyhip, please use the following code
       # 122B
        HIDDEN_SIZE, INTER_SIZE_TP, E, TOPK = 3072, 1024//8, 257, 9

        # 35B
        #HIDDEN_SIZE, INTER_SIZE_TP, E, TOPK = 2048, 512//4, 257, 9

        for prec in [prec_fp8_ptpc]:
            # TILE_M, TILE_N = 16, 64
            batch = [2, 4, 8, 16, 32]
     
            test_dec = TestCase(TILE_M, TILE_N, HIDDEN_SIZE, INTER_SIZE_TP, E, TOPK)
            test_dec.entry_common('aiter', [1] + batch, prec=[prec])
            test_dec.entry_common('16x32_2s_b1', [1], prec=[prec])
            test_dec.entry_common('16x32_2s_b', batch, prec=[prec])

            test_dec.show_perf(f'qwen dec {TILE_M=} {TILE_N=}')

            for DYN in [False,True]:
                GATE_TILE_N, DOWN_TILE_N = 128, 128
                if DYN:
                    GATE_TILE_N = 256
                for TILE_M in [64, 128]:
                    batch = [8192, 16384, 32768, 65536, 131072]
                    #batch = [ 8192]
                    test_prefill = TestCase(TILE_M, GATE_TILE_N, HIDDEN_SIZE, INTER_SIZE_TP, E, TOPK, DYN_SCHEDULE=DYN, STAGE2_TILE_N=DOWN_TILE_N)
                    test_prefill.entry_common('aiter', batch, prec=[prec])
                    test_prefill.entry_common('mxn_2s', batch, prec=[prec])
                    test_dec.show_perf(f'qwen dec {TILE_M=} {DYN=}')
                    test_prefill.show_perf(f'qwen prefill {TILE_M=} {DYN=}')
  1. Accuracy tests were added for qwen3.5 35B (TP4), qwen3.5 122B (TP8), qwen3.5 397B (TP8). Test method aligned with pyhip repo.

Test Plan

qwen3.5 122B TP8

python3 op_tests/test_moe_2stage.py -q 2 -a silu -e 257 -k 9 -dim 3072,128 -p t   -t  1 2 4 8 16 32 8192 16384 32768 65536 131072
dtype token model_dim inter_dim E topk actType qType AQDType WQDType use_g1u1 doweight_stage1 hidden_pad intermediate_pad preshuffle us err
torch.bfloat16 1 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 16.437 0.844076
torch.bfloat16 2 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 25.4672 0.851074
torch.bfloat16 4 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 34.0372 0.857585
torch.bfloat16 8 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 45.8772 0.86084
torch.bfloat16 16 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 68.186 0.857076
torch.bfloat16 32 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 83.855 0.857524
torch.bfloat16 8192 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 1119.91 0.122796
torch.bfloat16 16384 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 2063.91 0.121863
torch.bfloat16 32768 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 4026.6 0.122913
torch.bfloat16 65536 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 7985.57 0.121626
torch.bfloat16 131072 3072 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 16177.2 0.121776

qwen35B TP4

python3 op_tests/test_moe_2stage.py -q 2 -a silu -e 257 -k 9 -dim 2048,128 -p t   -t  1 2 4 8 16 32 8192 16384 32768 65536 131072
dtype token model_dim inter_dim E topk actType qType AQDType WQDType use_g1u1 doweight_stage1 hidden_pad intermediate_pad preshuffle us err
torch.bfloat16 1 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 14.3873 0.85498
torch.bfloat16 2 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 23.2172 0.844971
torch.bfloat16 4 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 28.317 0.868774
torch.bfloat16 8 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 38.417 0.854248
torch.bfloat16 16 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 53.6662 0.864838
torch.bfloat16 32 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 65.6453 0.858124
torch.bfloat16 8192 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 777.282 0.119903
torch.bfloat16 16384 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 1416.93 0.120795
torch.bfloat16 32768 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 2724.45 0.122246
torch.bfloat16 65536 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 5378.93 0.121433
torch.bfloat16 131072 2048 128 257 9 0 2 torch.float8_e4m3fnuz torch.float8_e4m3fnuz True False 0 0 False 10857 0.121593

acc test

python3 /opt/aiter/op_tests/test_fused_moe_ptpc_acc.py

All tests passed.

Test Result

Submission Checklist

Co-authored-by: Cheng Luo [email protected]
Co-authored-by: Tingqian Li [email protected]

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.

2 participants