Skip to content

[MoE] Tune Qwen3.5 TP2 and optimize FlyDSL intermediate quantization - #15

Merged
sammysun0711 merged 1 commit into
qwen38-flash-next-devfrom
moe35_tp2_20261130
Dec 1, 2026
Merged

sammysun0711 merged 1 commit into
qwen38-flash-next-devfrom
moe35_tp2_20261130

Conversation

@apinge

@apinge apinge commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

perf

python3 op_tests/test_moe_2stage.py \
  -q 2 -a silu -e 257 -k 9 -dim 2048,256 -p t \
  -t 1 2 4 8 16 32 64 128 256 1024 2048 4096 8192 16384 32768 \
  --no-flydsl-csv
T Before(μs) After(μs) Speedup Reduced latency
1 34.94 41.84 0.84× -19.76%
2 39.24 20.95 1.87× 46.61%
4 51.11 30.92 1.65× 39.50%
8 69.68 53.04 1.31× 23.88%
16 98.56 81.06 1.22× 17.76%
32 122.06 102.51 1.19× 16.02%
64 157.15 132.71 1.18× 15.55%
128 170.65 151.69 1.12× 11.10%
256 180.34 157.59 1.14× 12.61%
1024 291.42 266.34 1.09× 8.60%
2048 466.17 377.47 1.23× 19.03%
4096 799.55 532.43 1.50× 33.41%
8192 1404.36 1034.74 1.36× 26.32%
16384 2685.64 1684.67 1.59× 37.27%
32768 5282.98 3270.31 1.62× 38.10%

T1 single-point retest: 35.14 → 15.17 μs (2.32×).
The two after measurements fluctuated noticeably, so the table keeps the first-round results instead of the retest data.

acc

python3 op_tests/test_fused_moe_ptpc_acc.py \
  -m qwen3_5_35b_tp2 --backend flydsl

E2E model testing

launch using evaluation/launch_qwen3.5-35B-fp8_tp2_disable_prefix_cache.sh , no radix cache no mtp 8 conc 8k in 500 out

Before

#Input tokens: 1024000
#Output tokens: 64000
Starting warmup with 10 sequences...
Warmup completed with 10 sequences. Starting main benchmark run...
100%|██████████| 128/128 [01:30<00:00,  1.42it/s]

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 8         
Successful requests:                     128       
Benchmark duration (s):                  90.47     
Total input tokens:                      1024000   
Total input text tokens:                 1024000   
Total generated tokens:                  64000     
Total generated tokens (retokenized):    63946     
Request throughput (req/s):              1.41      
Input token throughput (tok/s):          11318.06  
Output token throughput (tok/s):         707.38    
Peak output token throughput (tok/s):    1056.00   
Peak concurrent requests:                16        
Total token throughput (tok/s):          12025.44  
Concurrency:                             8.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   5651.21   
Median E2E Latency (ms):                 5638.90   
P90 E2E Latency (ms):                    5752.76   
P95 E2E Latency (ms):                    5757.18   
P99 E2E Latency (ms):                    5758.13   
---------------Time to First Token----------------
Mean TTFT (ms):                          1319.67   
Median TTFT (ms):                        1250.86   
P90 TTFT (ms):                           1732.30   
P95 TTFT (ms):                           1733.35   
P99 TTFT (ms):                           1747.14   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          8.68      
Median TPOT (ms):                        8.76      
P90 TPOT (ms):                           10.44     
P95 TPOT (ms):                           10.59     
P99 TPOT (ms):                           10.75     
---------------Inter-Token Latency----------------
Mean ITL (ms):                           8.68      
Median ITL (ms):                         7.70      
P90 ITL (ms):                            7.83      
P95 ITL (ms):                            7.93      
P99 ITL (ms):                            16.00     
Max ITL (ms):                            1372.53   

After

