Skip to content

Commit b39576f

Browse files
hbarclayclaude
andcommitted
operatorx: multi-device gemm, moe and attention under InferenceX recipes
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 187088d commit b39576f

43 files changed

Lines changed: 20284 additions & 1481 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎operatorx/CI.md‎

Lines changed: 14 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22

33
**English** | [中文](CI_zh.md)
44

5-
[OperatorX Sweep](../../.github/workflows/operatorx-sweep.yml) runs manually on the
6-
self-hosted runners carrying one of these labels, the labels InferenceX's benchmark
7-
workflows use: `cluster:h100-dgxc` (default), `cluster:h200-dgxc`, `cluster:b200-nscale`,
8-
`cluster:b300-dsxe`, `cluster:gb200-nv`, `cluster:gb300-nv`, `cluster:mi300x-amd`,
9-
`cluster:mi325x-amds` or `cluster:mi355x-amds`.
10-
Pull requests only run the hosted planner; GPU work requires `workflow_dispatch`.
5+
[OperatorX Sweep](../.github/workflows/operatorx-sweep.yml) runs on `workflow_dispatch` only (pull requests run just the hosted planner).
116

12-
| GPU | Runner label | GPUs per physical node | Image platform | Result cluster |
7+
| GPU | Runner label | GPUs / node | Image platform | Result cluster |
138
| --- | --- | ---: | --- | --- |
14-
| H100 | `cluster:h100-dgxc` | 8 | `linux/amd64` | `h100_dgxc_8x` |
9+
| H100 | `cluster:h100-dgxc` (default) | 8 | `linux/amd64` | `h100_dgxc_8x` |
1510
| H200 | `cluster:h200-dgxc` | 8 | `linux/amd64` | `h200_dgxc_8x` |
1611
| B200 | `cluster:b200-nscale` | 8 | `linux/amd64` | `b200_nscale_8x` |
1712
| B300 | `cluster:b300-dsxe` | 8 | `linux/amd64` | `b300_dsxe_8x` |
@@ -21,190 +16,30 @@ Pull requests only run the hosted planner; GPU work requires `workflow_dispatch`
2116
| MI325X | `cluster:mi325x-amds` | 8 | `linux/amd64` | `mi325x_amds_8x` |
2217
| MI355X | `cluster:mi355x-amds` | 8 | `linux/amd64` | `mi355x_8x` |
2318

24-
GB200/GB300 runs use one four-GPU tray, not the full NVL72 rack. Dense GEMM uses
25-
`world_sizes=1` on every runner; reported TFLOPS remains per GPU. Hardware facts come
26-
from CollectiveX's platform registry, and both planning and execution validate them.
27-
2819
## Dispatch
2920

30-
Once GitHub has registered the workflow, select **OperatorX Sweep → Run workflow**,
31-
choose the source branch, and keep the initial defaults: `runner=cluster:h100-dgxc`,
32-
`backends=vllm`, `testlists=gemm`, `world_sizes=1`, `chunk_size=500`.
33-
This schedules the complete checked-in GEMM catalog in bounded shards (currently
34-
5,416 cases in 11 shards). The catalog includes formats unsupported by a selected
35-
backend and shapes that can exceed device memory. Unsupported rows remain visible;
36-
actual kernel and allocation errors fail CI. A full catalog run is not a promise
37-
that every case fits or is supported on H100. A newly added workflow
38-
may need to reach the default branch before GitHub accepts manual dispatch.
39-
4021
```bash
4122
gh workflow run operatorx-sweep.yml --repo SemiAnalysisAI/InferenceX \
4223
--ref <branch> -f runner=cluster:h100-dgxc -f backends=vllm \
43-
-f testlists=gemm -f world_sizes=1 -f chunk_size=500
24+
-f testlists=gemm -f world_sizes=1 -f chunk_size=500 -f ingest=false
4425
```
4526

