Repository navigation
feat: size each engine with one layout function - #4924
Closed
mikasenghaas wants to merge 1 commit into
Closed
mikasenghaas wants to merge 1 commit into
mikasenghaas wants to merge 1 commit into
Conversation
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>
This was referenced Dec 3, 2026
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_disaggregatedandVllmConfig.auto_setup_api_server_count. They found the user's own values withmodel_fields_setor 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)incomponents/engine/layout.py, derives the layout from the GPUs that the launcher gives the engine.data_parallel_sizeandapi_server_countdefault to"auto", so the value itself tells whether the user set it. Each entrypoint callsEngineSection.fit_engines(...)with its shape:fit_engines(num_infer_gpus, pin_local=False)fit_engines(gpus_per_node)fit_engines(gpus_per_node, nodes=infer_nodes_per_replica)fit_engines(gpus_per_node)inference, sft multi-node, standaloneEngineConfigfit_engines()auto→ 1data_parallel_sizeordata_parallel_size_localmust equal the computed value, else the config raises. The node GPUs must be divisible by TP.api_server_countstays. With LoRA it is 1 (a vLLM limit), and headless it is 0.reject_explicit_data_parallel_sizeis removed.model_fields_setcheck (client.base_url) and the typed vLLM fields (next PR).Breaking
data_parallel_sizeordata_parallel_size_local. Migration: remove the key, or set it to the size that fills the node.data_parallel_size. It is derived. An explicit value that matches still works.api_server_countis kept. Before, a single-node engine raised a value below DP to DP, and P/D replaced an explicit1with the node's DP. No checked-in config sets it.VllmConfig().data_parallel_sizeand.api_server_countare"auto"until a layout resolves them. Every built engine JSON holds integers. Code that reads a bareVllmConfigmust build anEngineConfigor callengine_layout.recipes/intellect-3.1,recipes/minimax-m2.5RL h200) now writesdata_parallel_size_local = 1, notnull. DP is 1, so vLLM andapply_multi_node_dp_env(dp_local or dp) behave the same.Verification
On e073486, on macOS without torch or vllm:
data_parallel_size_localnull → 1 in the two recipes above (engine.jsonandrl.json).test_rl_engine_layoutchecks 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.test_rl_fills_inference_gpus_…andtest_engine_layout_rejects_a_local_size_…fail: did not raisetest_engine_layout_rejects_gpus_that_tensor_parallelism_does_not_dividefailstest_rl_engine_layout[…trainer4]fails:(4, None, 4) != (4, None, 1)api_server_countkepttest_pd_role_overrides_pass_the_vllm_validatorstest_multi_node_auto_inference_parallelismtest_rl_engine_layout[…layout2]fails:(4, 4, 4) != (8, 4, 4)EngineConfiglayouttest_a_standalone_engine_runs_the_sizes_of_its_configfails:('auto', None, 'auto')InferenceConfiglayoutinferenceround tripMerge 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_layouthelper inlayout.py, wired throughEngineSection.fit_engines().VllmConfignow defaultsdata_parallel_sizeandapi_server_countto"auto"so unset values mean “fill from deployment.”set_engine_layoutwrites the computedEngineLayout(global DP, local DP, API servers).reject_explicit_data_parallel_sizeis 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).EngineConfigresolves layout on validation when no launcher sizes the engine.VllmConfigonly forces API server count for headless (0) and LoRA (1); auto sizing moved toengine_layout.Tests add
test_rl_engine_layoutand 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.