Skip to content

[Kimi] Enable GB300 TP4 and GB200/GB300 TP16 SP collectives - #35330

Merged
kpham-sgl merged 17 commits into
sgl-project:mainfrom
ajit283:feat/k3-sp-world16-gb300
Sep 29, 2026
Merged

kpham-sgl merged 17 commits into
sgl-project:mainfrom
ajit283:feat/k3-sp-world16-gb300

Conversation

@ajit283

@ajit283 ajit283 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable tuned Kimi K3 sequence-parallel collectives for:

  • GB300 DP4 x attention-TP4 / EP16, where attention TP is a derived node-local subgroup of full TP16.
  • GB200 and GB300 attention-TP16 / EP16 across four nodes in one NVL72 segment.

Relationship to upstream communicator work

#35061 provides generic SM100 world-size-16 CustomAllReduceV2 admission and configuration. #35735 subsequently split the communicator into push and pull planes and moved push-capacity validation into push binding.

This PR now contains only the remaining K3-specific functionality:

  1. Derived attention-TP groups inherit the global custom-AR policy instead of unconditionally setting use_custom_allreduce=False. Capability selection still happens independently per group, and explicit --disable-custom-all-reduce remains respected.
  2. K3 SP dispatch admits world size 16 on SM100 and SM103.
  3. Correctness-checked, exact-device GB200 and GB300 world=16,H=7168 RS/AG tables are added.
  4. Pull/direct K3 strategies no longer require push-workspace capacity. Every selected push bucket fits the default 256 KiB world-16 workspace.

The superseded K3 .cuh capacity change was dropped during the rebase; #35735 now owns that check in the push plane. Ordinary TP16 all-reduce behavior remains owned by the generic SM100 heuristics.

Changes

Attention process group

  • Let derived attention-TP groups inherit the global custom-all-reduce policy.
  • Leave final communicator selection to per-group topology and allocator capability checks.
  • Add focused CPU coverage for the derived-group option.

K3 world-16 support

  • Enable K3 SP on SM100/SM103 when an exact-device table is available.
  • Add GB200 and GB300 world=16,H=7168 reduce-scatter/all-gather tables.
  • Keep untuned attention-residual fusion entries on the existing separate path.
  • Check push workspace only after dispatch selects a push strategy; pull RS and direct AG use dedicated symmetric tensors.
  • Add exact-device table lookup and default-workspace-envelope tests.
  • Add one-time dispatch/fallback diagnostics.

Post-rebase tuning and correctness

Both devices were freshly retuned after #35735 on four 4-GPU nodes in one NVL72 segment over global-token buckets 16 through 16384.

  • Every measured push/pull/direct candidate was checked against NCCL before timing.
  • BF16 comparison used rtol=2e-2, atol=5e-2 for rank-16 reduction-order differences.
  • Every selected custom bucket was faster than NCCL.
  • Production selection excludes push candidates above the generic world-16 256 KiB per-rank workspace.
  • Attention-residual fusion was not part of the sweep and remains separate.
  • Independent production-table runs captured and replayed every RS+AG pair with the default workspace: all 11 buckets passed on each device.

GB200 (SM100)

Operation Tokens NCCL Selected custom Strategy Speedup
Reduce-scatter 512 113.521 us 20.134 us pull 5.64x
All-gather 512 93.383 us 17.473 us direct 5.34x
Reduce-scatter 8192 272.829 us 172.307 us pull 1.58x
All-gather 8192 285.638 us 171.881 us direct 1.66x
Reduce-scatter 16384 371.132 us 331.028 us pull 1.12x
All-gather 16384 369.924 us 334.020 us direct 1.11x

GB300 (SM103)

Operation Tokens NCCL Selected custom Strategy Speedup
Reduce-scatter 512 108.330 us 19.722 us pull 5.49x
All-gather 512 124.459 us 17.025 us direct 7.31x
Reduce-scatter 8192 269.595 us 172.248 us pull 1.57x
All-gather 8192 262.123 us 171.695 us direct 1.53x
Reduce-scatter 16384 370.241 us 330.787 us pull 1.12x
All-gather 16384 367.275 us 333.968 us direct 1.10x

