Skip to content

[CPU] Fix shm allreduce collision and sglang-router import - #37179

Merged
mingfeima merged 7 commits into
sgl-project:mainfrom
chunyuan-w:chunyuan/dp_router_pr
Sep 7, 2026
Merged

mingfeima merged 7 commits into
sgl-project:mainfrom
chunyuan-w:chunyuan/dp_router_pr

Conversation

@chunyuan-w

@chunyuan-w chunyuan-w commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Motivation

Two fixes needed to run multiple SGLang engines on a single host behind the data-parallel router (sglang_router.launch_server --dp-size N) on the Intel CPU backend.

Modifications

1. Re-export is_port_available for sglang-router <= 0.3.2

Fixes #23535 (the issue is closed due to inactivity but the issue persists).
#20646 moved network helpers from sglang.srt.utils.common to a new sglang.srt.utils.network submodule but did not re-export them at the package top level. sglang-router <= 0.3.2 (the latest published release) still does from sglang.srt.utils import is_port_available and crashes at launch with ImportError. Added a backwards-compat re-export in sglang/srt/utils/__init__.py.

2. Unique shared-memory allreduce namespace per engine

shm.cpp builds its /dev/shm segment names from MASTER_ADDR/MASTER_PORT + rank. When several engines run on one host, those env vars are unset or identical, so every engine's rank 0 maps the same segment. The shared collective sequence counter desyncs and decode hangs a few seconds into steady state until the watchdog kills the replica.

Fix: export each engine's dist_init_method (tcp://host:port, unique per engine) into MASTER_ADDR/MASTER_PORT before
torch.ops.sgl_kernel.initialize, giving each engine an independent shm namespace with no user env changes. setdefault preserves any user-provided values. Also added an init_threads_binding log line for debuggability.

3. Fix CI failure

test_framework_capacity_is_maximum_of_all_sources fails on main:

AttributeError: 'types.SimpleNamespace' object has no attribute 'speculative_algorithm'

#36972 changed resolve_max_m to call the module-level cutedsl_moe_max_num_tokens(server_args) instead of the attribute server_args.cutedsl_moe_max_num_tokens(), but left the test's SimpleNamespace stub untouched. The function reads fields the stub never declared.
Fix it by giving the stub the fields the function reads (max_prefill_tokens=8192, speculative_algorithm=None, prefill.backend="disabled") so it returns 8192.

Notes

  • Backend: CPU (AMX / ARM64 path only; guarded by _is_cpu_amx_available or _is_cpu_arm64).
  • MASTER_ADDR/MASTER_PORT are set via setdefault, so explicit user settings are respected.

CI States

Latest PR Test (Base): ✅ Run #33852093491
Latest PR Test (Extra): ❌ Run #33852093130
Latest PR Test (AMD ROCm 7.2): ❌ Run #33852093236

@chunyuan-w chunyuan-w changed the title Chunyuan/dp router pr [CPU] Fix shm allreduce collision and sglang-router import Aug 31, 2026
@chunyuan-w

Copy link
Copy Markdown
Contributor Author

/tag-run-ci-label

@chunyuan-w

This comment was marked as resolved.

@chunyuan-w

Copy link
Copy Markdown
Contributor Author

base-a-test-cpu CI failure will be fixed by #37343

@mingfeima

Copy link
Copy Markdown
Collaborator

what's purpose for this one? run multiple ci runners on one machine?

@mingfeima mingfeima added intel cpu cpu backend performance optimization labels Sep 2, 2026
@chunyuan-w

Copy link
Copy Markdown
Contributor Author

what's purpose for this one? run multiple ci runners on one machine?

For smaller models, we want to support running several DP ranks on one machine, for example, DP=2 with TP=2 on a machine with 4 sub-NUMA nodes.

For DP, the recommended API is the DP router (SMG) rather than native DP, as noted in the docs below. That's why we tried the SGLang DP router, and in doing so found several issues that this PR addresses.
https://docs.sglang.io/docs/advanced_features/dp_dpa_smg_guide#smg-based-dp-recommended

⚠️ Native DP is highly not recommended for use right now. It is only used in some ancient/outdated RL frameworks. You can use SGLang Model Gateway (SMG) to power up your data parallelism in any use case.

@chunyuan-w

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@chunyuan-w

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@chunyuan-w

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@mingfeima
mingfeima merged commit 1c992bb into sgl-project:main Sep 7, 2026
262 of 311 checks passed
chenxu214 pushed a commit to AndyLi429/sglang that referenced this pull request Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cpu cpu backend performance optimization intel run-ci

Projects

None yet

2 participants