#Input tokens: 1024000
#Output tokens: 64000
Starting warmup with 10 sequences...
Warmup completed with 10 sequences. Starting main benchmark run...
100%|██████████| 128/128 [01:22<00:00,  1.55it/s]

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 8         
Successful requests:                     128       
Benchmark duration (s):                  82.35     
Total input tokens:                      1024000   
Total input text tokens:                 1024000   
Total generated tokens:                  64000     
Total generated tokens (retokenized):    63976     
Request throughput (req/s):              1.55      
Input token throughput (tok/s):          12435.20  
Output token throughput (tok/s):         777.20    
Peak output token throughput (tok/s):    1120.00   
Peak concurrent requests:                16        
Total token throughput (tok/s):          13212.40  
Concurrency:                             7.99      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   5143.14   
Median E2E Latency (ms):                 5137.15   
P90 E2E Latency (ms):                    5200.01   
P95 E2E Latency (ms):                    5201.54   
P99 E2E Latency (ms):                    5202.07   
---------------Time to First Token----------------
Mean TTFT (ms):                          1200.72   
Median TTFT (ms):                        1144.93   
P90 TTFT (ms):                           1566.18   
P95 TTFT (ms):                           1567.50   
P99 TTFT (ms):                           1569.21   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          7.90      
Median TPOT (ms):                        7.99      
P90 TPOT (ms):                           9.56      
P95 TPOT (ms):                           9.57      
P99 TPOT (ms):                           9.67      
---------------Inter-Token Latency----------------
Mean ITL (ms):                           7.90      
Median ITL (ms):                         7.16      
P90 ITL (ms):                            7.21      
P95 ITL (ms):                            7.24      
P99 ITL (ms):                            7.61      
Max ITL (ms):                            1215.26   
==================================================

profiling

before prefill

image

after prefill

image

before decode

image

after decode

image

gsm8k

before 200

 python -m sglang.test.run_eval --eval-name gsm8k --num-examples 200 --max-tokens 16384 --port  7080
[aiter] import [module_aiter_core] under /opt/aiter/aiter/jit/module_aiter_core.so
/opt/sglang/python/sglang/test/run_eval.py:413: DeprecationWarning: sglang.test.run_eval is deprecated; its legacy scorers will be removed. Use sglang.test.sgl_eval_utils.run_sgl_eval or `sgl-eval run` instead.
  run_eval(args)
ChatCompletionSampler initialized with self.system_message=None self.temperature=0.0 self.max_tokens=16384 self.reasoning_effort=None self.extra_body=None self.stop=None self.record_meta_info=True
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 200/200 [03:08<00:00,  1.06it/s]
Total latency: 188.638 s
Score: 0.975
Output throughput: 3605.827 token/s
[METRIC] gsm8k_score=0.975 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
[METRIC] gsm8k_latency=188.63771143299527 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
====================
Speculative decoding: no per-request spec_accept_length in responses (non-speculative server, or --api completion which lacks return_meta_info).
====================
Writing report to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.html
{'score:std': np.float64(0.15612494995995996), 'score': np.float64(0.975), 'latency': 188.63771143299527, 'output_throughput': 3605.8272486072196}
Writing results to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.json

after 200

 python -m sglang.test.run_eval --eval-name gsm8k --num-examples 200 --max-tokens 16384 --port  7080
[aiter] import [module_aiter_core] under /opt/aiter/aiter/jit/module_aiter_core.so
/opt/sglang/python/sglang/test/run_eval.py:413: DeprecationWarning: sglang.test.run_eval is deprecated; its legacy scorers will be removed. Use sglang.test.sgl_eval_utils.run_sgl_eval or `sgl-eval run` instead.
  run_eval(args)
