Skip to content

fix(ep): AsyncLL slot assignment double-allocates when top-k does not divide warpSize - #505

Merged
TianDi101 merged 2 commits into
mainfrom
fix/asyncll-slotassign-lane-tiling
Jul 31, 2026
Merged

TianDi101 merged 2 commits into
mainfrom
fix/asyncll-slotassign-lane-tiling

Conversation

@TianDi101

@TianDi101 TianDi101 commented Jul 29, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

EpDispatchLowLatencyAsyncSendCopySlotAssign tiles a wavefront into
tokensPerWarp = warpSize / numExpertPerToken token groups. If top-k does not divide
warpSize, the trailing lanes form an incomplete group that resolves to the next warp's
first token:

warpSize=64, numEpt=6 -> tokensPerWarp=10
warp g   lanes 60..63 -> token g*10 + 10
warp g+1 lanes 0..3   -> token (g+1)*10     // same entry

Both warps take the atomicAdd branch, so one entry consumes two slots while
dispDestTokIdMap[i] keeps only one. The surplus slot is orphaned — SendCopyMultiBlock
never writes it, but RecvTransfer signals the inflated count, so the receiver reads
untouched memory as a token. Its index bytes give pe = id / numExpertPerRank out of
range, tripping the assert in RecvCopyMultiBlock.

Note this corrupts dispatch before it ever crashes: some tokens are routed twice with one
copy reading stale memory, so runs that complete without asserting are also affected.

Hidden until now because 64 % 8 == 0. DeepSeek-V4 uses top-k 6 (64 % 6 == 4), which
exposed it. Top-k 9 was already covered but _AsyncLLCombineOnlyTestCase skips
check_dispatch_result at non-multiple-of-8 top-k, so it could not catch this.

Fix

if ((inWarpTokIdx >= tokensPerWarp) || (tokenId >= args.curRankNumToken)) continue;

Active lanes only __shfl from baseLane + j < tokensPerWarp * numEpt, so masking these
lanes cannot disturb the dedup shuffle. No-op where top-k divides warpSize. This tiling
pattern appears at one site in the tree.

Test

test_dispatch_slot_assign_lane_tiling checks three top-k agnostic invariants, so it works
where the positional check cannot: received count matches the deduplicated host-side
expectation, source positions are unique, and each decodes to an in-range
(src_rank, src_id). Parametrized over top-k 8, 6, 9, 10, 12 (8 is the clean-tiling
control).

Verified on 8x MI355X:

New test, before fix FAILED — Rank[0] received 587 dispatched tokens, expected 547
New test, after fix 5 passed
Full test_dispatch_combine_async_ll.py, after fix 194 passed, 233 skipped, 0 failed

ditian12 added 2 commits July 29, 2026 08:19
…opk != 0

SlotAssign tiles a wavefront into tokensPerWarp = warpSize / numExpertPerToken
token groups. When top-k does not divide warpSize the trailing lanes form an
incomplete group that aliases the next warp's first token, so warp g lanes
[tokensPerWarp*numEpt, warpSize) and warp g+1 lanes [0, warpSize % numEpt)
compute the same entry.

Both take the atomicAdd branch, so one entry consumes two slots on
destPeTokenCounter while dispDestTokIdMap keeps only the last writer's. The
surplus slot is orphaned: SendCopyMultiBlock never writes it, but RecvTransfer
still signals the inflated count, so the receiver reads untouched memory as a
token -- giving pe = id / numExpertPerRank out of range and tripping the assert
in RecvCopyMultiBlock.

This corrupts dispatch before it ever crashes: some tokens are routed twice with
one copy reading stale memory, so runs that complete without asserting are also
affected.

Latent because 64 % 8 == 0. DeepSeek-V4 uses top-k 6 (64 % 6 == 4), which
exposed it. Small batches also masked it, since orphan slots still held valid
ids from earlier iterations until the batch grew past that high-water mark.

