[AMD] move shared expert check function to quark - #27057
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to determine if shared expert fusion can be performed, specifically adding a can_fuse_shared_expert check in the Quark quantization configuration and integrating it into Qwen MoE and Qwen 3.5 models. It also adds automatic disabling of shared expert fusion in Qwen 3.5 if it is not supported. The review feedback highlights a potential issue where replacing the original exclude_layers check in qwen2_moe.py with the new can_fuse_shared_expert method call will bypass the safety check for other quantization configurations that do not implement this new method, and suggests adding a fallback to the original check.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/tag-and-rerun-ci |
|
@amd-bot ci-status |
CI Status for PR #27057Merge verdict: All 5 real failures are unrelated to this PR — they are pre-existing/infra issues on AMD-allreduce, RDMA disaggregation, NPU perf, XPU, and CPU-benchmark paths, none of which touch Quark shared-expert fusion. However, this PR's actual new code is NOT exercised by any PR-CI test that ran — green CI does not verify the change. Functionally safe to merge from a "did I break CI" standpoint, but the behavior itself is unverified by PR CI. Caution This PR's core new logic — Changed files: AMD: 2 failures (0 related) · Others: 3 failures (0 related) AMD CI Failures
Other CI Failures
Details / what to do before merge
Generated by amd-bot using Claude Code CLI |
Motivation
For shared expert fusion feature, precise checks are added. This is aimed for a more general use for all models.
Modifications
There are two purposes behind this PR:
1. Add precise checks for shared expert fusion feasibility
So far most MXFP4 models have shared experts unquantized, so shared expert fusion cannot be applied. We add two checks for this:
excludelist of the quantization config, do any of the shared expert layers appear?_find_matched_configanddeep_compare. The config contains quantization information for each layer. Note that if the model doesn't give each layer a specific config (e.g. Qwen3.5), there will be no difference and we still rely on check (a). So this check is for general use.We also move the check function
can_fuse_shared_expertfrom the model code toquark.py, because it's more like quantization code and calls into some quantization-related utility functions.2. Enable #25885 multi-streaming even without
disable_shared_experts_fusion#25885 can improve performance by multi-streaming the transformer flow. The problem is that #25885 uses the server arg
disable_shared_experts_fusion, but if the model is not run withdisable_shared_experts_fusion, shared expert fusion is treated as "enabled". So even when the model is not run with the flag, this PR uses the check functioncan_fuse_shared_expertto ensure that shared expert fusion is disabled. Therefore, #25885 can still benefit the model from multi-streaming.Accuracy Tests
No impact because it just enables or disables a performance feature.
Speed Tests and Profiling
1. Serve
GPU_MAX_HW_QUEUES=5 \ SGLANG_USE_AITER=1 SGLANG_USE_AITER_UNIFIED_ATTN=1 \ SGLANG_ALT_STREAM=1 SGLANG_GDN_QKVZ_BA_ALT_STREAM=1 SGLANG_QK_NORM_ALT_STREAM=0 \ AITER_CONFIG_GEMM_BF16=/sgl-workspace/aiter/aiter/configs/qwen_bf16_tuned_gemm.csv \ python3 -m sglang.launch_server \ --model-path /data/amd/Qwen3.5-397B-A17B-MXFP4/ --trust-remote-code \ --model-loader-extra-config '{"enable_multithread_load": true}' \ --host 0.0.0.0 --port 8888 --tensor-parallel-size 2 \ --attention-backend aiter --kv-cache-dtype fp8_e4m3 --page-size 16 \ --chunked-prefill-size 8192 --mem-fraction-static 0.8 --watchdog-timeout 1200 \ --disable-radix-cache \ --enable-aiter-allreduce-fusionNotes:
ROCM_QUICK_REDUCE_QUANTIZATIONis left unset.2. Serving (benchmark)
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ✅ Run #27400593453
Latest PR Test (Extra): ❌ Run #27400593176