Skip to content

Allow SGLang EP at tensor width, refuse non-none MoE A2A, and add parallel-group ring checks - #402

Merged
FujitsuPolycom merged 4 commits into
mainfrom
feat/sglang-ep-and-parallel-groups
Nov 21, 2026
Merged

FujitsuPolycom merged 4 commits into
mainfrom
feat/sglang-ep-and-parallel-groups

Conversation

@FujitsuPolycom

Copy link
Copy Markdown
Owner

Summary

Enables SGLang expert parallelism at full tensor-parallel width (--ep-size == tp) on libsircl stock images, refuses non-none MoE A2A dispatch backends, and adds runtime/common/parallel_groups.py to model SGLang (v0.5.21) and vLLM (0.19.1) process-group topologies and ring-only reachability.

Changes

  1. SGLang stock-image EP & MoE A2A gating (runtime/common/stock_image.py, runtime/host/stock_install.py, docs/architecture/libsircl.md):
    • Allow --ep-size / --ep equal to the group's tensor-parallel width (size // pp): SGLang aliases _MOE_EP = _TP, adding no extra communicator. Still refuses 1 < ep < tp and ep > tp.
    • Remove --enable-ep-moe from SGLANG_REFUSED_FLAGS.
    • Refuse --moe-a2a-backend and --speculative-moe-a2a-backend values other than none (e.g. deepep, nixl, mooncake, mori, flashinfer) so dispatch stays on PyNccl over libsircl.
    • Thread group size from stock_install.survey into stock_image.preflight.
  2. Process-group shapes & ring-only reachability (runtime/common/parallel_groups.py, runtime/common/test_parallel_groups.py, runtime/common/test_libsircl.py):
    • Transcribe SGLang v0.5.21 (including _PP stride-tp groups and per-replica DP worlds) and vLLM 0.19.1 communicator construction.
    • Classify each communicator against a rank-to-position map into SINGLE, PAIR (K == 2 cable-adjacent), OPEN_ARC (3 <= K < W, fails under LIBSIRCL_RING_ONLY=1 because engine.c closes the child ring modulo K without a closing cable), WHOLE, or STRIDED.
    • Exhaustive pruned assignment() search with O(1) fast-fail when any group has 3 <= K < W, plus brute-force verification over 4! and 6! permutations.
    • Pin the tools/site_routes.py layout invariant in test_libsircl.py.

Verification

  • Unit tests & lint: ruff check . clean; python -m pytest runtime/common/test_parallel_groups.py runtime/common/test_stock_image.py runtime/common/test_libsircl.py runtime/host/test_stock_install.py — 177 passed.
  • Live 2-Spark hardware validation (Ring 4–7, hosts 8 & 7, LIBSIRCL_RING_ONLY=1, 2 direct RoCEv2 lanes):
    • Unmodified stock lmsysorg/sglang:v0.5.21-cu130-runtime serving nvidia/Qwen3.6-35B-A3B-NVFP4 (256 experts, 8+1 active) with --tp-size 2 --ep-size 2 --moe-a2a-backend none --moe-runner-backend flashinfer_cutlass.
    • /health, /v1/models (max_model_len: 262144), and /v1/chat/completions (both thinking and enable_thinking: false -> EP2_OK) all succeeded.
    • /proc/*/maps confirmed only /opt/sparkring/libsircl/lib/libsircl.so.0.6.0 mapped (zero NVIDIA libnccl.so.2).
    • libsircl receipts on both ranks confirmed exactly 2 communicators (c1 PyNccl + c2 torch PG, confirming _MOE_EP = _TP), ring_only: true, forwarded: 0, healthy: true, 22,185 all-reduces (7,428 CUDA-graph captured, 97.7 GB), 0 staged/refused ops.

A stock runtime derives its NCCL communicators from the parallelism widths
alone, and libsircl creates each as a child of the deployment's communicator
through ncclCommSplit. Under LIBSIRCL_RING_ONLY=1 a process holds queue pairs
only to its ring neighbours, so such a child can start only when its ranks
occupy one contiguous arc of the ring, or the whole ring. That refusal
belongs in the plan, which needs the runtimes' group lists and a map from
process rank to ring position to make it.

runtime/common/parallel_groups.py transcribes SGLang v0.5.21 and vLLM 0.19.1
group construction from the parallelism widths, classifies a group against a
rank-to-position map, lists the rank sets that are not one arc, and searches
for a position order under which every group is an arc (exhaustive over the
ring's positions, pruned as groups complete).

The rank lists are read from each runtime's initialize_model_parallel. At four
Sparks, vLLM dp2 x tp2 fits under the order {0:0, 1:1, 2:3, 3:2}; at eight,
vLLM dp2 x tp4 and SGLang tp8 ep4 have no order. Validation: pytest
runtime/common/test_parallel_groups.py (15 tests), ruff check.
A stock SGLang image on libsircl refused every --ep-size above one, although
the plan's own shape is the safe one: the plan sets --tp-size to the group's
Spark count, and SGLang builds its expert group as the tensor-parallel group
itself at that width (parallel_state.py: "if moe_ep_size ==
tensor_model_parallel_size: _MOE_EP = _TP"). Expert parallelism at that width
adds no communicator, and the deployment's one route map carries it.

preflight now takes the group's Spark count (stock_install passes the group's
row count) and refuses expert parallelism only below that width, where SGLang
forms expert groups of every moe_tp-th rank: no order of the ring makes those
one arc (runtime/common/parallel_groups.py), so the child communicator would
be refused at setup on a rank with no route to its group peer. --enable-ep-moe
leaves the refused-flag list; alone it is a no-op, since SGLang's ep_size
defaults to 1.

--moe-a2a-backend is checked now too: only "none" keeps MoE dispatch on
PyNccl's all-gather and reduce-scatter, and every other value dispatches
through a library the images do not carry (DeepEP's NVSHMEM, NIXL, Mooncake,
MORI or FlashInfer symmetric memory).

Validation: pytest runtime/common/test_stock_image.py (84 tests),
runtime/common/test_parallel_groups.py (27), runtime/host/test_stock_install.py
(9); ruff check clean.
parallel_groups.assignment finds the order of ranks that puts every runtime
communicator on one arc of the cable ring, but that order cannot be applied by
permuting the position list a plan hands to tools/site_routes.py. The tool
numbers each row by its index in the layout ("LIBSIRCL_POSITION": str(rank))
and reads that row's route map from the Spark named at that index, so a
permuted list describes a ring over cables that do not exist rather than a
relabelled rank order. The order is realised by which Spark runs each rank,
leaving the trace in cable order.

The docstring states that, and test_libsircl.py pins the layout invariant: a
cycle listed as 0,1,3,2 keeps positions 0-3 per row and changes what rank 2
reaches, since its row is now the Spark at position 3.

Validation: pytest runtime/common/test_libsircl.py (47 tests),
runtime/common/test_parallel_groups.py (27); ruff check clean.
@FujitsuPolycom
FujitsuPolycom merged commit 22d14ad into main Nov 21, 2026
10 checks passed
@FujitsuPolycom
FujitsuPolycom deleted the feat/sglang-ep-and-parallel-groups branch November 21, 2026 06:09
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.

1 participant