Checks

  • Rebased onto upstream/main at ef9e58fd6d.
  • Retuned commit: 94de276baa.
  • Runtime image source: bb5e619860f3f58752b82c9e296dcea9b53b3210; ARM64 manifest sha256:4780de5396e6cc291d8f134a7a9d1dc19386881967eaf6e02ef23c284315121e.
  • Changed-file pre-commit suite, Python syntax compilation, and JSON parsing passed.
  • Focused CPU tests: 9 passed.
  • GB200 and GB300: all candidates correctness-checked before timing; all 11 selected production buckets passed CUDA graph capture/replay against NCCL with the default workspace.

CI States

Latest PR Test (Base): ❌ Run #36543626146
Latest PR Test (Extra): ❌ Run #36543626044
Latest PR Test (AMD ROCm 10): ❌ Run #36543626644

@ajit283 ajit283 changed the title [Kimi] Add GB300 world-16 SP collective tuning [Kimi] Enable GB300 SP collectives for attention TP4 and TP16 Aug 18, 2026
@nvpohanh

Copy link
Copy Markdown
Collaborator

@DarkSharpness could you take a look? Also, what tests should we run? Thanks!

@nvpohanh

Copy link
Copy Markdown
Collaborator

@ajit283 could you fix the conflicts and mark this as ready? thanks

@ajit283
ajit283 force-pushed the feat/k3-sp-world16-gb300 branch from 7a62744 to 276c75a Compare August 19, 2026 11:12
@ajit283
ajit283 force-pushed the feat/k3-sp-world16-gb300 branch 2 times, most recently from 9654bc5 to d3e60c3 Compare August 19, 2026 12:28
@ajit283 ajit283 changed the title [Kimi] Enable GB300 SP collectives for attention TP4 and TP16 [Kimi] Enable GB300 TP4 and GB200/GB300 TP16 SP collectives Aug 19, 2026
@ajit283
ajit283 marked this pull request as ready for review August 19, 2026 12:29
@ajit283

ajit283 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@ajit283
ajit283 marked this pull request as draft August 19, 2026 12:39
@ajit283
ajit283 marked this pull request as ready for review August 19, 2026 15:32
@ajit283
ajit283 marked this pull request as draft August 19, 2026 15:36
@nvpohanh

Copy link
Copy Markdown
Collaborator

All NV pipelines have passed. @DarkSharpness could you approve/merge this? Thanks!

@kpham-sgl kpham-sgl self-assigned this Sep 22, 2026

@kpham-sgl kpham-sgl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some small nits

Comment on lines +292 to +295
if dispatch.strategy == "push":
local_bytes = tensor.numel() * tensor.element_size() // state.group.world_size
if local_bytes > state.comm.max_push_size:
return None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The early exit logic here looks a bit confusing. If the dispatch choose push but there's not enough memory for this, then we should try the next config (typically, "push" wins in low-latency case, "pull" in mid-batch; so if push fails to fit, we may still try "pull")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now included the size calculations into get_dispatch instead of here, seemed cleaner to have it in one place

@nvpohanh

Copy link
Copy Markdown
Collaborator

@ajit283 could you fix the conflicts? Thanks!

Ajit Mistry and others added 2 commits September 28, 2026 18:01
…gb300

# Conflicts:
#	python/sglang/kernels/ops/communication/configs/sp_collective/world=16,H=7168,device_name=NVIDIA_GB200.json
#	python/sglang/kernels/ops/communication/configs/sp_collective/world=16,H=7168,device_name=NVIDIA_GB300.json
#	python/sglang/srt/environ.py
@kpham-sgl

Copy link
Copy Markdown
Collaborator

Talked offline, this PR is good to merge