46-
`mode=timing` (default) records latency, telemetry and a profiler replay per op.
47-
`mode=counters` instead runs each op once under Nsight Compute (NVIDIA; the host's
48-
`/opt/nvidia/nsight-compute`) or rocprofv3 (AMD; 12 counter passes, so use a smaller
49-
`chunk_size`), with raw counter files under `results/counters/`. Latencies from a
50-
counters run are perturbed by the profiler.
51-
52-
For a quick infrastructure smoke check, explicitly select `testlists=gemm_perf`
53-
and `chunk_size=50` (11 BF16 cases). `attn_deepseek_v4`, `attn_kimi_k3` and `attn_minimax_m3` hold attention modules; dispatch
54-
them separately from gemm / moe lists. Test runs set `-f ingest=false` so their results stay
55-
out of the OperatorX database; a dispatched run is ingested by default. `gemm_serving_8k1k_min` and
56-
`gemm_serving_all_min` hold the GEMMs of InferenceX serving configurations. Unsupported operations remain visible in results. Backend
57-
import errors, benchmark errors, and zero successful rows fail the shard.
58-
Start with BF16 GEMM, then the quantized formats.
59-
Do not infer that Blackwell-specific FP4 kernels work on Hopper.
27+
- Inputs: `runner`, `backends` (`vllm`; AMD also `torch`), `testlists`, `mode` (`timing` | `counters`), `world_sizes` (1, 2, 4, 8), `chunk_size` (1-500), `recovery_run_id`, `ingest` (default true; `false` for test runs).
28+
- `mode=counters`: each op once under Nsight Compute (NVIDIA) or rocprofv3 (AMD, 12 passes: use a smaller `chunk_size`); raw files in `results/counters/`; latencies perturbed.
29+
- Smoke check: `testlists=gemm_perf`, `chunk_size=50`. Dispatch `attn_*` testlists apart from gemm / moe ones.
6030

6131
## Execution contract
6232

63-
- Hosted planning validates inputs, groups backends by container image, separates
64-
world sizes and MoE parallelism triples, and splits shapes into bounded chunks.
65-
At most 256 shards are accepted. World sizes are restricted to 1, 2, 4, and 8,
66-
and must fit one physical node (GB200/GB300 reject 8). Shapes outside the
67-
requested sizes are counted in `excluded_shapes`.
68-
- Each Actions shard holds exactly one exclusive physical Slurm node (four or eight GPUs). The GPU
69-
process count is the selected world size. Admission uses the existing priority
70-
scorer and `ci-job-*`, `ci-attempt-*`, and exactly one `nodes:1` label. All shards remain eligible; the priority/node scheduler controls physical-node
71-
admission. A second GitHub matrix cap can strand assigned labels on held jobs.
72-
Both scheduler switches must remain enabled.
73-
- Runner settings come from CollectiveX's tracked platform registry. Source is
74-
checked out at the workflow SHA and copied into a private, compute-visible
75-
directory below the configured shared squash parent or a writable configured
76-
`storage_roots` entry (GB200). B300 uses the compute-visible account home from
77-
the password database, matching CollectiveX; an explicit `stage_dir` takes
78-
precedence. Results never depend on
79-
a submit-host `/tmp` mount being visible to compute nodes.
80-
- The planner resolves each image digest. Imports are locked and cached by image
81-
plus digest and CPU architecture, with a second digest check after import. A moved or unresolvable
82-
tag fails rather than claiming the planned image was measured. Images must be
83-
anonymously readable from the planning and import hosts. Imports verify the host
84-
CPU architecture and run inside their allocation. B300 follows the inference
85-
launcher's compute-node import because its submit host lacks extraction space
86-
for this image. Enroot and GNU parallel use private temporary directories;
87-
Enroot uses explicit registry URLs and any platform-configured cache path. Allocation
88-
forwards account, QoS, and quarantined nodes; B300/GB nodes retain their existing
89-
remap-root and memory settings. B300 leaves QoS selection to its partition/account,
90-
matching the inference launcher; the former `batch_1_qos` override is rejected
91-
by the current cluster. Its former excluded node names also do not exist in
92-
this cluster and have been removed; Slurm still honors drained nodes. GB300 retains
93-
its configured QoS and exclusions.
94-
- The launcher remains active through allocation, import, and execution. The
95-
allocation time limit is 45 minutes; Actions permits 70 minutes including
96-
queueing and cleanup. Slurm job names match the Actions runner name.
97-
- Signals and the workflow's `always()` recovery step cancel recorded allocations,
98-
stop writers, recover partial results, and remove staged sources. The workflow
99-
explicitly allows 180 seconds for Slurm epilog/node release, including on H200. A failed
100-
cleanup retains staging for investigation. Slurm's time limit is the last
101-
bound if the runner host disappears.
102-
- Strict CI runs atomically checkpoint rank-zero rows after each operation,
103-
outside kernel timing. The existing non-CI timing loop is unchanged.
104-
105-
## Artifacts and reruns
106-
107-
`operatorx-manifest-<run_id>` records requested cases, image digests and source
108-
SHA. It remains available to failed-job reruns. Each attempt uploads separate
109-
`operatorx-shard-<run_id>-<attempt>-<shard>` artifacts containing execution
110-
metadata, allocation/import/benchmark logs, status and any raw result JSONs.
111-
Startup failures can have logs without results; cancellation checkpoints are
112-
partial coverage. A successful shard requires successful measurements, not just
113-
successful Slurm submission. Result environments record the workflow run,
114-
attempt, shard, source SHA and image digest.
115-
116-
Download artifacts through `gh run download`. Preserve raw files and provenance;
117-
`scripts/consolidate_results.py` is not part of CI.
33+
- Planning: shards per backend image, `parallel` split and InferenceX recipe (`recipes.py`: image, launch env, `vllm serve` args), chunked by `chunk_size`; at most 256 shards; a case with no recipe runs on the backend's image from `containers.toml`.
34+
- One exclusive Slurm node per shard (GB200/GB300: one 4-GPU tray, no world size 8); 45 min allocation, 70 min job.
35+
- Image: digest resolved at planning, imported with enroot on the allocated node, cached by image + digest + arch; a tag that moved since planning fails the shard.
36+
- Ranks: one process per GPU of the split's world size, env:// rendezvous; runner settings from CollectiveX's platform registry overlaid by `platforms.json`.
37+
- Results: rows checkpointed after each op; unsupported cases stay visible as rows, errors or zero successful rows fail the shard; artifacts `operatorx-manifest-<run_id>` and `operatorx-shard-<run_id>-<attempt>-<shard>`; ingested into the OperatorX database unless `ingest=false`.
38+
- Cleanup: cancellation and the `always()` step cancel the allocation and keep partial results; after a failed cleanup, rerun one shard with `recovery_run_id`.
11839

119-
## Local validation
120-
121-
Planning requires Python 3.11 or newer. Compute-side control code uses the existing
122-
Python 3.10+ Slurm-host environment. CPU tests run the real planner, benchmark
123-
orchestration and launcher with external GPU/Slurm collaborators substituted.
40+
## Local tests
12441

12542
```bash
12643
uv run --no-project --python 3.12 --with pytest --with pyyaml --with torch --with numpy \
12744
python -m pytest operatorx/tests/ -q
12845
```
129-
130-
Real acceptance additionally requires a smoke run with artifacts on each selected runner, a
131-
failed-shard rerun, and cancellation with confirmed allocation release. CPU
132-
checks alone do not establish GPU compatibility or cluster storage visibility.
133-
134-
The final coverage job selects the newest artifact attempt for each requested
135-
shard, preserves successful shards from previous attempts, and fails if any shard
136-
is missing or failed. Its summary separates requested shapes from result rows
137-
(one shape may run on multiple backends).
138-
139-
If cleanup failed, a single-shard dispatch can set `recovery_run_id` to the recent
140-
OperatorX run from the same runner. It downloads the execution artifacts and retries
141-
allocation/staging cleanup before allocating a new node. Recovery checks the run,
142-
runner, and private staging parent; do not select unrelated or old Slurm executions.
143-
144-
`cleanup.log` records the active-job query used to confirm allocation release.
145-
It queries the current user’s job list because querying a removed job ID directly
146-
can return a Slurm error even after that allocation has terminated.
147-
148-
## AMD execution
149-
150-
`platforms.json` overlays the CollectiveX registry, per runner label, with the AMDS Slurm clusters.
151-
AMD accepts single-GPU `torch`/`vllm` GEMM. ROCm PyTorch uses HIP events through
152-
`torch.cuda`; FP8 selects FNUZ on gfx942 and OCP on gfx950. Unsupported formats
153-
remain explicit. Staging lives outside `_work`, below the shared runner root
154-
derived from `RUNNER_TEMP`. Containers never write to the checkout. MI300X/MI325X
155-
forward `/dev/kfd` and `/dev/dri`; CPU requests follow each inference launcher.
156-
157-
## GEMM
158-
159-
`gemm` args describe each operand's storage and quantization. `a` is the
160-
activation `[M, K]` and `b` the weight `[N, K]`: `{"dtype", "scale"?, "scale2"?,
161-
"symmetric"?}`, where `scale` is `{"dtype", "static", "group": [rows, cols]}` and
162-
`-1` spans a dimension (`[-1, -1]` per-tensor, `[1, -1]` per-token, `[-1, 1]`
163-
per-channel, `[1, 128]` 1x128 groups, `[128, 128]` blocks). For example, FP8
164-
block quantization is
165-
`"a": {"dtype": "e4m3", "scale": {"dtype": "fp32", "static": false, "group": [1, 128]}}` and
166-
`"b": {"dtype": "e4m3", "scale": {"dtype": "fp32", "static": true, "group": [128, 128]}}`;
167-
an unquantized operand is `{"dtype": "bf16"}`. `scale.dtype` is the checkpoint's
168-
scale format. `input` is the dtype an operand arrives in (default bf16): when it
169-
differs from `dtype`, quantization is part of the op; when equal, the operand is
170-
pre-quantized. The runtime format a framework converts to is reported per result.
171-
172-
The `vllm` backend builds a vLLM `ReplicatedLinear` under the checkpoint quant
173-
config those descriptors imply, runs `process_weights_after_loading` and times
174-
`layer(x)`, so vLLM picks the kernel. `metrics.backend_meta` records the chosen
175-
kernel classes, parameter dtypes before and after loading, and the vLLM env.
176-
Emulation-only paths are reported unsupported. AMD enables AITER, as
177-
InferenceX's ROCm launches do.
178-
179-
## MoE
180-
181-
`moe` (`ops/moe.py`) describes one MoE layer from the router GEMM on
182-
normed hidden states to the combined output: shape (`tokens`, `hidden`),
183-
routed `experts` (count, top-k, intermediate size, optional biases / latent width /
184-
zero experts, and gemm operand descriptors `a1`, `w1`, `w2`, `a2`), `router`
185-
(gate dtype, scoring, top-k / grouped / hash selection, bias, renormalize, scale),
186-
`activation`, optional `shared` experts, and the `routing` data distribution.
187-
Execution (expert kernels, dispatch, shared-expert fusion or stream overlap, graphs)
188-
is the backend's choice. The `vllm` backend (`runners/common/vllm/moe.py`) builds
189-
vLLM's router (`GateLinear`), routed experts (`FusedMoEFactory`) and shared-expert
190-
MLP under the quant configs the descriptors imply and times the block; vLLM picks the
191-
expert kernels, shared-expert fusion and streams. A forced expert-load distribution
192-
(`balanced`, `zipf`, `single_hot`) replaces the router's expert choice and keeps its
193-
weights; zero experts are reported unsupported for now.
194-
195-
`testlists/moe_small.json` holds one full-size routed MoE layer per InferenceX
196-
MoE checkpoint scheme (DeepSeek-R1, DeepSeek-V4-Pro/V4.1-Flash, Qwen3.5, Qwen3.8-Flash-Next,
197-
GLM-5.2, Kimi-K3, MiniMax-M3 in their FP8/NVFP4/MXFP4/MXFP8 variants) at `tokens=1`,
198-
plus `tokens=256` layers under each expert-load distribution, 28 cases. Each layer's
199-
weights fit on one GPU.
200-
201-
Every testlist entry says where it comes from: `sources` lists one
202-
`<checkpoint>/<role>` per layer that runs the case, e.g.
203-
`deepseek-ai/DeepSeek-V4-Pro/attn.wq_b` or `zai-org/GLM-5-FP8/mlp`. A checkpoint id is
204-
`org/model`, so the role is what follows the last `/`. A shape shared by several models,
205-
or by several layers of one model, lists every pair, so each role stays tied to its
206-
model. The list is empty for a shape from no model. The loader rejects an entry without
207-
it, and it is carried into each result's `op`; it is not part of the op's identity.
208-
209-
Experimental operator changes are recorded in the adjacent `perf-changelog.yaml`,
210-
separately from the root inference-recipe changelog's config-key schema.

0 commit comments

Comments
 (0)