[AMD] WIP - Clamp disagg max_total_num_tokens to MORI's single-MR size limit - #30336
[AMD] WIP - Clamp disagg max_total_num_tokens to MORI's single-MR size limit#30336yctseng0211 wants to merge 8 commits into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Triggered a MI355X disagg Configs under test (all 8 flash variants, fp8/fp4 × base/mtp/dp8ep8): Will update once it completes. |
|
Re-triggered the MI355X disagg
Same 8 |
|
Rebased/merged latest
Same 8 |
|
Fixed a
Same 8 |
6ef68f9 to
9df498e
Compare
|
Rebased the branch onto
Same 8 |
9df498e to
dbf009a
Compare
|
Re-based onto the exact sglang commit baked into the MI355X CI image (
Same 8 |
…rrno=22 on MI355X)
|
Prior aligned run gave direct evidence that the MI355X RDMA single-MR ceiling is below 4 GiB: after the clamp reduced the region to
|
… test triton-decode-on-transferred-KV
|
Side investigation on this branch (separate from the clamp): the Findings so far:
Experiment now running: kimik26 non-MTP with If accuracy returns to ~0.94, the fix is to use aiter decode for Kimi disagg (matching the backend MTP verify already uses). |
|
closed as #30313 being merged. |

Motivation
The
Nightly Test (AMD MI355X 2N 1P1D Disagg)has been failing forDeepSeek-V4-Flash since the 2026-07-02 scheduled run
(https://github.com/sgl-project/sglang/actions/runs/28565894749); the last
green scheduled run was 2026-07-01
(https://github.com/sgl-project/sglang/actions/runs/28494350421). Every
dsv4flashjob (fp8/fp4, base/mtp/dp8ep8) fails while everydsv4projobstays green.
Root cause (as investigated in 30313): DSV4-Flash disagg auto-sizing raises
max_total_num_tokensfrom the 07-01 value8,551,168to23,448,064. Each per-layer unified C4 KV buffer is 256 bytes/token, so the largest single KV region grows from ~2.19 GB to ~6.0 GB. MORI registers each KV buffer as one RDMA memory region, andRegisterRdmaMemoryRegionfails witherrno=22 (EINVAL)once a single region crosses the ~4 GiB (2**32) single-MR ceiling.The PD path then never serves (disagg warmup returns near-all-zero
output_ids;/generate-> 500 -> router 502 ->PD path not serving; aborting), and the GSM8K gate reports no accuracy. 30313 mitigates this by hardcodingmax_total_tokens: 8551168in the MTP recipe.This PR replaces that recipe-scoped magic number with a general, limit-aware clamp, so all DSV4 disagg recipes — and real deployments, not just CI — are protected without a per-recipe constant.
Modifications
environ.py: addSGLANG_MORI_MAX_MR_BYTES(default4 GiB = 2**32,<= 0disables) — the max byte size of a single MORI-registered KV region.pool_configurator.py: addlargest_registered_kv_region_bytes_per_token().The base returns
0(no known bound, so callers skip clamping).DSV4PoolConfiguratorreturns(qk_nope_head_dim + qk_rope_head_dim) * 2 / min(compress_ratios), which isexactly the per-token size of the largest registered region (a C4 layer)
under the unified bf16 layout and an upper bound for the packed-FP8 layout.
It reads the same
model_configdims the pool uses to allocate the buffers,so it cannot drift from
get_contiguous_buf_infos.model_runner_kv_cache_mixin.py: in_resolve_memory_pool_config, after theexisting user-cap / PP constraints,
_apply_mori_mr_limit()clampsmax_total_num_tokensso the largest region stays strictly below the limit(minus one page to absorb
get_contiguous_buf_infospage rounding). No-opunless
disaggregation_mode != "null"anddisaggregation_transfer_backend == "mori"; other backends and models areunchanged.
With the 4 GiB default and DSV4-Flash (
(448+64)*2/4 = 256bytes/token) thecap is ~16.78M tokens — above the
8,551,168that was green on 07-01 and belowthe
23,448,064that failed on 07-02. If a NIC/driver caps MRs smaller, lowerSGLANG_MORI_MAX_MR_BYTES(no code change).Speed Tests and Profiling
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #28857410081
Latest PR Test (Extra): ❌ Run #28857409874