@kpham-sgl
kpham-sgl merged commit ced5e9f into sgl-project:main Sep 29, 2026
148 of 170 checks passed
guapisolo added a commit that referenced this pull request Oct 16, 2026
… kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
Richardyu114 added a commit to sammysun0711/sglang that referenced this pull request Oct 19, 2026
Let attention-TP groups inherit custom-allreduce and MSCCL++ policies
and participate in graph capture with existing group deduplication.

Allow eligible attention-TP groups to use the existing AITER
reduce-scatter and all-gather paths without changing PyNccl selection.

Add regression tests for policy inheritance and aliased capture groups.

Adapted from sgl-project#31629 and sgl-project#35330.

Signed-off-by: Richardyu114 <[email protected]>
Rockdu pushed a commit that referenced this pull request Oct 30, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
Rockdu pushed a commit that referenced this pull request Oct 30, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
Rockdu pushed a commit that referenced this pull request Oct 31, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
Richardyu114 added a commit to sammysun0711/sglang that referenced this pull request Nov 3, 2026
Let attention TP groups inherit custom-allreduce and MSCCL++ policies
and participate in graph capture. Deduplicate aliased groups and retain
the existing PyNccl selection. Test policy inheritance and capture scope.

Selectively adapt the attention-group changes from the upstream PRs.

