Skip to content

feat: size each engine with one layout function - #4924

Closed
mikasenghaas wants to merge 1 commit into
feat/validate-oncefrom
feat/engine-layout
Closed

mikasenghaas wants to merge 1 commit into
feat/validate-oncefrom
feat/engine-layout

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Why. Six code paths sized the engine's data parallelism and API servers, each with its own rules: RLConfig.auto_setup_deployment (single node, multi-node EP, multi-node non-EP), SupervisedConfig, InferenceSection.auto_setup_disaggregated and VllmConfig.auto_setup_api_server_count. They found the user's own values with model_fields_set or by comparing with the class default (data_parallel_size == 1, api_server_count == 1). The paths did not agree: an explicit size that does not fill the GPUs raised on a single node, but on multi-node and P/D the launcher kept it or replaced it without a warning. A resolved config that is parsed again also lost the "user set it" information.

Idea. One function, engine_layout(vllm, gpus_per_node, nodes, pin_local) in components/engine/layout.py, derives the layout from the GPUs that the launcher gives the engine. data_parallel_size and api_server_count default to "auto", so the value itself tells whether the user set it. Each entrypoint calls EngineSection.fit_engines(...) with its shape:

Shape Call DP DP local API servers
rl / sft, single node fit_engines(num_infer_gpus, pin_local=False) GPUs / TP as set DP
rl, multi-node fit_engines(gpus_per_node) node GPUs / TP node GPUs / TP DP local
rl, multi-node EP fit_engines(gpus_per_node, nodes=infer_nodes_per_replica) nodes × node GPUs / TP node GPUs / TP DP local
P/D role engine fit_engines(gpus_per_node) node GPUs / TP node GPUs / TP DP local
inference, sft multi-node, standalone EngineConfig fit_engines() auto → 1 as set DP local or DP
  • An explicit data_parallel_size or data_parallel_size_local must equal the computed value, else the config raises. The node GPUs must be divisible by TP.
  • An explicit api_server_count stays. With LoRA it is 1 (a vLLM limit), and headless it is 0.
  • reject_explicit_data_parallel_size is removed.
  • Out of scope: the remaining model_fields_set check (client.base_url) and the typed vLLM fields (next PR).

Breaking

  • An explicit DP size that does not fill the GPUs raises on multi-node and P/D. Before, multi-node non-EP and P/D kept an explicit data_parallel_size or data_parallel_size_local. Migration: remove the key, or set it to the size that fills the node.
  • Multi-node EP no longer requires data_parallel_size. It is derived. An explicit value that matches still works.
  • An explicit api_server_count is kept. Before, a single-node engine raised a value below DP to DP, and P/D replaced an explicit 1 with the node's DP. No checked-in config sets it.
  • VllmConfig().data_parallel_size and .api_server_count are "auto" until a layout resolves them. Every built engine JSON holds integers. Code that reads a bare VllmConfig must build an EngineConfig or call engine_layout.
  • Multi-node non-EP at TP = node GPUs (recipes/intellect-3.1, recipes/minimax-m2.5 RL h200) now writes data_parallel_size_local = 1, not null. DP is 1, so vLLM and apply_multi_node_dp_env (dp_local or dp) behave the same.

Verification

On e073486, on macOS without torch or vllm:

  • Launcher output. I dry-ran the 103 launcher cases against feat: validate each built config once with all its values #4923 (99c0d44). The only difference is the data_parallel_size_local null → 1 in the two recipes above (engine.json and rl.json).
  • Round trip. Every resolved entrypoint dump parses again to the same components (17 cases).
  • Tests. The config, launch, router, resume, client, dynamo and algorithm tests: 799 passed. test_rl_engine_layout checks the section and the built engine for six shapes: single node, multi-node, multi-node EP, LoRA set on vLLM, LoRA set by the trainer, and an explicit API server count.
Change removed Result
explicit size check test_rl_fills_inference_gpus_… and test_engine_layout_rejects_a_local_size_… fail: did not raise
TP divisibility check test_engine_layout_rejects_gpus_that_tensor_parallelism_does_not_divide fails
LoRA → 1 API server in the layout test_rl_engine_layout[…trainer4] fails: (4, None, 4) != (4, None, 1)
explicit api_server_count kept 3 tests fail, incl. test_pd_role_overrides_pass_the_vllm_validators
local size pinned per node 4 tests fail, incl. test_multi_node_auto_inference_parallelism
EP engine spans the replica nodes test_rl_engine_layout[…layout2] fails: (4, 4, 4) != (8, 4, 4)
standalone EngineConfig layout test_a_standalone_engine_runs_the_sizes_of_its_config fails: ('auto', None, 'auto')
InferenceConfig layout 7 tests fail, incl. the inference round trip

Merge order

Stacked on #4923 (#4899 → #4905 → #4909 → #4919 → #4921 → #4922 → #4923 → this PR).

🤖 Generated with Claude Code


Note

Medium Risk
Changes how inference DP/API server counts are derived and validated across RL, SFT, and inference entrypoints; explicit sizes that no longer match allocated GPUs now fail on multi-node and P/D (breaking for some configs).

Overview
Unifies six scattered code paths that sized inference engines' data parallelism and API server counts into a single engine_layout helper in layout.py, wired through EngineSection.fit_engines().

VllmConfig now defaults data_parallel_size and api_server_count to "auto" so unset values mean “fill from deployment.” set_engine_layout writes the computed EngineLayout (global DP, local DP, API servers). reject_explicit_data_parallel_size is removed; explicit DP sizes that don’t match the GPUs the launcher assigns raise consistently (including multi-node and P/D).

RL, SFT, and inference entrypoints replace inline DP/API math with fit_engines(...) (single-node uses total infer GPUs; multi-node EP spans replica nodes; per-node engines pin local DP). EngineConfig resolves layout on validation when no launcher sizes the engine. VllmConfig only forces API server count for headless (0) and LoRA (1); auto sizing moved to engine_layout.

Tests add test_rl_engine_layout and related validation cases; error message for conflicting explicit DP on single-node is updated.

Reviewed by Cursor Bugbot for commit e073486. Bugbot is set up for automated code reviews on this repo. Configure here.

The rl, sft and inference entrypoints each sized the engine's data
parallelism and API servers in their own way, with "did the user set
it" checks on model_fields_set. engine_layout now derives the sizes
from the GPUs the launcher gives the engine, and data_parallel_size
and api_server_count default to "auto".

An explicit size that does not fill the GPUs now raises in every
shape, and multi-node expert parallelism derives its size instead of
requiring it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mikasenghaas

Copy link
Copy Markdown
Member Author

Folded into #4928. The config stack is now four PRs, one per motivation: #4899 (public vs internal configs) → #4909 (a complete config per process) → #4919 (package layout) → #4928 (resolve each value in one place).

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