Active lanes only __shfl from baseLane + j < tokensPerWarp * numEpt, so masking
these lanes cannot disturb the dedup shuffle. No-op where top-k divides warpSize.
…% topk != 0

check_dispatch_result cannot run at non-multiple-of-8 top-k, and
_AsyncLLCombineOnlyTestCase skips it with a comment asserting the dispatch data
is correct there -- exactly the assumption the lane-tiling bug violates. That is
why the existing top-k=9 coverage, which also has a straggler lane, passed.

The new checks are top-k agnostic: received count must equal the deduplicated
host-side expectation, source positions must be unique, and each must decode to
an in-range (src_rank, src_id). An orphan slot fails all three.

top-k 8 is the clean-tiling control; 6 is DeepSeek-V4's and exposed this; 9/10/12
cover other remainders. max_num_inp_token_per_rank=128 exceeds tokensPerWarp so
adjacent warps actually collide rather than relying on a rare boundary hit.

Verified on 8x MI355X: unfixed -> FAILED ("Rank[0] received 587 dispatched
tokens, expected 547"); fixed -> 5 passed.
@TianDi101
TianDi101 force-pushed the fix/asyncll-slotassign-lane-tiling branch from 5eff956 to cd9d2bd Compare July 29, 2026 08:19
@TianDi101
TianDi101 merged commit 12d1bc3 into main Jul 31, 2026
31 of 35 checks passed
Oseltamivir added a commit to SemiAnalysisAI/InferenceX-app that referenced this pull request Aug 30, 2026
…opk-6 assert)

