Skip to content

Add option to disable rmsnorm ca fusion - #21

Merged
apinge merged 9 commits into
apinge:qwen3_5_v0.5.15_dflashfrom
sammysun0711:add_disable_rmsnorm_allreduce_option
Aug 19, 2026
Merged

apinge merged 9 commits into
apinge:qwen3_5_v0.5.15_dflashfrom
sammysun0711:add_disable_rmsnorm_allreduce_option

Conversation

@sammysun0711

@sammysun0711 sammysun0711 commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

This PR restores the intended custom all-reduce behavior while keeping --disable-custom-all-reduce as nccl fallback
path.

After this change:

  • 35B custom-reduce mode is aligned with 397B:
    • prefill QR / AITER custom all-reduce
    • decode fused AR + RMSNorm with old custom all-reduce
  • 27B with --disable-custom-all-reduce fall back to nccl
  • Fused AR + RMSNorm is guarded to run only when the target group is equivalent to regular TP (no EP DP).

After this modification, 35B command line as (Note that export AITER_QUICK_REDUCE_QUANTIZATION=INT6 for prefill QR )

export SGLANG_DISABLE_CUDNN_CHECK=1
export SGLANG_USE_CUDA_IPC_TRANSPORT=1
export SGLANG_VLM_CACHE_SIZE_MB=8192 # or 0
export SGLANG_USE_AITER=1
export SGLANG_ROCM_USE_AITER_LINEAR_SHUFFLE=1 # internal branch
export SGLANG_ROCM_USE_AITER_LINEAR_FP8HIPB=1
export USE_AITER_COMM=1

export AITER_QUICK_REDUCE_QUANTIZATION=INT6
export SGLANG_USE_AITER_NEW_CA=false
export SGLANG_USE_IPC_POOL_HANDLE_CACHE=1

export HIP_GDN_SORT_IDX_BS=32768

export TVM_FFI_DISABLE_TORCH_C_DLPACK=1 # pip uninstall torch-c-dlpack-ext

model=/models/Qwen/Qwen3.5-35B-A3B-PTPC-FP8


python3 -m sglang.launch_server \
 --port 7080 \
 --model-path ${model} \
 --tp-size 4 \
 --reasoning-parser qwen3 \
 --tool-call-parser qwen3_coder \
 --enable-multimodal \
 --trust-remote-code \
 --chunked-prefill-size 32768 \
 --mem-fraction-static 0.9 \
 --max-prefill-tokens 32768 \
 --max-running-requests 128 \
 --attention-backend aiter \
 --mm-attention-backend aiter_attn \
 --kv-cache-dtype fp8_e4m3 \
 --linear-attn-backend aiter \
 --linear-attn-decode-backend aiter \
 --linear-attn-prefill-backend aiter \
 --disable-radix-cache  2>&1 | tee qwen3.5-35B-fp8_tp4_origin.log

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

@apinge
apinge requested a lite review from Copilot August 18, 2026 07:16
@apinge
apinge marked this pull request as ready for review August 18, 2026 07:18
@apinge
apinge self-requested a review August 18, 2026 07:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the normalization + all-reduce fusion plumbing so AITER fused AR+RMSNorm is only attempted when custom all-reduce is enabled, aligning “fused norm” behavior with the global custom-AR enable/disable switch.

Changes:

  • Gate AITER fused AR+RMSNorm behind is_custom_all_reduce_enabled() in both layernorm fusion and communicator fusion checks.
  • Refine all-reduce fallback behavior in layernorm.py to use the correct TP group (attention vs MoE) when fusion isn’t taken.
  • Tighten custom-allreduce routing in parallel_state.py (including adding is_custom_all_reduce_enabled() and preventing fused AR+RMSNorm calls when custom AR is disabled).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
python/sglang/srt/layers/layernorm.py Adds custom-AR gating for AITER fused norm and adjusts fallback all-reduce path selection.
python/sglang/srt/layers/communicator.py Centralizes the AITER fused AR+RMSNorm enable check and reuses it in fusion decision points.
python/sglang/srt/distributed/parallel_state.py Adds a global “custom AR enabled” query and ensures custom/fused all-reduce paths are skipped when disabled.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/sglang/srt/layers/layernorm.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

python/sglang/srt/layers/layernorm.py:203

  • --enable-aiter-allreduce-fusion still exists in server_args.py, but after this change it no longer gates the AITER fused AR+RMSNorm path anywhere (repo-wide grep shows only server_args.py references). This makes the CLI flag effectively a no-op and can confuse users. Either remove/deprecate the flag (and its validation) or reintroduce it as a gate for attempting the AITER fused AR+RMSNorm path.
            if (
                fused_ar_uses_tp_group
                and _AITER_FUSED_NORM_DEFAULT
                and is_custom_all_reduce_enabled()
                and x.numel() > 0
            ):

python/sglang/srt/layers/communicator.py:182

  • _is_aiter_fused_ar_rmsnorm_enabled() currently ignores get_global_server_args().enable_aiter_allreduce_fusion. Since that CLI option still exists, incorporating it here would make the AITER fused AR+RMSNorm gating consistent across this file and avoid the flag becoming a no-op.
def _is_aiter_fused_ar_rmsnorm_enabled() -> bool:
    return _AITER_FUSED_AR_RMSNORM_DEFAULT and is_custom_all_reduce_enabled()

Comment thread python/sglang/srt/layers/layernorm.py Resolved
@apinge

apinge commented Aug 19, 2026

Copy link
Copy Markdown
Owner

The last CI run shows worse performance. Even after bumping --warmup-requests 8, we still seem to be hitting kernel cold-start overhead, likely from autotune pre-compilation.
I did a local experiment on the base branch and the PR branch, and it looks like rerunning the benchmark a second time can avoid this issue.

PR cold raw benchmark

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 1         
Successful requests:                     32        
Benchmark duration (s):                  126.46    
Total input tokens:                      256000    
Total input text tokens:                 256000    
Total generated tokens:                  16000     
Total generated tokens (retokenized):    15955     
Request throughput (req/s):              0.25      
Input token throughput (tok/s):          2024.29   
Output token throughput (tok/s):         126.52    
Peak output token throughput (tok/s):    164.00    
Peak concurrent requests:                2         
Total token throughput (tok/s):          2150.81   
Concurrency:                             1.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   3951.08   
Median E2E Latency (ms):                 3336.35   
P90 E2E Latency (ms):                    4817.60   
P95 E2E Latency (ms):                    8357.57   
P99 E2E Latency (ms):                    10034.25  
---------------Time to First Token----------------
Mean TTFT (ms):                          693.47    
Median TTFT (ms):                        280.48    
P90 TTFT (ms):                           535.08    
P95 TTFT (ms):                           2930.63   
P99 TTFT (ms):                           6241.18   
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          6.53      
Median TPOT (ms):                        6.12      
P90 TPOT (ms):                           6.15      
P95 TPOT (ms):                           6.29      
P99 TPOT (ms):                           14.98     
---------------Inter-Token Latency----------------
Mean ITL (ms):                           6.53      
Median ITL (ms):                         6.12      
P90 ITL (ms):                            6.14      
P95 ITL (ms):                            6.15      
P99 ITL (ms):                            6.24      
Max ITL (ms):                            6098.69   
==================================================

PR warm raw benchmark

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 1         
Successful requests:                     32        
Benchmark duration (s):                  108.50    
Total input tokens:                      256000    
Total input text tokens:                 256000    
Total generated tokens:                  16000     
Total generated tokens (retokenized):    15951     
Request throughput (req/s):              0.29      
Input token throughput (tok/s):          2359.44   
Output token throughput (tok/s):         147.47    
Peak output token throughput (tok/s):    163.00    
Peak concurrent requests:                2         
Total token throughput (tok/s):          2506.91   
Concurrency:                             1.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   3389.74   
Median E2E Latency (ms):                 3389.61   
P90 E2E Latency (ms):                    3401.11   
P95 E2E Latency (ms):                    3404.41   
P99 E2E Latency (ms):                    3415.93   
---------------Time to First Token----------------
Mean TTFT (ms):                          281.20    
Median TTFT (ms):                        281.05    
P90 TTFT (ms):                           286.54    
P95 TTFT (ms):                           291.20    
P99 TTFT (ms):                           295.38    
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          6.23      
Median TPOT (ms):                        6.23      
P90 TPOT (ms):                           6.25      
P95 TPOT (ms):                           6.26      
P99 TPOT (ms):                           6.28      
---------------Inter-Token Latency----------------
Mean ITL (ms):                           6.23      
Median ITL (ms):                         6.17      
P90 ITL (ms):                            6.19      
P95 ITL (ms):                            6.21      
P99 ITL (ms):                            7.60      
Max ITL (ms):                            26.63     
==================================================

Base raw benchmark (with warm)

============ Serving Benchmark Result ============
Backend:                                 sglang    
Traffic request rate:                    inf       
Max request concurrency:                 1         
Successful requests:                     32        
Benchmark duration (s):                  107.12    
Total input tokens:                      256000    
Total input text tokens:                 256000    
Total generated tokens:                  16000     
Total generated tokens (retokenized):    15973     
Request throughput (req/s):              0.30      
Input token throughput (tok/s):          2389.95   
Output token throughput (tok/s):         149.37    
Peak output token throughput (tok/s):    163.00    
Peak concurrent requests:                2         
Total token throughput (tok/s):          2539.32   
Concurrency:                             1.00      
----------------End-to-End Latency----------------
Mean E2E Latency (ms):                   3346.37   
Median E2E Latency (ms):                 3347.35   
P90 E2E Latency (ms):                    3350.77   
P95 E2E Latency (ms):                    3351.64   
P99 E2E Latency (ms):                    3355.69   
---------------Time to First Token----------------
Mean TTFT (ms):                          281.64    
Median TTFT (ms):                        281.85    
P90 TTFT (ms):                           286.39    
P95 TTFT (ms):                           287.59    
P99 TTFT (ms):                           292.39    
-----Time per Output Token (excl. 1st token)------
Mean TPOT (ms):                          6.14      
Median TPOT (ms):                        6.14      
P90 TPOT (ms):                           6.14      
P95 TPOT (ms):                           6.14      
P99 TPOT (ms):                           6.14      
---------------Inter-Token Latency----------------
Mean ITL (ms):                           6.14      
Median ITL (ms):                         6.14      
P90 ITL (ms):                            6.16      
P95 ITL (ms):                            6.17      
P99 ITL (ms):                            6.27      
Max ITL (ms):                            10.63     
==================================================

@apinge
apinge merged commit 1b8ae99 into apinge:qwen3_5_v0.5.15_dflash Aug 19, 2026
5 checks passed
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