Repository navigation
operatorx: GEMM testlist cleanup, MoE data-parallel groups bugfix - #5007
Conversation
Every dp rank timed the same batch. The CUDA graph replays on the launcher's padded input, drawn from the default generator after the same seed on every rank, so the per-group tokens only fed the untimed path; hash-routing token ids and forced expert ids were seeded alike on every rank too. A dp row then touched the experts of T tokens instead of T*dp. - _launcher: the padded input's first rows are the op's tokens; padding rows come from the op's generator when it supplies one (MoE: the group's). - Hash routing and the model's own module: token ids per dp group (tid2eid, the model's table, stays shared). - Forced routing: per-group draws; balanced continues the round-robin across groups, zipf keeps one expert ranking, single_hot keeps expert 0 hot. - dp group 0 draws exactly as before, so dp=1 rows are unchanged. Refs #4996 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Beyond the inline findings, I also checked how the new generators line up with devices. The device generator g passed through ctx goes into torch.randn on x.device, which is the same device. In _MoeBlock, _dp_generator(routing["seed"]) makes a CPU generator for a CPU randint, which matches. And _dp_generator(...) or g behaves correctly because a torch.Generator is always truthy. None of these is a problem.
Extended reasoning...
The change touches only the vLLM MoE and GEMM benchmark runners in operatorx (moe.py and the shared CUDA-graph _launcher in linear.py), with no security-sensitive surface. The generator-device and truthiness questions were checked against the diff and are not problems.
Findings marked 🟡 are optional suggestions and need no follow-up push.
| base = (torch.arange(tokens * top_k) + dp_rank * tokens * top_k) % experts | ||
| ids = base.view(tokens, top_k) |
There was a problem hiding this comment.
🔴 With dp > 1, balanced routing still gives every data-parallel group the same experts for most models. Experts then see T tokens' worth of load, not T·dp. The offset dp_rank * tokens * top_k uses tokens=_MAX_TOKENS (65536, moe.py:224), not the op's T. It is 0 mod experts whenever 65536·top_k divides by E, as for E=256/128/64, or E=384 with top_k=6. Fix: offset by dp_rank * T * top_k using the op's real token count (a["tokens"]), since _ForcedRouting slices only the first T rows.
Why this was flagged
_MoeBlock builds forced ids at moe.py:224 as _forced_ids(..., _MAX_TOKENS, E, K, seed, _dp_rank()), and _MAX_TOKENS = 65536 (moe.py:24). _ForcedRouting uses only forced_ids[: gating_output.shape[0]] (moe.py:175), i.e. the first T rows. Row 0 of rank r starts at (r*65536*K) % E. For E=384, K=6 that is r*393216 % 384 = 0, and for any power-of-two E ≤ 65536 it is 0 for every K. So every group gets the same expert set. Only the per-rank column randperm differs, and it does not change which experts are touched. The PR claims balanced covers 384 experts over dp8, T=8 for DeepSeek-V4-Pro (384 experts, top-k 6). The code still touches 48, the same as one group, so the 14 dp>1 balanced rows keep the inflated bandwidth this PR sets out to fix.
Verification: normal. Triggering condition: an op with routing.distribution "balanced", parallel.dp > 1, and an expert count E that divides 65536·top_k. That covers every power-of-two E up to 65536 at any top_k, and E=384 at top_k=6. Mechanism: moe.py:224 calls _forced_ids(routing["distribution"], _MAX_TOKENS, E, K, routing["seed"], _dp_rank()) with _MAX_TOKENS = 65536 (moe.py:24). So moe.py:144 computes base = (torch.arange(tokens * top_k) + dp_rank * tokens * top_k) % experts with tokens=65536, not the op's T. The offset r·65536·K mod E is 0 in those cases.
There was a problem hiding this comment.
Fixed in 3a5ea4f. With balanced routing and dp > 1, each group's round-robin offset now uses the op's token count (a["tokens"]) instead of the 65,536-row buffer length. It is rewritten per case, because a layer is now built once and reused across its token sweep. Checked on CPU: for E=256/top_k=8/T=8 and E=384/top_k=6/T=16, groups 0 and 1 previously routed to identical experts (64/64, 96/96 shared) and now share none. Every MoE case in the testlists uses natural routing, so no collected results were affected.
|
|
||
|
|
||
| def _dp_generator(seed: int, device=None): | ||
| """Generator for this data-parallel group's token draws. Group 0 returns None (draw as before).""" |
There was a problem hiding this comment.
🟡 nit (optional): "(draw as before)" in the _dp_generator docstring is a history comment, which AGENTS.md:57 prohibits. Fix: say what group 0 does now, e.g. "Group 0 returns None so callers use their shared generator".
Why this was flagged
AGENTS.md:57 forbids comments describing how code evolved or what it replaced. The new docstring at moe.py:89 refers to earlier behavior ("draw as before"), which is the kind of comment that rule bans. No runtime effect; this is a convention slip only.
Verification: The new docstring at operatorx/runners/common/vllm/moe.py:89 says "Group 0 returns None (draw as before)." The phrase "draw as before" describes how group 0 behaves compared with the earlier code, which makes it a history comment. AGENTS.md:57 says "No history: how code evolved, what it replaced, where it came from, or past results."
There was a problem hiding this comment.
Fixed in 3a5ea4f: the docstring now says what group 0 does (returns None, so callers use the generator every group shares).
…el synthetic shapes gemm_serving_8k1k_min and gemm_serving_all_min mixed DeepSeek-V4-Pro's serving GEMMs with shapes from larger hypothetical models that are no checkpoint (no sources). The DeepSeek-V4-Pro cases move into gemm_deepseek_v4 (3,719 new, 217 existing cases gain sources; one case per shape), the rest are dropped, and both files are deleted. Shapes from no model (116 in gemm, 2 in gemm_perf) now carry the source operatorx/Synthetic-Shapes/<testlist> instead of none. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The shapes Ascend 950PR runs measured from no model (a 326-shape bf16 sweep) and the 116 synthetic cases from gemm.json move into one list, gemm_synthetic.json (441 cases, source operatorx/Synthetic-Shapes/gemm_synthetic). gemm_perf keeps its two smoke squares. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nder dev/ gemm.json splits by source model into gemm_deepseek_r1, gemm_kimi_k2, gemm_qwen3_5, gemm_glm5, gemm_minimax_m2_5 and gemm_gpt_oss; its DeepSeek-V4 and MiniMax-M3 cases join gemm_deepseek_v4 and gemm_minimax_m3. A shape several models share goes to each of their lists with all its sources; each list holds one case per shape. Testlists live in testlists/official/ (ingested) and testlists/dev/ (gemm_perf, smoke_parallel). The sweep never ingests a run that includes a dev list, and its default testlist is now gemm_perf. The loaders search both directories and reject a name found twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The gemm/moe/attn _parallel lists merge into gemm_, moe_ and attn_ deepseek_v4, minimax_m3 and kimi_k3. Planning already selects cases by world size, so a single-device run of a model's list skips them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hapes A source is <org>/<model>/<role>, or <org>/<model> for a shape with no layer; the loader and recipe lookup accept both. This matches the relabeled OperatorX database. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The layers of one model share the token dimension, so every single-device layer of a model's GEMM list now covers the same M values. Each model keeps about its previous case count: K = cases / layers values, chosen from the M values its layers already sampled, one per equal band of log(M), taking the value most layers had. Multi-device cases are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A shape from no model has the source operatorx/Synthetic-Shapes/m<M>_n<N>_k<K>, so it parses like every <org>/<model>/<role> source; the two-part form is dropped again. Matches the OperatorX database. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its DeepSeek-V4, Kimi-K3 and MiniMax-M3 cases are already in moe_deepseek_v4, moe_kimi_k3 and moe_minimax_m3; the rest sampled a few MoE layers of models with no MoE list, which is removed rather than kept sparse. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each single-device layer now has a value in every half-octave bin from 1 to 65,536 (the 32 bins an integer count can reach), the bins the model view groups token counts by. Missing bins take a value the model already sampled, else the standard grid value; gemm_glm5, gemm_gpt_oss, gemm_minimax_m2_5, gemm_minimax_m3, gemm_qwen3_5 and gemm_synthetic gain cases, none lose any. Co-Authored-By: Claude Opus 5.5 <[email protected]>
gemm_deepseek_r1, gemm_kimi_k2 and gemm_minimax_m2_5 move to testlists/deprecated/. Like dev lists, a run that includes one is never ingested; their stored results stay. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sweep ingests a run only if every testlist it names is in testlists/official/, instead of excluding dev/ and deprecated/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Repeat each MoE and attention layer's single-device token ladder at the splits InferenceX serving recipes use on up to 8 GPUs. Skip MoE dp cases whose dp x tokens exceeds 65,536. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Score the shards 0 so every other CI job on the pool runs first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit e641ca6.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A shard runs one part per parallel split in turn; each part runs as many process groups side by side as the node has GPUs for, each on its own GPUs. - A layer's ladder stays in one process, which builds the GEMM or MoE layer once and times every size on it. - Shards hold up to 4000 cases and about 30 minutes of estimated work. - No cooldown sleep by default; telemetry flags throttled ops. - A cancelled sweep does not trigger ingest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Attention cases take seconds each and every part pays process startup, so shard sizing estimates per op type and per part (from H100 runs). Decode context parallelism shards the MLA KV cache; the KDA layer has none, and its dcp cases are dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
After a case that raised an error, or that failed with no layer or engine cached while the process still holds device memory (a failed startup vLLM never freed), the process checkpoints and exits; the rank wrapper starts a fresh one that runs that case once more and resumes. A single-device process that dies mid-case is resumed after recording the case as an error. Every rank of a group decides together. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cess A layer whose build fails again after a restart, or two of whose cases fail again after one, has its remaining cases recorded with that result instead of restarting for each. Failures are tagged with the step they failed in (ranks.together), on every rank. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
It is retried once in a fresh process first, so memory an earlier case left behind is not mistaken for the op's own need. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Newer vLLM dropped num_common_prefix_blocks; every DeepSeek-V4 attention case on the B200, B300 and MI355X recipe images errored on it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CollectiveX moved to the new label in #4650; OperatorX jobs queued for the old one and never started. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A second vLLM engine in one process can hang in its process-group setup (10 minutes per case on MI355X Kimi-K3 KDA; H100 dcp). Under a CI part the attention runner asks for a fresh process instead (FreshProcessError): the harness restarts and runs that case first, without a result row. Shard sizing uses DeepSeek-V4 attention at up to 20 s per case (B200). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ranks of a group shared nothing between restarts: a rank that hung (rank 0 after a fresh-process request on B200) kept the others waiting at its rendezvous until the shard timed out. Now the first rank to end an attempt marks it; every other rank's supervisor dumps its process's stacks and kills it, rank 0's supervisor makes the group's progress file final, and all ranks resume from it together. Only a crash records the case in flight as an error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s twice A case that hangs in a collective otherwise waits for NCCL's 10-minute watchdog (B200 DeepSeek-V4 attention at dp2). A per-case watchdog (300 s, 900 s for a process's first case) records the case as an error with the process's stacks and restarts the group; a layer two of whose cases crash or hang has the rest recorded the same way. The shard log tail is read with undecodable bytes replaced. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ter a hang The first case of each layer builds it and compiles its kernels and gets 30 minutes (DeepSeek-V4 attention on B200 compiled for over 15 minutes cold); later cases 5 minutes. A rank stuck in native code holding the GIL still stops (faulthandler's own thread). A case that kills or hangs the process runs once more in a fresh one before it is recorded as an error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ranks other than 0 exited at once and their supervisors killed rank 0 before it saved the group's progress, so a layer whose build failed twice was never recorded as such and every case restarted (Kimi-K3 MLA on B200). Every rank now passes a barrier after rank 0's writes, and a supervisor gives its process 30 s to exit before dumping and killing it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Plus a dev testlist reproducing DeepSeek-V4.1 ratio-1 attention at tp1/2/8 (removed once fixed). Co-Authored-By: Claude Opus 5.5 <[email protected]>
DeepSeek-V4.1's compress-ratio-1 layers call their attention module once per 128-token chunk; the runner captured and timed the first call only, so prefill rows of those layers measured one chunk (on any split). The runner now captures each call in the step and replays them in order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In eager prefill vLLM's decoder replay runs the layers from the last KV source on (V4.1-Flash: 20-39, every compress-ratio-1 layer) on each request's trailing sliding window only; the source layer first writes its KV for every row (forward_kv). The runner captured only the module's forward, so the source layer's rows missed that write. It now captures and replays every forward and forward_kv call of the step, each under its own forward context. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI priority scoring moved to the scheduler (#5085): drop this branch's ci-priority.yaml change and keep main's scheduling facts in the sweep workflow, alongside the official-testlist ingest check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n experts A group's round-robin offset used the routing buffer's length (65,536) rather than the op's token count, so with dp > 1 every group routed to the same experts whenever 65,536 x top_k divides by the expert count. The offset now follows the op's tokens. No collected case uses balanced routing (all are natural), so stored results are unaffected. Co-Authored-By: Claude Opus 5.5 <[email protected]>
3a5ea4f recorded this worktree's stale submodule checkout by accident. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two changes: the MoE data-parallel fix (refs #4996), and a GEMM testlist cleanup.
MoE fix: not rerun yet; the 14 dp>1 cases in
testlists/moe_parallel.jsonneed a rerun after review.Bug
With dp > 1, every data-parallel rank timed the same tokens. The schema says each dp group brings its own batch, so experts should see T·dp distinct tokens.
_launcher. It captured and replayed the graph onxp = torch.randn(...), drawn from the default generator. Every rank seeds that generator the same way (torch.manual_seed(routing["seed"])), so every rank drew the samexp. The per-groupxonly fed the untimed check and the eager path.routing.seed, so they were identical on every rank.Result: a dp row touched the experts of T tokens, not T·dp. For example, DeepSeek-V4-Pro at dp8, T=8 on H200 (run 36460297119) read 101–115% of the bandwidth roofline.
Fix
linear.py_launcher: the padded graph input's first rows are now the op's own tokens (ctx["x"]). The padding rows come from the op's generator when it supplies one. GEMM supplies none, so it keeps drawing padding from the default generator.moe.py:tid2eid, the model's token-to-expert table, stays the same on every rank.Effect on existing rows
mainexactly.xinstead of a separate random draw with the same distribution. The values differ, but the distribution is the same.x, also from the default generator, so its inputs are drawn the same way as before.Forced ids with dp8, T=8, 384 experts, top-k 6, distinct experts touched (one group → all eight groups):
operatorx/testspass (70, plus 61 subtests).Testlist cleanup
gemm_serving_8k1k_min.jsonandgemm_serving_all_min.jsonare deleted. Their DeepSeek-V4-Pro cases move intogemm_deepseek_v4.json: 3,719 new cases, and 217 existing cases gain sources, with one case per shape. Their unlabeled cases (5,177 entries) came from larger hypothetical models, not checkpoints, and are dropped. Nothing else referenced either file.New
gemm_synthetic.json(441 cases) holds the GEMM shapes from no model: the 116 synthetic cases that were ingemm.json(now 5,300 cases), plus the 326-shape bf16 sweep that Ascend 950PR runs measured; 2 of those were alreadygemm_perfsquares, so 324 are new. Their source isoperatorx/Synthetic-Shapes/m<M>_n<N>_k<K>(e.g.operatorx/Synthetic-Shapes/m1_n1088_k7168), the same form as every<org>/<model>/<role>source.gemm_perfkeeps its 2 smoke squares under the same naming. The README notes the convention; the loader accepts it, and recipe lookup treats it like no checkpoint.gemm.jsonis split by source model:gemm_deepseek_r1gemm_kimi_k2gemm_minimax_m2_5gemm_qwen3_5gemm_glm5gemm_gpt_ossIts DeepSeek-V4 cases join
gemm_deepseek_v4(516 new) and its MiniMax-M3 cases joingemm_minimax_m3(98 new). A shape several models share goes into each of their lists with all its sources: 2,056 of the 5,300 shapes land in 2–4 lists, mostly shared between DeepSeek-R1 and Kimi-K2. Each list holds one case per shape.Testlists move into
testlists/official/(ingested),testlists/dev/(gemm_perf,smoke_parallel) andtestlists/deprecated/(gemm_deepseek_r1,gemm_kimi_k2,gemm_minimax_m2_5, models that get no new data; their stored results stay). The sweep ingests a run only if every testlist it names is inofficial/, and its default testlist changes fromgemmtogemm_perf. The loaders search both directories and reject a name that appears in both. I checked a CI planning dry run ongemm_kimi_k2,gemm_perf.The
gemm_parallel,moe_parallelandattn_parallellists merge into each model's list (*_deepseek_v4,*_minimax_m3,*_kimi_k3). Planning already selects cases by world size: for example,moe_deepseek_v4plans 96 cases at world size 1 and 34 at world sizes 2, 4 and 8.One M sweep per model: every single-device layer in a model's GEMM list now covers the same M values, and each model keeps about its previous case count:
gemm_deepseek_r1gemm_deepseek_v4gemm_kimi_k2gemm_minimax_m3gemm_minimax_m2_5gemm_glm5gemm_qwen3_5gemm_gpt_ossHow the values are chosen: the number of M values per layer is the model's previous case count ÷ its layers. The values come from the M values that model's layers already sampled, split into that many equal bands of log(M), taking in each band the value most layers had. N, K and the dtypes of each layer are unchanged.
Every M and token ladder covers every half-octave bin from 1 to 65,536: the 32 bins a whole-number count can reach, which are the bins the dashboard's model view groups token counts by. A missing bin gets a value the model already sampled, or the standard grid value if it had none. Six lists gain cases and none lose any:
gemm_glm5gemm_gpt_ossgemm_minimax_m2_5gemm_minimax_m3gemm_qwen3_5gemm_syntheticDeepSeek-R1, DeepSeek-V4, Kimi-K2, Kimi-K3 and the MoE lists already covered every bin. Multi-device cases are covered in the next item.
Multi-device MoE and attention cases at the splits InferenceX serving recipes use on up to 8 GPUs. Each layer's single-device cases are repeated at every split its model is served with, over the same token ladder. A serving config maps to splits as: plain tp → tp; tp with ep → attention tp, MoE tp·ep; tp with dp-attention → dp; tp with ep and dp-attention → attention dp, MoE dp·ep; tp with dcp → attention tp·dcp, MoE tp. The lists leave out the 58 MoE dp cases whose dp × tokens exceeds 65,536; nothing in the harness changes.
moe_deepseek_v4moe_minimax_m3moe_kimi_k3attn_deepseek_v4attn_kimi_k3attn_minimax_m3A CI planning dry run at world sizes 2, 4 and 8 plans 3,264 cases in 68 shards on H200, B300 and MI355X. Serving splits over 8 GPUs (GB200/GB300 racks: DeepSeek-V4 tp12/16/32 with ep and dp-attention, Kimi-K3 tp16 with dcp16 or ep16) need multi-node runs, which the harness does not do yet; that is a follow-up.
Faster collection (
ci.py,main.py, the vLLM GEMM/MoE runners):A shard runs one part per
parallelsplit in turn, in one Slurm allocation. Each part runs as many process groups side by side as the node has GPUs for (8 single-device processes on an 8-GPU node, 4 at tp2, ...), each on its own GPUs with its own layers. Previously every shard held the whole node for one process.A layer's ladder (cases that differ only in
m,tokensor the attentionbatch) stays in one process, which builds the GEMM or MoE layer once and times every size on it. Weights were already seeded identically per case; only the rebuild goes.Shards hold up to 4,000 cases (
chunk_size, default 4,000) and about 30 minutes of estimated work, estimated per op type plus a startup cost per part.No cooldown sleep by default (
OPERATORX_COOLDOWN_RATIO=0); telemetry already flags throttled ops.A part whose cases are all unsupported no longer fails its shard or stops its sibling processes; the shard summary still fails errors and shards without ok rows. A cancelled sweep no longer triggers ingest. H100 shards stage under the account home, as B300's do (the configured parent was not writable).
Recovery from failed cases: after a case that raised an error (OOM, device fault), or that failed with no layer or engine cached while the process still holds device memory (vLLM never frees a failed engine startup), every rank of the group exits after its checkpoint and the rank wrapper starts a fresh process, which runs that case once more and resumes. A layer whose build fails again in the fresh process, or two of whose cases do, has the rest of its cases recorded with that result instead of restarting for each. A single-device process that dies mid-case resumes after recording the case as an error. Before, every case after a failed attention engine startup was recorded unsupported ("Free memory on device ... on startup"): on H100, 98 DeepSeek-V4 dp8 and 32 Kimi-K3 dcp8 cases. In the H100 retest every case of those shards was recorded, with 2 and 4 restarts.
H100 test runs (ingest off): all 10,111 GEMM cases in 4 shards, about 12 minutes from first shard start to last finish (median 0.1 s per case, from about 1 s). MoE multi-device: 1,350 cases in 5 shards; attention multi-device: 1,848 cases in 11 shards. Against the stored H100 rows, bf16 GEMM and bf16 MoE match (median ratio 1.00); fp8/fp4 GEMM and quantized MoE above 2,048 tokens are faster, from the newer vLLM images (the stored rows are from vLLM 0.29.1).
operatorx/perf-changelog.yaml: one entry for this PR.Stored results are relabeled separately in the OperatorX database.
🤖 Generated with Claude Code