Bisected on-metal with a pure mori.ops probe on mia1-p01-g18: AsyncLL passes at
top-k 8 with both 256 and 384 experts and dies at top-k 6 with both, on the
device assert (pe >= 0) && (pe < worldSize) in
EpDispatchLowLatencyAsyncRecvCopyMultiBlock. Known upstream: ROCm/mori#505
('AsyncLL slot assignment double-allocates when top-k does not divide
warpSize', merged 2026-07-31); every shipped mi35x image predates it (newest
mori-0706). Cells flip green with the image bump; no new upstream issue needed.
Oseltamivir added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Aug 31, 2026
…(mori >= #505)

AsyncLL under the DSv4-Pro workload (topk 6) dies on every shipped
mi35x-mori image: ROCm/mori#505 (AsyncLL slot assignment double-allocates
when top-k does not divide warpSize, fixed upstream 2026-07-31) postdates
them all. On-metal probe of this date-stamped nightly (job 41563, pure
mori.ops): AsyncLL topk6@384 and topk8@256 both pass, split-phase recv API
present. mi355x only — the -tw SKUs keep their image until separately
validated on their docker path.
@QizhouZhang97
QizhouZhang97 deleted the fix/asyncll-slotassign-lane-tiling branch September 3, 2026 08:00
Oseltamivir added a commit to SemiAnalysisAI/InferenceX that referenced this pull request Sep 9, 2026
… AsyncLL, DSv4-Pro workload (#2786)

* CollectiveX: publish wire-basis bytes so LL bandwidth stops mixing byte definitions

DeepEP/UCCL/NCCL low-latency kernels move one copy per (token, expert)
assignment; normal mode and MoRI LL move rank-deduplicated (token, dest-rank)
copies. byte_provenance always carried the smaller deduplicated numerator, so
any bandwidth divided from it on a token-expert backend was a lower bound
published as the wire rate (34.1% low on nccl-ep LL EP8 at T=128: 77.4 MB vs
the 117.4 MB the kernels move) and not comparable across backends.

Rows now carry wire_byte_provenance beside byte_provenance: identical for
token-rank receives, per-assignment for token-expert ones, basis declared by
the existing logical_copies.wire discriminator. bandwidth.py divides from the
wire basis (falling back to the deduplicated one for pre-wire artifacts, which
only ever understates).

* CollectiveX: hold nccl-ep low-latency fleet-wide until the combine fence ships

The T<=128 ladder clamp reduces exposure to the un-fenced shared-memory combine
race (DeepEP #642's fence, absent at our pin and at NVIDIA master); the source
has said all along it is not a safety boundary — lower rungs are less likely to
hit the race, not immune. Green clamped rows are therefore not
publication-valid, and describing T=256 as a capacity limit was wrong. Rows
held in the registry, normal mode unaffected.

* CollectiveX: charge nccl-ep's per-step routing collective to the timed HT dispatch

ncclEpUpdateHandle is documented as a per-step collective and production
routing changes every MoE layer, so a serving step pays it before every HT
dispatch at the handle's full token capacity. Excluding it (as NVIDIA's
ep_bench does) made HT dispatch the one window that omitted its routing work
while deepep-v2, uccl-ep, MoRI and FlashInfer all carry theirs per call.
kernel_generation bumps to nccl-ep-ht-routed — the per-row discriminator the
earlier NCCL measurement changes lacked.

* CollectiveX: measure MoRI low-latency on AsyncLL, the kernel production deploys

SGLang's moriep dispatcher maps low-latency to AsyncLL split-phase
(dispatch_send/recv + combine_send/recv, block_num 64 rdma 32 warps 8) and
asserts that kernel type; IntraNodeLL is not selected by any engine, so the
previous rows measured an off-production path (kernel_generation intranode-ll
discriminates them). The timed windows now run AsyncLL send+recv back-to-back
and the adapter fails closed on wheels whose AsyncLL lacks the recv API —
single-call AsyncLL returns before any payload lands. Pending on-metal
validation on mi355x.

* CollectiveX: sync methodology with the wire basis, the nccl-ep LL hold and the routed HT window

* CollectiveX: switch the EP workload to DeepSeek-V4-Pro routing

deepseek-v4-pro: hidden 7168, top-k 6, 384 routed experts — the dsv4 shape the
rest of InferenceX benchmarks (operatorx testlists, HF-config-derived). The
workload name is part of every case_id, so this is a clean identity break in
the durable store: no v3 row can collide with a v4-pro row. Ladders and seed
unchanged.

* CollectiveX: sync the README's MoRI low-latency kernel description with AsyncLL (review)

* CollectiveX: rewrite the payload-bandwidth section around the wire basis (review)

The Measurement section still described the rank-deduplicated count as the
sole GB/s numerator and cited the retired IntraNodeLL as the dedup exemplar;
bandwidth.py and the app now divide from wire_byte_provenance. The section now
names both accountings, which rows differ, the 34% understatement that
motivated the change, and the fallback behavior for pre-wire artifacts.

* CollectiveX: exclude b300-001 and b300-016 (mlx5_4 DOWN)

The full v4-pro sweep's two b300 EP16 legs each drew one of these nodes and
failed closed at the network-profile gate (rdma-port-5=inactive = the 5th
selector, mlx5_4). Idle-pool survey: exactly these two nodes have mlx5_4 port
state 1: DOWN; the other 12 idle nodes are 4: ACTIVE — a sick node pair
(likely one leaf/cable pair), not a rail-wide outage. SRE handback owed.

* CollectiveX: hold gb300 low-latency until the nvshmem-over-MNNVL init regression is resolved

All gb300 deepep-v2 LL shards die at the first CUDA op after Buffer init with
cudaErrorUnknown (context poisoned during nvshmem symmetric-heap init over
MNNVL), on every rank, both degrees and precisions. Discrimination: gb300
normal mode green at n2/n4; gb200 LL green with the same image/pin/workload;
a main-branch control with the old workload fails identically — so neither
this PR nor the v4-pro shape. CI-shaped 2-node hand probe (job 27430 on the
pool) reproduces: bootstrap and buffer creation complete, then every rank's
next CUDA call returns unknown error. Driver is 580.159.03 (installed in the
KV-fix window ~2026-08-26..28, after the last green gb300 LL run). Platform
escalation owed; rows held so sweeps don't burn four known-red shards each.

* CollectiveX: bump the mi355x image to v0.5.18-rocm720-mi35x-20260830 (mori >= #505)

AsyncLL under the DSv4-Pro workload (topk 6) dies on every shipped
mi35x-mori image: ROCm/mori#505 (AsyncLL slot assignment double-allocates
when top-k does not divide warpSize, fixed upstream 2026-07-31) postdates
them all. On-metal probe of this date-stamped nightly (job 41563, pure
mori.ops): AsyncLL topk6@384 and topk8@256 both pass, split-phase recv API
present. mi355x only — the -tw SKUs keep their image until separately
validated on their docker path.

* CollectiveX: build DeepEP against the image-matched nvshmem (cu13) — un-breaks gb300 LL

The gb300 LL cudaErrorUnknown was ours, not the platform's. 2x2 on the pool:
stock in-image deep_ep (built on nvidia-nvshmem-cu13==3.4.5) runs LL clean on
the exact r01 nodes and driver (580.159.03) where the CI stack dies; the CI
venv's nvidia-nvshmem-cu12==3.3.9 r12 host library survives sm90/sm100 but
poisons the CUDA context during symmetric-heap init over MNNVL on sm103 —
buffer creation returns, the next CUDA call on every rank fails. The earlier
driver-window attribution was a coincidence of timing (pin bump and driver
install overlapped; hold commit e9ef099 superseded).

The wheel spec now lives in common.sh (COLLX_DEEPEP_V2_NVSHMEM_SPEC), is
installed by prepare_backend, and keys the venv cache so every NVIDIA deepep
venv rebuilds once against cu13. gb300 ll_backends restored.

* CollectiveX: torch 2.11.0 for the DeepEP venv — the actual gb300 LL fix

Root cause, finally isolated by holding everything else constant: a venv
identical to prepare_backend's recipe (same DeepEP pin, same nccl-cu13 2.30.4,
same nvshmem-cu13 3.4.5) is green with torch==2.11.0+cu130 and red with
torch==2.10.0+cu130 on the same gb300 r01 nodes (jobs 27760 vs 27430/27757).
torch 2.10.0's bundled CUDA-13 userland poisons the CUDA context during
nvshmem symmetric-heap init over MNNVL on sm103 + driver 580.159.03; sm90 and
sm100 are unaffected. Falsified along the way, in order: the v4-pro workload
(main control), the driver alone (stock image green on the failing nodes —
the user's r03 canary forced that 2x2), the nvshmem cu12 wheel (cu13 rebuild
still red), the DeepEP pin (old-pin venv red). 2.11.0 is what the cu130 image
ships. The torch spec joins the nvshmem spec in the venv cache key, so every
deepep venv rebuilds once.