ChatCompletionSampler initialized with self.system_message=None self.temperature=0.0 self.max_tokens=16384 self.reasoning_effort=None self.extra_body=None self.stop=None self.record_meta_info=True
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 200/200 [03:13<00:00,  1.03it/s]
Total latency: 193.898 s
Score: 0.980
Output throughput: 3658.160 token/s
[METRIC] gsm8k_score=0.98 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
[METRIC] gsm8k_latency=193.8980238850054 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
====================
Speculative decoding: no per-request spec_accept_length in responses (non-speculative server, or --api completion which lacks return_meta_info).
====================
Writing report to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.html
{'score:std': np.float64(0.13999999999999999), 'score': np.float64(0.98), 'latency': 193.8980238850054, 'output_throughput': 3658.160025502213}
Writing results to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.json

after 1319

python -m sglang.test.run_eval --eval-name gsm8k --num-examples 1319 --max-tokens 16384 --port  7080
[aiter] import [module_aiter_core] under /opt/aiter/aiter/jit/module_aiter_core.so
/opt/sglang/python/sglang/test/run_eval.py:413: DeprecationWarning: sglang.test.run_eval is deprecated; its legacy scorers will be removed. Use sglang.test.sgl_eval_utils.run_sgl_eval or `sgl-eval run` instead.
  run_eval(args)
ChatCompletionSampler initialized with self.system_message=None self.temperature=0.0 self.max_tokens=16384 self.reasoning_effort=None self.extra_body=None self.stop=None self.record_meta_info=True
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1314/1314 [15:26<00:00,  1.42it/s]
Total latency: 926.971 s
Score: 0.970
Output throughput: 4923.871 token/s
[METRIC] gsm8k_score=0.969558599695586 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
[METRIC] gsm8k_latency=926.9714455450012 labels={"model": "/models/Qwen3.5-35B-A3B-PTPC-FP8/", "eval": "gsm8k"}
====================
Speculative decoding: no per-request spec_accept_length in responses (non-speculative server, or --api completion which lacks return_meta_info).
====================
Writing report to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.html
{'score:std': np.float64(0.1717984908313237), 'score': np.float64(0.969558599695586), 'latency': 926.9714455450012, 'output_throughput': 4923.871195748089}
Writing results to /tmp/gsm8k__models_Qwen3.5-35B-A3B-PTPC-FP8_.json

Quantizing the 256-channel intermediate activation launches one 256-thread
HIP block per route, although only 32 threads load and convert valid data.
Add a gfx942 FlyDSL kernel that processes four rows per 128-thread block
using independent 32-lane reductions. This reduces dispatched waves by 8x
and removes LDS storage and block barriers for the reduction.

Preserve HIP's native reciprocal, saturation and FP8 FNUZ conversion,
including zero rows and rounding-boundary cases. Limit the new path to
Qwen3.5 TP2 PTPC prefill: hidden/intermediate=2048/256, experts/topk=257/9,
BF16 activations and FP8 FNUZ weights.

Apply the previously validated CK/ASM/FlyDSL selections to 15 TP2 buckets
and update the six FlyDSL prefill timings. Keep TP1 and the T512 CK row
unchanged. Against the previous best configurations, the quantization
change reduces complete MoE GPU kernel time by 5.28%-9.75% at T1024-32768
in interleaved, same-input measurements on two MI308X GPUs.

Validation on MI308X/gfx942 with FlyDSL 0.3.2:
- Original test_moe_2stage.py command passed all 16 token sizes using the
  default merged CSV: --no-flydsl-csv -q 2 -a silu -e 257 -k 9
  -dim 2048,256 -p t
  -t 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768.
- 24 quantization cases matched HIP FP8 bytes and FP32 scales exactly.
- Fixed-input complete MoE outputs matched the previous FlyDSL path
  exactly at the six adopted prefill sizes.
- All 14 configuration collision checks passed.
@apinge
apinge marked this pull request as ready for review December 1, 2026 08:57
@apinge
apinge requested a review from sammysun0711 December 1, 2026 08:57
@sammysun0711
sammysun0711 merged commit 6f3c963 into qwen38-flash-next-dev Dec 1, 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.

2 participants