Adapted-from: sgl-project#31629
Adapted-from: sgl-project#35330
Signed-off-by: Richardyu114 <[email protected]>
sammysun0711 pushed a commit to sammysun0711/sglang that referenced this pull request Nov 3, 2026
…00X (#39)

* fix(rocm): always mask padded MoE expert IDs

Mask padded top-k IDs to a valid expert even when EPLB is disabled,
while retaining zero routing weights for padded rows. Add a regression
for invalid padded IDs without an expert-location remap.

Adapted-from: sgl-project#28378
Upstream-commit: 6309fb9
Signed-off-by: Richardyu114 <[email protected]>

* perf(moriep): skip unused expert counts in captured graphs

Do not capture LocalExpertCount for the no-op recorder. Keep the
count kernel for configured recorders so recording can start after
capture. Cover inactive, active and capture-time recording policies.

Adapted-from: sgl-project#30302
Upstream-commit: 9ddea8d
Signed-off-by: Richardyu114 <[email protected]>

* feat(mimo): route MiMo MoE through MORI expert parallelism

Recognize MORI in the MiMo A2A initialization and forward-path gates.
Use the existing dispatcher-based forward with padded-token metadata
and avoid the tensor-parallel post-expert reduction path.

Add a regression for MORI forward-path selection.

Signed-off-by: Richardyu114 <[email protected]>

* fix(distributed): enable custom collectives for attention TP groups

Let attention TP groups inherit custom-allreduce and MSCCL++ policies
and participate in graph capture. Deduplicate aliased groups and retain
the existing PyNccl selection. Test policy inheritance and capture scope.

Selectively adapt the attention-group changes from the upstream PRs.

Adapted-from: sgl-project#31629
Adapted-from: sgl-project#35330
Signed-off-by: Richardyu114 <[email protected]>

* perf(rocm): backport AITER reduce-scatter and capture handling

Use AITER for eligible reduce-scatter calls with ROCm defaults. Support
unregistered capture inputs for memory-saver and an opt-in AG/RS copy-in
path, retaining existing collective fallbacks.

Adapt the backport to keep RS inside the registered collective boundary
and check per-rank alignment, output shape/dtype/device and deterministic
policy. Add CPU dispatch tests and a four-GPU collective smoke test.

Only the collective portions are included; gfx950 EP decode kernels and
pre-dispatch token hints are not part of this change.

Adapted-from: sgl-project#29103
Adapted-from: sgl-project#34203
Adapted-from: sgl-project#43077
Signed-off-by: Richardyu114 <[email protected]>

* fix(bench): wait for idle before flushing the server cache

Backport the post-warmup cache-flush race fix. Add --flush-cache-timeout
with a 60-second default for SGLang and retain backend-specific endpoints.
Raise on HTTP failure before issuing measured requests. Cover deferred
flush completion, CLI validation and benchmark abort on flush failure.

Adapted-from: sgl-project#33663
Upstream-commit: 8a1637a
Signed-off-by: Richardyu114 <[email protected]>

* eval(mimo): prepare the Flash DP2 attention-TP4 EP8 launcher

Configure global TP8/EP8 with DP2, MORI normal mode, dense TP1 and a DP
LM head. Size and validate dispatch capacity for prefill and DFlash blocks.

Default PERFORMANCE_MODE=1 to fake routing plus PD prefill; setting it
to 0 selects real routing and ordinary serving. Keep TBO and fused QKV
quantization disabled and leave collective workaround flags unset.

The launcher prepares the target topology; DFlash DP-attention support
is still pending and the existing admission guard is unchanged.

Signed-off-by: Richardyu114 <[email protected]>

* eval(mimo) refine dp2_attn-tp4_ep8 prefill server secript

Signed-off-by: Richardyu114 <[email protected]>

* perf(mimo): enable tuned MORI EP8 launch configs by default

Add gfx942 tuning rules for FP8 dispatch and BF16 combine at
2048, 4096, and 8192 tokens per rank.

Default the MiMo-V2.6-Flash DP2/attention-TP4/EP8 launcher to AUTO
mode with the bundled JSON, while preserving environment overrides.
Validate config readability and log the active config path.

(cherry picked from commit 1c6b707)
Signed-off-by: Richardyu114 <[email protected]>

* perf(mimo): pack FP8 QKV activations and scales into one all-gather

Write fused QKV quantization outputs into a shared FP32 bit-view
buffer and reuse the existing AITER/RCCL collective path. Keep
activations as row-strided views and transpose scales once for
CK/CKTile GEMMs.

Enable the path through SGLANG_MIMO_FUSED_RMS_QKV_QUANT and default
it on in the EP8 launcher. Add layout and 8-GPU graph replay tests.

Validate DFlash GSM8K accuracy and improve input throughput by 4.86%
at global chunk 32K, input 64K, and concurrency 16 on MI300X.

Signed-off-by: Richardyu114 <[email protected]>

* feat(eval): enable prefill delayer in MiMo Flash DP2 launcher

- Enable coordinated prefill admission by default with a configurable
  maximum of 100 scheduler passes and an opt-out switch.
- Validate prefill delayer settings and log the resolved configuration.
- Expose stable router-weight fusion as an environment override,
  disabled by default.

Signed-off-by: Richardyu114 <[email protected]>

* Negotiate PrefillDelayer only after KV-budget admission checks (sgl-project#31835)

Signed-off-by: Richardyu114 <[email protected]>

* [Bugfix] Fix prefill suspension caused by delayed negotiate_should_allow_prefill invocation (sgl-project#32389)

Signed-off-by: Richardyu114 <[email protected]>

* fix(ci): run MiMo EP regression tests through pytest

Add executable pytest entry points for the packed FP8 and MORI tests.
Replace the partial parallel-state runner so direct CI invocation
executes all cases and propagates failures.

Signed-off-by: Richardyu114 <[email protected]>

---------

Signed-off-by: Richardyu114 <[email protected]>
Co-authored-by: Hanming Lu <[email protected]>
Co-authored-by: silencejade <[email protected]>
guapisolo added a commit that referenced this pull request Dec 3, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
guapisolo added a commit that referenced this pull request Dec 3, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
guapisolo added a commit that referenced this pull request Dec 3, 2026
…s without launching the kernel

The legacy CUDA kernel sizes its grid from the element count, so an empty
input launches zero blocks. The launch is unchecked and leaves
cudaErrorInvalidValue pending until the next kernel launch on the thread.

The attention TP group now selects a custom communicator (#35330), so with
SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 an idle DP-attention rank all-reduces
the zero-row embedding output through this path, and its next kernel fails
with "CUDA error: invalid argument". An empty all-reduce exchanges nothing,
so return the empty output directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit-kernel run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants