Repository navigation
[Fix] [NVIDIA] allreduce: Stage VMM graph inputs in CustomAllreduce instead of IPC-registering them - #44448
[Fix] [NVIDIA] allreduce: Stage VMM graph inputs in CustomAllreduce instead of IPC-registering them#44448adi-suresh01 wants to merge 4 commits into
Conversation
|
@ch-wan this is the custom all-reduce half of #44291: with |
…/deferred/avoid map - 3A [24-35]: NVFP4 MoE boot sgl-project#39807/sgl-project#40173, block-FP8 TP refine sgl-project#42566, k-pool indexer split sgl-project#43619, SM120 skinny GEMM sgl-project#42865/sgl-project#42867, DeepGEMM warmup guards sgl-project#32686/sgl-project#43712, autotune sgl-project#43363/sgl-project#40420, mHC overlap sgl-project#42985, FP8-einsum precompile sgl-project#42821. - 3B [36-43]: PCIe CustomAllreduce VMM sgl-project#44448, EP local expert ids sgl-project#44480, shm TP broadcast sgl-project#44202, PCIe-IPC all-gather sgl-project#42863 + multicast guard sgl-project#41888, TP-sampling consistency sgl-project#41916/sgl-project#38565, draft embed/lm_head VRAM sgl-project#37155. - sgl-project#39807 toolchain commit verified safe against our CUDA_HOME=12.9 pin (cu13 fallback needs CUDA_HOME unset AND glibc>=2.41; we are 2.39). - stack_want.txt: execution-status banner. Branch tip 5dd6ec7.
…rt, DeepGEMM warmup recipe key, MoE disagg bag) Individually-passing PRs collided when merged on deepseek-41-flash-1017-stack: - sgl-project#44448: test_custom_all_reduce_v1_vmm.py imported register_comm_cleanup from sglang.kernels.ops.communication.mp (does not exist); the real home is sglang.srt.distributed.comm_cleanup. Fixing the import unblocked collection. Also added the repo-idiomatic module-level skipif(not torch.cuda.is_available()) so the torchrun-only GPU tests skip cleanly when pytest is invoked directly without GPUs. - sgl-project#43712: _INITIALIZATION_DICT is keyed by the 5-tuple (kernel_type, n, k, num_groups, recipe) (compile_utils.py:163); the blockwise FP8 gemm_nt_f8f8bf16 path calls the hook without a recipe, so test_warmup_state now builds 5-tuple keys with recipe=None, matching the implementation exactly. - sgl-project#39807: the flashinfer_cutlass fp4 fallback calls _cutlass_moe_tune_max_num_tokens -> get_disagg(); the sm120 nvfp4 placement test called _run_flashinfer_cutlass outside any publish scope, so 'config namespace disagg not published'. Publish the bags with the file's existing idiom, get_context().override_server_args(model_path= "dummy"), the same way test_flashinfer_cutlass_swiglu_params.py exercises the disagg bag. CPU verification (CUDA_VISIBLE_DEVICES=9): 13 passed, 9 skipped (GPU-only VMM subtests), 0 failed.
…s in CustomAllreduce instead of IPC-registering them cudaIpcGetMemHandle accepts only cudaMalloc memory; a CUDA-graph input that lives in cuMemCreate memory (expandable_segments, the memory saver, symmetric-memory pools) made v1's register_graph_buffers path die with RuntimeError: invalid argument during capture. Decide registration per input at capture time and stage VMM inputs through the pre-registered IPC buffer instead. Fork union with entry 75 (a89d298): is_vmm_pointer is added to the existing cuda_vmm_utils import line, and the shipped test skips (rather than raises) when v1 is init-disabled by the fork's VMM-allocator guard -- upstream's raise would make the test dead-on-arrival on this tree. The capture-time staging keeps the fork byte-aligned with upstream for the residual reachable case (VMM inputs despite a non-VMM init probe). (cherry picked from commit ad19c6a) (cherry picked from commit 044ac078bed291e2bc1d14c2d96c11ddbcfefad2)
…(entries 255-256) Batch 1 of the 2026-10-28 second wave. Two open-PR ports landed clean (zero conflicts) onto 56f97a7 -- code tip 0df18e9: a13e98b sgl-project#44448 (VMM graph-input staging in CustomAllreduce v1, defense-in-depth behind the entry-75 init refusal) and 0df18e9 sgl-project#39605 (host-staged + LL TP2 all-reduce transports, both opt-in, LL/PCIe-IPC COLLISION documented at the dispatch site). FAM-A6a marked LANDED in wanted_stack.txt; sgl-project#44342's parallel_state.py hold explicitly RELEASED for its later FAM-A3b wave. Verified at the landed tip (prod venv, CVD=9): comm named set 114P/1S/30sub (exact worker match), whole unit/distributed dir 120P/1S/35sub 0F, the three new test files collect 18 (9 registered multi-GPU + 9 test/manual). NOTHING PUSHED.
…n cleanup) no upstream PR; fork debt from entry 256. Entry 256 ported sgl-project#39605 keeping upstream's raw os.environ.get sites -- deliberate at port time ("PR as-is, not normalized"), but the fork's own sgl-project#44448-era convention is environ.py registration, and the flagged consequence is real: an environ-only grep of the tree missed all three of these switches. This closes the deviation for the three named gates. SGLANG_ENABLE_PCIE_IPC_- ALLREDUCE is already registered (environ.py, "Deterministic inference and all-reduce"), which is why the LLGUARD guard could read PCIe-IPC's state via envs through eligible_group. Registered (append-only, next to the PCIe-IPC pair): SGLANG_LL_ALLREDUCE = EnvBool(False) SGLANG_LL_ALLREDUCE_MAX_BYTES = EnvInt(64 << 10) -- verified against the raw fallback str(64 << 10) in ll_allreduce.py: identical 65536. SGLANG_HOST_STAGED_ALLREDUCE = EnvBool(False) Migrated: the two construction gates in parallel_state (host-staged inline, LL via _build_ll_allreduce) and LLAllReduce.__init__'s max-bytes read. ACCEPTANCE SEMANTICS DELTA, STATED (this is NOT byte-identical, and the safer superset was chosen): the raw gates were `== "1"`; EnvBool.parse also honors "true"/"yes"/"y" case-insensitively and maps junk to the default-off with a warning. Every value the raw check accepted ("1") still arms; the widening only makes an operator who wrote =true get the transport they clearly meant. Under the LLGUARD guard this is collision-safe for every spelling. The MAX_BYTES move is strictly more forgiving: the raw int() raised on garbage and took the coordinator __init__ down with it; EnvInt.get warns and uses 65536. The raw == "1" pin from commit LLGUARD was replaced by the new acceptance table, not deleted. Out of scope, deliberately left raw (entry 256's two secondary knobs, named by neither task nor audit): SGLANG_HOST_STAGED_ALLREDUCE_MIN_BYTES and ..._PIECE in host_staged_allreduce.py -- _PIECE is a module-import-time read, registration would need a callable-default discussion of its own. Tests: test_parallel_state.py +test_ll_env_acceptance_is_env_bool (8-value table through the real gate) and +test_comm_envs_are_registered_not_raw (defaults: False/65536/False; source pins that the sites read the handles, per the repo's mocks-cannot-catch precedent). Battery CVD=9: test/registered/unit/distributed/ = 133P/1S/35sub 0F (commit-1 state 132P, base 120P/1S/35sub). Manual GPU tests unaffected (env names in docstrings only; envs.get reads live os.environ, so a setenv-driven boot behaves the same).
ad19c6a to
f38f473
Compare
|
@ch-wan rebased onto current main. The only conflict was #36088's |
Motivation
On PCIe-only boxes,
CustomAllReduceV2requires full NVLink, so sglang falls back to the legacy v1CustomAllreduce. WhenPYTORCH_CUDA_ALLOC_CONF=expandable_segments:Trueis set (the Qwen3.8-Flash-Next cookbook recommends it for long contexts), CUDA-graph inputs come fromcuMemCreatememory. During capture v1 records those pointers, andregister_graph_buffers->get_graph_buffer_ipc_metacallscudaIpcGetMemHandleon them, which only acceptscudaMallocmemory. The server dies during graph capture withRuntimeError: invalid argument. This is attempt 1 in #44291.Reproduced on 2x RTX PRO 6000 Blackwell Server Edition (sm_120, PCIe, no NVLink, P2P OK),
lmsysorg/sglang:dev-cu13at a6a8c56,Qwen/Qwen3-0.6B,--tp-size 2:expandable_segments:TrueRuntimeError: invalid argumentinget_graph_buffer_ipc_metaexpandable_segments:True+SGLANG_ENABLE_PCIE_IPC_ALLREDUCE=1expandable_segments:True+ this PRModifications
python/sglang/srt/distributed/device_communicators/custom_all_reduce.py: during capture, an input that is VMM memory (checked with the existingis_vmm_pointer) goes through the staged path, which copies it into v1's pre-registeredcudaMallocIPC buffer. That is the pathSGLANG_MEMORY_SAVER_CUDA_GRAPHalready uses, so no kernel or sgl-kernel change is needed. Non-VMM inputs keep the registered path exactly as before. The check is per input, so it also covers the memory saver and symmetric-memory pools, and it only runs at capture time.test/registered/kernels/ops/communication/test_custom_all_reduce_v1_vmm.py: new 2-GPU test that runs v1 underexpandable_segments, captures 4 all-reduces per graph (inputs from a plain tensor and from the graph's own pool), and compares against NCCL exactly.Why not zero-copy like v2's
VmmGraphInputManager: v1's graph slots only takecudaIpchandles, so zero-copy would need a new AOT op and an sgl-kernel release. Staging reuses a path that is already in production.Accuracy Tests
1 failed, 1 passed(test_graph_all_reduce_matches_nccl[16-False]raisesRuntimeError: invalid argument); with it9 passed.expandable_segments+ this PR, the smoke request returns the same text as the default allocator at temperature 0.Speed Tests and Profiling
Decode with
sglang.benchmark.one_batch_server,Qwen/Qwen3-0.6B, TP2, input 256, output 128, steady-state tok/s:expandable_segmentsDefault users see no change.
expandable_segmentsusers go from a crash at startup to 2-3% below the default allocator.Per all-reduce, 8 captured per graph, median of 2 runs:
expandable_segments)Staging adds about 0.8 us at decode sizes and stays 2.3-2.7x faster than falling back to pynccl.
Checklist
Refs #44291
CI States
Latest PR Test (Base): ⊘ Skipped -- a maintainer comments⚠️ Run #47166305823
/tag-and-rerun-cito run CI tests.Latest PR Test (Extra): ⊘ Skipped -- a maintainer comments
/tag-and-rerun-cito run CI tests.Latest PR Test (AMD ROCm 10):
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: