Skip to content

Commit 4ca968a

Browse files
authored
Add accelerator-proportional worker memory infrastructure (#4754)
* feat: add accelerator-proportional worker memory infrastructure * Simplify worker memory binding and fix resource propagation * Supply hardware inventory to changelog matrix fixture * Preserve recipe node reservations and remove SRT node inference * test: restore explicit recipe reservations in planner fixtures * test: fit new SRT driver fixtures to worker memory binding * fix: skip worker memory binding for video recipes * test: give fixtures added on main explicit worker GPU requests
1 parent aeaa92a commit 4ca968a

48 files changed

Lines changed: 1248 additions & 786 deletions

Some content is hidden

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

‎.github/workflows/benchmark-multinode-tmpl.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ env:
160160
PR_NUMBER: ${{ inputs.pr-number }}
161161
TEST_NAME: ${{ inputs.test-name }}
162162

163+
PREFILL_GPUS_PER_WORKER: ${{ fromJSON(inputs.config).prefill['gpus-per-worker'] }}
163164
PREFILL_NUM_WORKERS: ${{ fromJSON(inputs.config).prefill.num-worker }}
164165
PREFILL_TP: ${{ fromJSON(inputs.config).prefill.tp }}
165166
PREFILL_PP_SIZE: ${{ fromJSON(inputs.config).prefill.pp }}
@@ -170,6 +171,7 @@ env:
170171
PREFILL_EP: ${{ fromJSON(inputs.config).prefill.ep }}
171172
PREFILL_DP_ATTN: ${{ fromJSON(inputs.config).prefill.dp-attn }}
172173

174+
DECODE_GPUS_PER_WORKER: ${{ fromJSON(inputs.config).decode['gpus-per-worker'] }}
173175
DECODE_NUM_WORKERS: ${{ fromJSON(inputs.config).decode.num-worker }}
174176
DECODE_TP: ${{ fromJSON(inputs.config).decode.tp }}
175177
DECODE_PP_SIZE: ${{ fromJSON(inputs.config).decode.pp }}

‎.github/workflows/benchmark-tmpl.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ env:
117117
IMAGE: ${{ fromJSON(inputs.config).image }}
118118
FRAMEWORK: ${{ fromJSON(inputs.config).framework }}
119119
PRECISION: ${{ fromJSON(inputs.config).precision }}
120+
GPU_COUNT: ${{ fromJSON(inputs.config)['gpus-per-worker'] }}
120121
TP: ${{ fromJSON(inputs.config).tp }}
121122
PP_SIZE: ${{ fromJSON(inputs.config).pp }}
122123
DCP_SIZE: ${{ fromJSON(inputs.config).dcp-size }}
@@ -289,10 +290,8 @@ jobs:
289290
export GPU_COUNT="$VIDEO_GPUS"
290291
export CONC_LIST="$VIDEO_CONC_LIST"
291292
echo "CONC_LIST=${CONC_LIST}" >> "$GITHUB_ENV"
292-
else
293-
export GPU_COUNT=$((TP * PP_SIZE * PCP_SIZE))
293+
echo "GPU_COUNT=${GPU_COUNT}" >> "$GITHUB_ENV"
294294
fi
295-
echo "GPU_COUNT=${GPU_COUNT}" >> "$GITHUB_ENV"
296295
297296
echo "RESULT_FILENAME=${RESULT_FILENAME}" >> "$GITHUB_ENV"
298297

‎.github/workflows/profile.yml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ jobs:
220220
IMAGE: ${{ matrix.config.image }}
221221
FRAMEWORK: ${{ matrix.config.framework }}
222222
PRECISION: ${{ matrix.config.precision }}
223+
GPU_COUNT: ${{ matrix.config['gpus-per-worker'] }}
223224
TP: ${{ matrix.config.tp }}
224225
PP_SIZE: ${{ matrix.config.pp }}
225226
DCP_SIZE: ${{ matrix.config.dcp-size }}
@@ -329,8 +330,6 @@ jobs:
329330
export GITHUB_WORKSPACE="$PWD"
330331
echo "INFERENCEX_E2E_ROOT=$PWD" >> "$GITHUB_ENV"
331332
set -eo pipefail
332-
export GPU_COUNT=$((TP * PP_SIZE * PCP_SIZE))
333-
echo "GPU_COUNT=${GPU_COUNT}" >> "$GITHUB_ENV"
334333
ep_val="${EP_SIZE:-1}"
335334
res_name="${EXP_NAME}_${PRECISION}_${FRAMEWORK}_tp${TP}-pp${PP_SIZE}-dcp${DCP_SIZE}-pcp${PCP_SIZE}_ep${ep_val}_dpa_${DP_ATTENTION}_conc${CONC}_${RUNNER_NAME}"
336335
export RESULT_FILENAME="${res_name}"

‎inferencex-e2e/benchmarks/multi_node/srt-slurm-recipes/RECIPES.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ TileRT uses the pinned upstream srt-slurm submodule. Recipes select `roles.prefi
3131

3232
## Schema 2 and master configuration
3333

34-
Recipes use `schema: 2`, `engine`, and `roles`. Each worker role owns its node count, worker count, GPU allocation, environment, and engine arguments. `resources` retains GPU hardware facts. `placement` controls the frontend and benchmark location, `services` describes auxiliary processes, and `dynamo.source` selects the Dynamo package or source revision.
34+
Recipes use `schema: 2`, `engine`, and `roles`. The master config supplies `num-worker` and required `gpus-per-worker`; the adapter writes the rendered roles' `workers` and `gpus`. Recipe fragments retain their `nodes`, engine arguments, environment, and placement settings such as `nodes: colocate`. `resources.gpus_per_node` may restrict packing capacity within the physical node; DRAM shares always use the physical cluster GPU count. `placement` controls the frontend and benchmark location, `services` describes auxiliary processes, and `dynamo.source` selects the Dynamo package or source revision.
3535

3636
| Recipe field | `configs/nvidia-master.yaml` field |
3737
|---|---|
38-
| `roles.prefill.workers` | `prefill.num-worker` |
39-
| `roles.decode.workers` | `decode.num-worker` |
38+
| Rendered `roles.prefill.workers` / `gpus` | `prefill.num-worker` / `gpus-per-worker` |
39+
| Rendered `roles.decode.workers` / `gpus` | `decode.num-worker` / `gpus-per-worker` |
4040
| `roles.prefill.args.tp-size` (SGLang) | `prefill.tp` |
4141
| `roles.prefill.args.ep-size` (SGLang) | `prefill.ep` |
4242
| `roles.prefill.args.enable-dp-attention` | `prefill.dp-attn` |
@@ -45,7 +45,7 @@ Recipes use `schema: 2`, `engine`, and `roles`. Each worker role owns its node c
4545
| Recipe directory, relative to this tree | entry-level `srt-recipe-dir` |
4646
| Recipe file, optionally with a `base`, `override_<name>`, or `zip_override_<name>[<index>]` selector | search-space `srt-recipe`; `eval-srt-recipe` for eval-only real verification |
4747

48-
Keep the recipe and master configuration synchronized. The launcher executes the recipe; the master configuration supplies result labels and scheduling metadata. For aggregate recipes use `roles.agg`; `roles.decode.nodes: colocate` shares prefill nodes and contributes no additional worker nodes to scheduling.
48+
Keep engine parallelism settings consistent with the master resource request. The launcher executes the bound recipe, applies GPU-proportional DRAM limits to its inference-worker steps. For aggregate recipes use `roles.agg`; `roles.decode.nodes: colocate` places both roles in a shared node pool. The scheduler node count reads the recipe’s existing worker node reservations and includes any auxiliary nodes.
4949

5050
All referenced recipes must be checked in: srt-slurm 2 ships curated examples instead of the historical `recipes/` archive. The initial migration restores 204 previously external recipes and two still-referenced AgentX recipes from InferenceX history. Master-config paths follow the layout above; existing override selectors are preserved.
5151

‎inferencex-e2e/configs/CONFIGS.md‎

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ entry-name:
2424
- isl: int
2525
osl: int
2626
search-space:
27-
- { tp: int, conc-start: int, conc-end: int, srt-recipe: string }
27+
- { gpus-per-worker: int, tp: int, conc-start: int, conc-end: int, srt-recipe: string }
2828
# Optionally, specify pipeline/expert/data-attention/context parallelism.
29-
- { tp: int, pp: int, ep: int, dp-attn: bool, dcp-size: int, pcp-size: int, conc-start: int, conc-end: int }
29+
- { gpus-per-worker: int, tp: int, pp: int, ep: int, dp-attn: bool, dcp-size: int, pcp-size: int, conc-start: int, conc-end: int }
3030
# Optionally, declare router metadata.
31-
- tp: int
31+
- gpus-per-worker: int
32+
tp: int
3233
router: { name: string, version: string }
3334
conc-start: int
3435
conc-end: int
3536
- ...
3637
- ...
3738
agentic-coding: # optional
3839
- search-space:
39-
- tp: int
40+
- gpus-per-worker: int
41+
tp: int
4042
kv-offloading: dram
4143
kv-offload-backend: { name: string, version: string } # version optional
4244
conc-start: int
@@ -59,6 +61,7 @@ scenarios:
5961
prefill:
6062
hardware: b200
6163
num-worker: 1
64+
gpus-per-worker: 16
6265
tp: 8
6366
pp: 1
6467
dcp-size: 1
@@ -68,6 +71,7 @@ scenarios:
6871
decode:
6972
hardware: h100
7073
num-worker: 2
74+
gpus-per-worker: 8
7175
tp: 8
7276
pp: 1
7377
dcp-size: 2
@@ -89,6 +93,13 @@ The below list describes what each field is:
8993
fleet.
9094
- `precision`: The precision to run the benchmark. Launcher workload policy rows may also match on it.
9195
- `framework`: The framework (serving runtime) to serve the benchmark, e.g., `vllm`, `sglang`, `trt`.
96+
- `gpus-per-worker`: Required positive integer on each single-node search-space entry or each
97+
`worker`, `prefill`, and `decode` block. It is the total GPU allocation of one logical
98+
inference worker, including any data parallel ranks. Worker counts and GPU allocations
99+
are copied from the master config into SRT `workers` and `gpus`. Recipe roles retain
100+
their node counts and engine settings. For example, DEP16 on HGX8 uses a recipe with
101+
two nodes and a master request for 16 GPUs per worker. Memory limits use the GPUs
102+
assigned to each worker step; all steps of a role must have the same limit.
92103
- `multinode`: Required. `true` selects the multinode schema with `prefill`/`decode` or `worker` blocks, and `false` the single-node schema with `tp` entries.
93104
- `disagg`: Enables disaggregated serving and may only be `true` when
94105
`multinode` is also `true`.
@@ -113,9 +124,9 @@ The below list describes what each field is:
113124
- (Optional) `kv-p2p-transfer`: Non-empty name of the engine used to move KV state between workers. It is valid only for `multinode: true` configs and does not carry version metadata.
114125
- (Optional) `pp`: Pipeline parallelism level. Default is 1. It must be a positive integer.
115126
- (Optional) `dcp-size`: Decode context-parallel size. Default is 1. It must be a positive divisor of `tp`. DCP reuses the TP GPUs.
116-
- (Optional) `pcp-size`: Prefill context-parallel size. Default is 1. A topology consumes `tp * pp * pcp-size` GPUs per worker. DCP does not add GPUs.
127+
- (Optional) `pcp-size`: Prefill context-parallel size. Default is 1. These are engine parallelism settings; resource allocation comes from `gpus-per-worker`. DCP does not add GPUs.
117128
- For single-node entries, set `pp`, `dcp-size`, and `pcp-size` directly in the search-space entry.
118-
- For multinode entries, set them independently inside each `prefill` and `decode` worker block. A worker pool allocates `num-worker * tp * pp * pcp-size` GPUs.
129+
- For multinode entries, set them independently inside each `prefill` and `decode` worker block. A worker pool allocates `num-worker * gpus-per-worker` GPUs.
119130
- `agentic-coding`: Agentic trace replay benchmarks using real conversation traces. Each entry has:
120131
- `search-space`: Same structure as `fixed-seq-len` search-space entries, plus `kv-offloading` (`none` or `dram`, required for single-node entries) and the optional `kv-offload-backend`.
121132

@@ -150,7 +161,7 @@ jobs to 3600 seconds. Reusable workflow callers may override the `duration`
150161
input.
151162

152163
Notes:
153-
- The fields above are the common ones, not the full schema. The Pydantic models in [`infx/matrix/validation.py`](../infx/matrix/validation.py) are the authoritative contract; they also accept fields such as `spec-decoding`, `num-nodes`, `require-power` and `power`, and they reject any field they do not define, which fails matrix generation.
164+
- The fields above are the common ones, not the full schema. The Pydantic models in [`infx/matrix/validation.py`](../infx/matrix/validation.py) are the authoritative contract; they also accept fields such as `spec-decoding`, `require-power` and `power`, and they reject any field they do not define, which fails matrix generation.
154165
- Every multinode benchmark point on a cluster with a GPU exporter measures GPU power (DCGM where the cluster sets `srt-slurm.power-exporter-port`, its `default_gpu_exporter` elsewhere), and CPU power where the cluster declares a `cpu-power-exporter`, unless its recipe runs etcd and NATS on a dedicated node; it keeps its result when telemetry fails. A search-space entry with `power: true` makes failed telemetry or invalid AgentX power fail the point, and is rejected on a cluster without a GPU exporter.
155166
- A multinode entry with `cpu-power: true` beside `power: true` also measures CPU power: its rows carry `cpu-power: true` and the launcher binds the cluster's `cpu-power-exporter` record beside the GPU telemetry block. Native single-node points measure CPU power by default on a cluster that declares a `cpu-power-exporter`; a single-node fixed-sequence entry sets `cpu-power: true` alone to count a missing CPU leg as invalid.
156167
- srt-slurm entries require `srt-recipe-dir`. Every row requires `srt-recipe: <file>[:<selector>]` under it (selector: `base`, `override_<name>` or `zip_override_<name>[<i>]`). Multinode rows may add `eval-srt-recipe`. Validation rejects missing files or variants, and `CONFIG_FILE`/`EVAL_CONFIG_FILE` settings. Only `llmd-vllm` keeps `CONFIG_FILE`. Generated rows carry the path from `inferencex-e2e/`.
@@ -162,7 +173,7 @@ Multi-node prefill workers may set `dwdp-size` to the number of ranks in a
162173
distributed weight-data parallel group. It defaults to 1 (disabled). For DWDP,
163174
`tp`, `ep`, `pp`, `dcp-size`, and `pcp-size` must all be 1 and `dp-attn` must be
164175
false. `num-worker` counts groups, not ranks: two workers with `dwdp-size: 8`
165-
allocate 16 prefill GPUs. Decode workers cannot enable DWDP.
176+
must also declare `gpus-per-worker: 8`, allocating 16 prefill GPUs. Decode workers cannot enable DWDP.
166177

167178
The native TensorRT-LLM recipe must enable the corresponding DWDP mode and match
168179
the declared group layout. This field records topology and sizes allocations;
@@ -209,11 +220,28 @@ schema; unknown keys fail.
209220
`python -m infx.launch` resolves its cluster from `RUNNER_NAME` this way.
210221
- Matrix generation reads `gpus-per-node` from the cluster a master config's
211222
`cluster:<id>` label names; broad SKU labels use the GPU family when its clusters agree.
212-
Agentic master configs must use a `cluster:<id>` label. Servers must tile their nodes,
213-
and per-worker `hardware` is not supported.
223+
Agentic master configs must use a `cluster:<id>` label; per-worker `hardware` is not supported.
214224
- `available-cpu-dram-mib` is the host DRAM a benchmark job can use on a node: the lower of
215225
Slurm's `RealMemory - MemSpecLimit` and `MemTotal` less 16 GiB for the OS, over the
216-
cluster's GPU nodes.
226+
cluster's GPU nodes. Inference workers automatically receive
227+
`available-cpu-dram-mib * worker GPUs on the node / gpus-per-node` MiB through
228+
`roles.<role>.srun_options.mem`. Four GPUs on an eight-GPU node receive half the node's
229+
available DRAM, including when the job has exclusive access. A worker spanning whole
230+
nodes receives the full available amount on each node; colocated roles receive their
231+
own shares. InferenceX calculates the budget from the master GPU request and cluster
232+
capacity; the adapter maps it to the launcher's steps. Separate per-GPU processes split
233+
the worker budget, while MPI ranks sharing a step share its node-local cap.
234+
The proportional policy is scheduler independent; the Slurm adapter applies
235+
it to inference-worker steps. Frontends, benchmark clients, telemetry, and services retain
236+
their existing step memory settings. Native multi-node jobs and exclusive single-node jobs
237+
request all node memory with `--mem=0` so scheduler defaults cannot undercut worker ceilings;
238+
shared single-node jobs request their GPUs' proportional share. These are worker ceilings,
239+
not dedicated reservations: workers and helpers still share the enclosing job's memory budget.
240+
Slurm must be configured to enforce job-step memory limits.
241+
Native engine cache sizes remain recipe settings: the offload pool and all other server
242+
allocations must fit within the worker's limit. The memory allocation does not reserve
243+
the entire amount for KV cache. Results record the total assigned worker capacity in
244+
`allocated_cpu_dram_gb`.
217245
- `env` is the workload environment of every launch on the cluster. Like
218246
`slurm.srt-slurm.env`, it overrides the runner's own environment but never a name the
219247
point's additional-settings set. Values cannot contain commas: Slurm hands them to jobs

‎inferencex-e2e/infx/launch/drivers/srt/__init__.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
staged_recipe,
3939
)
4040
from infx.launch.drivers.srt.run import SrtRun, require, slurm_backend
41+
from infx.launch.memory import gpu_share_mib
4142
from infx.launch.request import (
4243
BATCH_REENTRY_ENV,
4344
MultiNodeRequest,
@@ -182,6 +183,13 @@ def write_single_node_job(
182183
**fields: Any,
183184
) -> None:
184185
"""Write the single-node srtslurm.yaml; ``fields`` are the job's own SrtJob inputs."""
186+
job_mib = (
187+
0
188+
if run.srt.single_node_exclusive
189+
else gpu_share_mib(
190+
run.cluster.available_cpu_dram_mib, request.gpu_count, run.cluster.gpus_per_node
191+
)
192+
)
185193
job_config = config.SrtJob(
186194
srtctl_root=checkout.root,
187195
workspace=run.workspace,
@@ -190,6 +198,7 @@ def write_single_node_job(
190198
container=run.backend.stage_image(request.image, single_node=True).reference,
191199
single_node=True,
192200
account=run.account,
201+
mem_mib=job_mib,
193202
**fields,
194203
)
195204
config.create_volume_mounts(run)

‎inferencex-e2e/infx/launch/drivers/srt/config.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SrtJob:
6262
mounts: Sequence[tuple[str, str]] = ()
6363
single_node: bool = False
6464
account: str | None = None
65-
mem_mib: int | None = None
65+
mem_mib: int | None = 0
6666
cpu_power_source: CpuPowerSource | None = None
6767

6868

@@ -201,6 +201,8 @@ def srun_options(settings: SlurmSettings) -> str | None:
201201
options = {}
202202
for arg in settings.srun_args:
203203
name, _, value = arg.removeprefix("--").partition("=")
204+
if name in {"mem", "mem-per-cpu", "mem-per-gpu"}:
205+
raise LaunchError("worker memory is derived from the cluster's available DRAM")
204206
options[name] = value
205207
return json.dumps(options) if options else None
206208

‎inferencex-e2e/infx/launch/drivers/srt/submit.py‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def bind_point(
111111
"""
112112
prepare = [
113113
str(checkout.venv / "bin/python"), "-m", "infx.srt_slurm.single_node", "prepare",
114-
f"{run.workspace}/{run.request.srt_recipe}", str(arguments), *_fabric(run),
114+
f"{run.workspace}/{run.request.srt_recipe}", str(arguments), *_fabric(run), *_memory(run),
115115
] # fmt: skip
116116
if cpu_power_source is not None:
117117
prepare += ["--cpu-power-source", cpu_power_source]
@@ -154,7 +154,7 @@ def bind_recipe(
154154
bind += ["--cpu-power-source", cpu_power_source]
155155
for name, value in client_env.items():
156156
bind += ["--client-env", f"{name}={value}"]
157-
bind += _fabric(run)
157+
bind += [*_fabric(run), *_memory(run)]
158158
return _bind(run, bind, checkout.root)
159159

160160

@@ -188,6 +188,19 @@ def _fabric(run: SrtRun) -> list[str]:
188188
return ["--fabric", json.dumps(run.srt.fabric.rendered())]
189189

190190

191+
def _memory(run: SrtRun) -> list[str]:
192+
"""Pass measured node capacity to the binder that resolves worker placement."""
193+
available = run.cluster.available_cpu_dram_mib
194+
if available is None:
195+
raise LaunchError(f"cluster {run.cluster.id!r} must declare available-cpu-dram-mib")
196+
return [
197+
"--available-memory-mib",
198+
str(available),
199+
"--gpus-per-node",
200+
str(run.cluster.gpus_per_node),
201+
]
202+
203+
191204
def apply(
192205
run: SrtRun,
193206
checkout: Checkout,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import annotations
2+
3+
4+
def gpu_share_mib(available_mib: int, gpus: int, gpus_per_node: int) -> int:
5+
"""Return the node's available DRAM share for its requested accelerators, in MiB."""
6+
for name, value in (
7+
("available-cpu-dram-mib", available_mib),
8+
("gpus-per-node", gpus_per_node),
9+
("requested GPUs", gpus),
10+
):
11+
if isinstance(value, bool) or not isinstance(value, int) or value <= 0:
12+
raise ValueError(f"{name} must be a positive integer for worker memory limits")
13+
if gpus > gpus_per_node:
14+
raise ValueError("Requested GPUs exceed the physical node's accelerator count")
15+
share = available_mib * gpus // gpus_per_node
16+
if share <= 0:
17+
raise ValueError("Worker GPU share is less than one MiB")
18+
return share

0 commit comments

Comments
 (0)