* CollectiveX: pin the RDC device-link arch — the real gb300 LL root cause

The DeepEP build compiles every object with the right -gencode (setup.py
'Arch list: 10.3', all compile lines sm_103), but the final nvcc -dlink step
receives NO gencode and falls back to nvcc's CUDA-13 default, sm_75 — the
.so's single linked device image is sm_75 and its kernels can never load on
the target GPU. On gb300/sm103 that surfaced as cudaErrorUnknown at the first
legacy-kernel launch (LL and layout paths; ElasticBuffer JIT paths were
unaffected, which is why normal mode stayed green). Proven by instrumented
runs of prepare_backend's own build (job 27792: compile lines sm_103, step
9/9 -dlink bare, product sm_75) after hand builds of the identical recipe
produced sm_103 and ran LL clean on the failing nodes.

Fix: NVCC_PREPEND_FLAGS carries -gencode=arch=compute_<arch>,code=sm_<arch>
into every nvcc invocation including the dlink. COLLX_DEEPEP_V2_BUILD_GEN
(dlarch1) joins the cache key so the sm_75 venvs with valid .ready markers
rebuild instead of being reused.

The torch 2.10->2.11 bump (previous commit) stays: 2.11 matches the image and
the 2.10-vs-2.11 A/B was run against differently-linked binaries, so its
verdict is voided rather than reversed; the pin question can be revisited
upstream of this fix if anyone cares to re-test.
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