Repository navigation
feat: resolve each config value in one place - #4928
Merged
Merged
Conversation
This was referenced Dec 3, 2026
The trainer and the orchestrator always share max_steps, resume, rollout_transport, monitors and the checkpoint policy. rl took each of them at the top level and per component, copied the top-level value into the raw input, and checked the copies for equality. Keep these fields only at the top level of rl and let the builders pass them into trainer.json and orchestrator.json. [ckpt] now holds the fields of both sides, and each builder narrows it to its own. model.name, seq_len, tokenizer and log can differ per component, so they keep their top-level default and per-component override. The old propagation copied only monitors.file.path, so other [monitors.file] fields never reached the processes. They do now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Many defaults applied only when the user left a field unset, read from model_fields_set. A resolved config (configs/<entrypoint>.json, or a pod's CLI flags) counts every field as set, so its second parse could build other components than the first: - A P/D prefill engine under bidirectional KV transfer lost its recompute policy, since the dumped None counted as set. - An SFT online-eval engine gained vllm.tokenizer on the second parse. Derive these defaults from the value instead: None (or "auto" for num_reserved_sms) means "derive it". build_component_config then validates plainly and no longer carries the section's fields_set. A test parses every entrypoint's resolved config again and compares the components. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The builders patched engines and routers after validation: P/D role ports, DP sizes, env vars and vLLM overrides, the admin-token flag, and the router's bidirectional TTL. model_copy(update=...) also changed train samplings without validation. A P/D override such as max-lora-rank = 24 thus reached the engine unrounded, and LoRA did not pin api_server_count to 1. Compute every value first and validate once: the role builder and engine_config(require_admin_token=...) pass the values into build_component_config, router_config passes the TTL, and copy_validated replaces model_copy. Reloading a built engine or router now changes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
prime-rl read nine vLLM pass-through args with getattr or model_extra, so a typo or a wrong type reached vLLM unchecked and every reader needed a fallback. They are now typed VllmConfig fields. A None value is still left out of the vLLM namespace, so vLLM keeps its default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
engine_config(role) writes each role's all2all backend, decode compile config, vLLM overrides and env vars into engine-<role>.json, and the P/D sbatch scripts applied the same settings again on every rank. The two copies could drift. The scripts now pass only the host-dependent values (data parallel rank and address, ports, GPUs), and the engine reads everything else from its JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mikasenghaas
force-pushed
the
feat/resolve-once
branch
from
December 3, 2026 03:36
5456cb0 to
04ac592
Compare
The rl and sft validators wrote what the run implies (LoRA, router replay, NVFP4 experts, dummy load, sampling masks, engine layout, draft swaps, score-centering logprobs, client URLs, metrics roles) into the user's sections. Results depended on validator order, and rl.json held derived values instead of what the user wrote. The validators now only check. resolved_inference() and orchestrator_config() / online_eval_config() derive these values when they build the component configs. Checks that span processes (NVFP4 experts, speculative sampler logprobs) run on the built configs, so a setting from a P/D role override is checked like one on [inference]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mikasenghaas
marked this pull request as ready for review
December 3, 2026 03:46
Drop the redundant run-name validator, correct docstrings that still describe per-rank inference processes, one-node sft inference, the pool checkpoint directory and the weight broadcast fallbacks, and test live updates against the orchestrator component config. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Find a default client base_url by its value, not model_fields_set, so a resolved config with a non-default inference port re-parses to the same components. - Reject an api_server_count below the local data parallel ranks under nccl or modelexpress weight broadcast: vLLM then starts too few workers, and the weight transfer waits forever. - Copy every wired config in build_component_config, so the trainer and the orchestrator no longer share one monitors, resume or rollout_transport instance. - Name the component and the field path when a built config fails. - Run a one-node multi_node inference deployment per rank with engine, as inference.json holds only engine fields. - Resolve the run name in every validator that reads it, log only the configs a single-node SLURM launch writes, drop get_ckpt_base, and fix the README rule on run-level fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[ckpt] and [monitors] of rl hold what the trainer and the orchestrator must agree on. A setting that only one of them reads goes in that component's section, so each field still has one place: - [trainer.ckpt]: async_save, remote, skip_dataloader, skip_optimizer - [orchestrator.ckpt]: rollouts, rollouts_save_timeout - [orchestrator.monitors.file]: trace_sample, live The builders merge both parts, so every component JSON is unchanged. A component ckpt section without [ckpt] raises, as the two processes checkpoint each step together. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
skpulipaka26
approved these changes
Dec 3, 2026
skpulipaka26
left a comment
Contributor
There was a problem hiding this comment.
LGTM from the Model Factory / operator side. Prod and develop are pinned on v0.11.1.dev123 so no import-path shims are needed here; we will follow up with dual-compatible updates in model-factory-iac, platform, and prime CLI before bumping RL_FFT_DEFAULT_IMAGE_TAG.
cabrinha
approved these changes
Dec 3, 2026
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
…#4899) ## Summary **Why.** rl and sft compose several processes, and they nested each process's whole config. Users could set keys that the launcher always fills or that no process reads, e.g. `trainer.output_dir` next to the top-level `output_dir`, or `inference.slurm` next to `[slurm]`. Some of these values were silently overwritten. A single-node `orchestrator.env_worker_pool_replicas` hung the run. `uv run inference` had the same mix: it was both the public entrypoint and the bare engine that each SLURM rank ran. **Idea.** Separate what users write from what a process reads, in the package and in the classes: ``` configs/entrypoints/ RLConfig, SFTConfig, PretrainConfig, EvalConfig, InferenceConfig (EntrypointConfig) configs/components/ TrainerConfig, OrchestratorConfig, EngineConfig, RouterConfig, ... (ComponentConfig) section (user writes) component config (process reads) filled by the entrypoint TrainerSection TrainerConfig + output_dir, weight_broadcast OrchestratorSection OrchestratorConfig + output_dir, weight_broadcast, env_worker_pool_replicas EngineSection EngineConfig + weight_broadcast ``` An entrypoint nests only sections. A component config extends its section with the launcher-filled fields, so the two cannot drift. A builder per process (`RLConfig.trainer_config()`, `orchestrator_config()`, ...) validates the component config from the section plus the entrypoint's values. Example: `TrainerConfig.output_dir` comes from `RLConfig.output_dir / run.name`. - `EngineConfig` is what one engine process reads. A new `engine` script serves it without a router, and the SLURM ranks run `uv run engine` with engine-only JSON. `InferenceConfig` stays the public entrypoint. - Keys that no process reads go: the sft `[eval]` run fields, `log.interval` and `log.log_data` where no loop reads them, and the rl shared `[monitors.wandb] offline`. `inference.backend_port` follows `server.port + 100` unless set. - `test_config_layout` checks that each script parses the config of its role, and that components never import entrypoints. The package README states the config rules. - Next in the stack: every process gets its own complete JSON (#4909), the package layout (#4919), and resolving each value in one place (#4928). ## Breaking Remove these keys. Each now fails as an unknown key: - rl: `trainer.output_dir`, `trainer.weight_broadcast`, `orchestrator.output_dir`, `orchestrator.weight_broadcast` (set `output_dir`, `run.name` and `[weight_broadcast]`), `orchestrator.env_worker_pool_replicas`, `inference.weight_broadcast`, `inference.slurm` (set `[slurm]`), `inference.output_dir`, `inference.dry_run`, `inference.use_pd_kv_transfer`, `inference.pd_decode_blocks_ttl_s`, `inference.pd_spill_to_store`, `[monitors.wandb] offline` (set it on `trainer` and `orchestrator`). - sft: `inference.weight_broadcast`, `inference.deployment`, `inference.slurm`, `inference.output_dir`, `inference.dry_run`, the three `inference.pd_*` keys, and `[eval]` `model`, `weight_broadcast`, `broadcasts_dir`, `max_steps`, `resume_step`, `output_dir`, `log`, `monitors`. - All entrypoints: `log.interval` outside the orchestrator, eval and online-eval logs; `log.log_data` outside the sft trainer log. These values now fail with an error that names the fix: an explicit single-node `inference.vllm.data_parallel_size` that does not fill `deployment.num_infer_gpus`, and `inference.vllm.max_lora_rank` below the LoRA rank. Import paths change, with no aliases: | Old | New | |---|---| | `prime_rl.configs.{rl,sft,pretrain,supervised,eval}` | `prime_rl.configs.entrypoints.{...}` | | `prime_rl.configs.{trainer,orchestrator,env_worker_pool,router}` | `prime_rl.configs.components.{...}` | | `prime_rl.configs.inference.InferenceConfig` | `prime_rl.configs.entrypoints.inference` | | `prime_rl.configs.inference.*` (engine blocks), `setup_dummy_load` | `prime_rl.configs.components.engine` | | `prime_rl.configs.diff` | `prime_rl.utils.diff` | | `prime_rl.entrypoints.{trainer,orchestrator,env_worker_pool,router}` | `prime_rl.components.{...}` | | `apply_multi_node_dp_env` (`prime_rl.entrypoints.inference`) | `prime_rl.components.engine` | | `RouterEntrypointConfig` / `RouterConfig` (backend union) | `RouterConfig` / `RouterBackendConfig` | Python API: `RLConfig.trainer`, `.orchestrator` and `.inference` are sections. Call the builder for a filled field, e.g. `config.trainer_config().output_dir`. Outside prime-rl, the `prime` CLI's schema worker and the k8s operator's engine render (`run_engine.py`) import the old paths. PrimeIntellect-ai/prime#1284 reads both. #4909 lists every launcher break of the stack. - **Custom SLURM templates.** The multi-node and P/D ranks now run `uv run engine @ "$CONFIG_PATH"` on engine-only JSON, which has no `router` key. A custom `slurm.template_path` copied from `main` that still runs `uv run inference @ "$CONFIG_PATH"` on each rank fails without an error: `InferenceConfig` then defaults to a vllm-router, so every rank starts its own router on `server.port` and moves its engine to `backend_port`. Migration: run `uv run engine` on the ranks, as `_launch_rank.sh.j2` does. ## Verification On 2569ff7, on macOS without torch or vllm: - **Launcher output.** I dry-ran the `rl`, `sft` and `inference` launchers for 103 cases: every checked-in config that loads, plus synthetic P/D, Mooncake, multi-node, single-node SLURM and sft online-eval cases. Against `main` (47f3ec3), every value a process reads is unchanged. The JSONs only lose the removed keys above (`log.interval`/`log.log_data`, `router`/`backend_port` in the per-rank files, the launcher-filled section fields in `rl.json` and `sft.json`). The sbatch scripts start the ranks with `uv run engine` in place of `uv run inference`. - **Engine ≡ routerless inference.** `test_engine_serves_per_rank_configs_like_a_routerless_inference` parses the multi-node and P/D per-rank JSON under `EngineConfig` and under `InferenceConfig --router None`, which the ranks ran before. Both give the same vLLM namespace, including `kv_transfer_config`. - **Tests.** The config, launch, router, resume, client, dynamo and algorithm tests: 879 passed. | Change removed | Result | | --- | --- | | `output_dir` back on `TrainerSection` | `test_entrypoints_reject_component_fields_their_launcher_fills`: `DID NOT RAISE` | | `env_worker_pool_replicas` back on `OrchestratorSection` | `DID NOT RAISE` (2 cases) | | `offline` back on the rl shared `[monitors.wandb]` | `DID NOT RAISE` | | engine-only fields in the per-rank JSON | `test_engine_serves_per_rank_configs_…`: `router: Extra inputs are not permitted` | | a component imports an entrypoint | `test_config_layout`: `components/router.py imports prime_rl.configs.entrypoints.rl` | These rows ran before the restack, on earlier commits of this branch and of the closed #4905. This PR keeps the code under test unchanged. No GPU run. ## Merge order Base of the stack: this PR → #4909 → #4919 → #4928. Rebase each onto `main` after a squash merge. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **High Risk** > This is a breaking public import and CLI layout change across the whole repo; external tools (e.g. Prime CLI, k8s operator) must adopt the new paths before merge/deploy. > > **Overview** > Reorganizes **`prime_rl.configs`** by role: **`entrypoints/`** for user-written configs (`RLConfig`, `SFTConfig`, `EvalConfig`, `InferenceConfig`, …) and **`components/`** for per-process configs (`TrainerConfig`, `OrchestratorConfig`, `RouterConfig`, `EnvWorkerPoolConfig`, online eval). Adds **`EntrypointConfig`** and **`ComponentConfig`** base markers; component configs now inherit **`ComponentConfig`**. > > Splits the former flat layout: **`EvalConfig`** moves to **`entrypoints/eval`**; inference is split into **`entrypoints/inference`** (public **`InferenceConfig`**) plus **`components/engine`** (vLLM, deployment, KV offload) and **`components/router`** (router backends). **`Live` / diff utilities** move from **`prime_rl.configs.diff`** to **`prime_rl.utils.diff`**. **`RouterEntrypointConfig`** becomes **`RouterConfig`**; the old router backend union is **`RouterBackendConfig`**. > > **`uv run`** script entrypoints for **`trainer`**, **`orchestrator`**, **`router`**, and **`env-worker-pool`** now target **`prime_rl.components.*`** instead of **`prime_rl.entrypoints.*`**. CI slim-import checks, docs, and skills are updated to the new import paths. **All old `prime_rl.configs.{rl,trainer,inference,...}` import paths are removed** (no aliases). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ab4c7ee. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
## Summary **Why.** After #4899, each process has a component config, but each launcher (local, SLURM, the k8s operator) still assembled the per-process JSON its own way: excludes, renames, and patches after the build. So the JSON a process read depended on who launched it. Some processes had no config of their own: the router read the engine's `inference.json`, and the operator ran the ModelExpress server with `trainer.json` and `extra="ignore"`. **Idea.** Each entrypoint returns every process it launches from one API, and every launcher writes it as is: ```python config = RLConfig(...) # or SFTConfig, PretrainConfig, InferenceConfig, EvalConfig config.components() # {"trainer": TrainerConfig, "orchestrator": OrchestratorConfig, # "engine-prefill": EngineConfig, "engine-decode": EngineConfig, # "router": RouterConfig, "envs/train/<source>": EnvWorkerPoolConfig, # "modelexpress-server": ModelExpressServerConfig} config.placement() # same keys -> Placement(replicas, nodes, gpus_per_node) dump_components(config) # same keys -> the JSON each process reads; launchers write <key>.json ``` A launcher never rewrites a component JSON. Every value known before the launcher has hosts is in the JSON. Only host- or attempt-dependent wiring goes on the command line at process start: the engine URLs of a multi-node router (`router @ router.json --worker-urls …`), each env pool's `--address-file`, `--weight_broadcast.host $MASTER_ADDR`, and the attempt log dir of a local ModelExpress server. - `RouterConfig` is strict and holds only what vllm-router reads. Locally, the router and the engine run as separate processes, as on SLURM and k8s. llm-d has no `RouterConfig`. - The ModelExpress server is a component: rl and sft build `ModelExpressServerConfig(port, log_dir)` for a `modelexpress` broadcast. - `InferenceSection.engine_config(role=...)` builds a P/D role engine and replaces `for_pd_role`. `EngineConfig.pd_kv_transfer` replaces the three flat P/D fields. - The builders fill the weight broadcast group (NCCL host, `inference_world_size`), so `[weight_broadcast]` no longer takes them. - The rl and sft engines set `server.require_admin_token`. The online-eval config carries the trainer's `resume`, and the process resolves its resume step at start. - Each entrypoint calls `components()` when it validates, so a config that resolves can always launch. - Out of scope: the platform and the operator do not use `components()` yet. They break on this PR; see [Launchers outside prime-rl](#launchers-outside-prime-rl). ## Breaking Remove these keys. Each now fails as an unknown key: - rl and sft `[weight_broadcast]`: `host` for `nccl`, and `inference_world_size` for `nccl` and `modelexpress`. The builders fill both. `modelexpress` keeps `host`: it names a server that the run does not start. - inference: `use_pd_kv_transfer`, `pd_decode_blocks_ttl_s`, `pd_spill_to_store` (the deployment sets them per role). sft with an `nccl` or `modelexpress` weight broadcast and no `[inference]` now fails at validation. The launcher raised this before. Files in `configs/attempt_<n>/resolved/`: - `inference.json` → `engine.json`; `inference-{prefill,decode}.json` → `engine-{prefill,decode}.json`; sft `eval.json` → `online-eval.json`. New: `router.json`, and `modelexpress-server.json` for a `modelexpress` weight broadcast. Behind a router, `engine.json` has `server.port = backend_port`. - `rl.json`, `sft.json`, `pretrain.json` and `inference.json` (the `inference` entrypoint) are full dumps, including `slurm`, `dry_run` and `clean`. The single-node SLURM job relaunches them with `--slurm None --no-dry-run --no-clean`. - A multi-node rl run with no inference nodes writes no `orchestrator.json`. - rl and sft `engine*.json` set `server.require_admin_token = true`. A launcher that starts them must set `PRIME_RL_ADMIN_TOKEN` or `PRIME_RL_ADMIN_TOKEN_SHA256`, or pass `--no-server.require-admin-token`. - `engine-{prefill,decode}.json` hold `pd_kv_transfer`. `online-eval.json` adds `resume` and `ckpt_output_dir`. Env pool JSONs hold no `address_file` and a relative `output_dir`. SLURM templates: the multi-node scripts run `uv run router @ $CONFIG_DIR/router.json` with the engine URLs as flags. A custom template that includes `_launch_router.sh.j2` must pass four arguments and build `ROUTER_ARGS` as router flags. CLI: `python -m prime_rl.entrypoints.modelexpress_server` reads a strict `ModelExpressServerConfig`. Pass `--port` and `--log-dir`, or `@ modelexpress-server.json`. Env: `PRL_ENV_ADDRESSES` keys are `envs/<split>/<source>`, the `components()` keys (was `<split>/<source>`). Python API: - `RLConfig.inference_config()` and `SFTConfig.inference_config()` → `engine_configs()` and `router_config()`. `InferenceConfig.for_pd_role(role)` → `engine_config(role=role)`. `InferenceConfig.to_namespace()` → `config.engine_config().to_namespace()`. `InferenceConfig` is no longer an `EngineConfig`. - `dump_rl_components`, `dump_pd_components` and `dump_env_worker_pool_components` → `dump_components(config)`. `keep_engine_fields` is gone. `build_vllm_router_cmd` → `router_command(RouterConfig)`. - `ModelExpressServerConfig` moves to the components package; `port` and `log_dir` are required. - Entrypoints take `NCCLWeightBroadcastSection` and `ModelExpressWeightBroadcastSection`; the `*WeightBroadcastConfig` classes are the process configs. `config.weight_broadcast.inference_world_size` → `config.inference_world_size`. - `env_worker_pool_config()` takes no `address_file`; launchers pass `--address-file` at start. ### Launchers outside prime-rl I built the pod commands of the k8s operator on model-factory-iac `main` (17d27957) for hosted runs that PrimeIntellect-ai/prime#1284 compiles. Then I parsed each command with prime-rl `main` (42e1e43) and with this PR as first written (16752ca). The cases were rl single-node, rl multi-node, rl with a `modelexpress` broadcast, sft with online evals, and sft without evals. On `main` all 23 commands parse. On this PR 5 fail. #4899 changes none of them. I reran the parse on f5ac012 and on the old stack top, where the prime#1284 worker reads `dump_components`: the same 5 fail. | Consumer | Today | On this PR | Change needed | |---|---|---|---| | Operator router pod, in every run with inference | `router @ inference.json --server.host … --server.port …` | Fails: `--server`, `--vllm`, `--log`, … `Extra inputs are not permitted` | Run `router @ router.json` with `--worker-urls`, or `--prefill-urls` and `--decode-urls`, as the multi-node sbatch scripts now do. Pass `--intra-node-data-parallel-size` when one URL serves several DP ranks. `router.json` is `dump_components(config)["router"]`, which no PrimeRun carries yet. | | Operator ModelExpress pod | `python -m prime_rl.entrypoints.modelexpress_server @ trainer.json --log-dir …` | Fails: `--port Field required`, and every trainer key is extra | Pass `--port <weight_broadcast.port> --log-dir …`. Images from before this PR parse the same flags. | | Operator P/D engines (PrimeRuns with `configs.prefill` and `configs.decode`) | `inference @ inference-{prefill,decode}.json` | Fails: `use_pd_kv_transfer`, `pd_*`, `log.interval`, `log.log_data` are extra | Run `engine @ engine-{prefill,decode}.json`. Give the engines `PRIME_RL_ADMIN_TOKEN_SHA256` (and the orchestrator the token), or pass `--no-server.require-admin-token`. | | Operator engine render for served checkpoints (`run_engine.py`) | `InferenceConfig.to_namespace()` | `AttributeError` (and `ImportError` from #4899 first) | Call `config.engine_config().to_namespace()`. Import from `prime_rl.configs.entrypoints.inference`. | | Env-server configs that the platform writes | `env-worker-pool @ env-server-<n>.json` | Fails only if the config sets `log.interval` or `log.log_data` | Remove those keys. | | `PRL_ENV_ADDRESSES` (PrimeIntellect-ai/model-factory-iac#3893, open) | Keys `<split>/<source>` | The orchestrator does not find the pools | Use the keys `envs/<split>/<source>`. | | The SFT online-eval split in PrimeIntellect-ai/prime#1284 (`supervised_online_eval`) | Dumps `weight_broadcast` from the section, which `sft` filled with `inference_world_size` | The trainer and online-eval JSONs miss `inference_world_size`, which defaults to 1. A hosted SFT online eval over `nccl` or `modelexpress` with more than one inference GPU waits for transfer workers that never join. | Take `weight_broadcast` from `config.weight_broadcast_config()` (`"0.0.0.0"` as the trainer's NCCL host on multi-node), or take both JSONs from `dump_components`. | | `prime train` with a released CLI | Imports `prime_rl.configs.{rl,sft,pretrain}`, `dump_rl_components` | `ImportError` when it compiles the run (from #4899) | Release PrimeIntellect-ai/prime#1284. | These still parse: the trainer (`prime_rl.trainer.{rl,sft}.train @ trainer.json` with `--weight_broadcast.*` and `--rollout_transport.*`), the orchestrator, `prime_rl.eval.online @ … @ eval-resume.json` (its `resume_step` still takes precedence), `inference @ inference.json --router None`, and the resume cleanup's imports. For hosted training, this means: - An image with this PR fails every hosted rl run and every sft run with online evals at the router pod. A run with a `modelexpress` broadcast also fails at the ModelExpress pod. An sft run without evals still works. - `prime train` cannot submit P/D: the CLI rejects `deployment.type = "disaggregated"` on `main` and on this PR. So the P/D break hits only PrimeRuns that are written by hand. - With PrimeIntellect-ai/prime#1284 as it stands, an SFT run with online evals over `nccl` or `modelexpress` and more than one inference GPU hangs at its first weight broadcast. - Before hosted runs use an image with this PR: fix the SFT online-eval split in PrimeIntellect-ai/prime#1284 and release it, have the CLI and the platform send `router.json`, and update the operator's router and ModelExpress commands. ## Verification On c86c474, on macOS without torch or vllm: - **Launcher output.** I dry-ran the 103 launcher cases and diffed every written file against #4899 (2569ff7). The file renames and new files above are the only structural changes. `engine.json` holds the old per-rank `inference.json` values, except `server.port` behind a router (8000 → 8100) and `server.require_admin_token`. `router.json` holds the values of the old router command line. Env pool JSONs drop `address_file` and add `store_dir: null`. `rl.json` and `sft.json` drop the weight broadcast `host` and `inference_world_size`; the trainer and orchestrator JSONs keep both values. - **Router commands.** I rendered the multi-node sbatch scripts of rl (regular, P/D, ModelExpress), sft with online evals, and inference (multi-node, P/D). All 6 pass `bash -n`. I ran each script's URL block with four fake hosts and parsed `router @ router.json` with the flags it builds. Each vllm-router command has the same policy, host, ports, P/D retries and bidirectional TTL as the old template command. - **Tests.** The config, launch, router, resume, client, dynamo and algorithm tests: 919 passed. | Change removed | Result | | --- | --- | | engine `server.port = backend_port` behind a router | `test_engine_behind_a_router_listens_on_the_backend_port` fails | | `pd_kv_transfer` on role engines | 4 P/D tests fail | | role `kv_cache_offload` and `hisparse` in the P/D engine build | `test_pd_role_connectors` fails: `HiSparse does not work with native KV cache offload` | | `write_component_configs` rewrites `address_file` again | `test_rl_launcher_writes_exactly_the_components` and the sft one fail | | `server.require_admin_token` on the rl engines | `test_rl_components_carry_the_router_and_one_engine_per_pd_role` fails | | `inference_world_size` fill in `weight_broadcast_config` | 4 tests fail, among them `test_sft_online_evals_size_the_in_memory_transfer_group` | | NCCL host fill | `test_rl_trainer_alone_binds_the_nccl_rendezvous_on_multi_node` fails | | `resume` in the online-eval builder | `test_online_eval_resumes_where_the_trainer_does` fails | | `router.json` in `_launch_router.sh.j2` | `test_multi_node_launchers_start_the_router_from_its_config` fails | | router entry in `RLConfig.placement()` | `test_entrypoints_place_every_component_they_launch` fails (3 cases) | | `modelexpress-server` entry in `components()` | placement tests and `test_modelexpress_server_reads_its_own_config_not_the_trainers` fail | | strict `ModelExpressServerConfig` | the trainer's JSON parses: `Regex pattern did not match` | | `RLConfig.validate_components` | `test_rl_validates_the_component_configs_it_builds`: `DID NOT RAISE` | The table ran on earlier commits of this PR with the same code under test. No GPU run. ## Merge order #4899 → this PR → #4919 → #4928. Rebase onto `main` after each squash merge. Do not ship an image with this PR to hosted training before the changes in [Launchers outside prime-rl](#launchers-outside-prime-rl) are live. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Large contract change to resolved JSON shapes and launcher/operator commands; misaligned external orchestrators could fail startup or hang weight broadcast, but behavior is validated via `components()` at config resolve time. > > **Overview** > **Unifies how run configs become per-process JSON** so local, SLURM, and external launchers all use the same builders instead of excludes, renames, and post-hoc patches. > > Each entrypoint now exposes **`components()`**, **`placement()`**, and **`dump_components()`** with stable keys (`trainer`, `engine` / `engine-prefill` / `engine-decode`, `router`, `envs/<split>/<source>`, `modelexpress-server`, …). Launchers write those blobs as-is; only host-dependent wiring (router URLs, `--address-file`, NCCL rendezvous) stays on the CLI. > > **Inference is split into real components:** `RouterConfig` is strict and router-only; P/D engines come from **`InferenceSection.engine_config(role=...)`** with **`EngineConfig.pd_kv_transfer`** instead of flat `use_pd_kv_transfer` fields; resolved artifacts rename `inference*.json` → `engine*.json` plus new `router.json`. RL/SFT launch local **router** and **engine** processes separately. > > **Supervised/RL config layout** moves trainer sections into dedicated component modules; weight broadcast uses **section vs process config** with **`weight_broadcast_config()`** filling `inference_world_size` and NCCL host. Online eval configs gain trainer **`resume`** / **`ckpt_output_dir`** for aligned resume behavior. > > Docs and **`AGENTS.md`** are updated for the new API. This is a **breaking** change for custom SLURM templates, k8s operator pod commands, env pool key prefixes, and several removed TOML fields. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c86c474. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
…ks (#4919) ## Summary **Why.** After #4899 and #4909 the configs split by who writes them, but the modules still mix concerns. `components/trainer.py` holds the model, MoE, optimizer, loss, data and checkpoint configs. `shared.py` holds ten unrelated blocks. Two `ModelConfig` and two `CheckpointConfig` classes exist. Config logic also sits outside the package: `utils/validation.py` holds the rl shared-field table, and `utils/config.py` mixes config helpers with CLI helpers. A human or an agent cannot find a field from its TOML path. **Idea.** One layout, navigable by TOML path, and rules that tests enforce. The PR only moves code and adds docstrings: no field, default or launcher output changes. ``` prime_rl/configs/ base.py BaseConfig, EntrypointConfig, ComponentConfig, Placement, build_component_config, dump_components, dump_resolved_config, default_output_dir entrypoints/ rl, sft, pretrain, eval, inference, _supervised components/ trainer/ __init__ (TrainerSection, TrainerConfig), sft, pretrain, base, model, moe, optim, loss, data, ckpt orchestrator/ __init__ (OrchestratorSection, OrchestratorConfig), sources, sampling, curriculum, ckpt engine/ __init__ (EngineSection, EngineConfig), vllm, kv_cache, deployment router.py env_worker_pool.py online_eval.py modelexpress_server.py blocks/ weight_broadcast, deployment, slurm, monitors, log, client, run, ckpt, model, algorithm, length_penalty, transport ``` `[trainer.optim]` is in `components/trainer/optim.py`. `[orchestrator.train.source]` is in `components/orchestrator/sources.py`. `test_config_package_follows_its_rules` and `test_config_utils_hold_no_config_logic` enforce the [package README](https://github.com/PrimeIntellect-ai/prime-rl/blob/feat/configs-layout/packages/prime-rl-configs/README.md#package-layout) rules: 1. A module in `components/` defines at most one `ComponentConfig`, and each entry in `components/` defines one. No module outside `components/` defines one. 2. Each class name is unique in the package. 3. Imports go one way: `entrypoints` → `components` → `blocks` → `base`. 4. A module stays under about 400 lines (the test allows 450). `entrypoints/rl.py` is the one exception. 5. Each config class and each field has a docstring that says what it does, without repeating the type, the default or the bounds. 6. `prime_rl.utils` holds helpers that know no config (`cli`, the `mode` checks, config diffs, parser names) and imports nothing from `prime_rl.configs`. - Docstrings for 104 classes and 47 fields that had none. Docstrings that repeated a default are cut. - Review fixes: `InferenceConfig.components()` is typed `dict[str, ComponentConfig]`, `RLConfig.auto_setup_draft_swaps` moves below the fields (still the first `after` validator), and a stray TODO and two stale "per-node config" remarks go. ## Breaking Python import paths. Old paths fail with `ImportError`; there are no shims. | Old module (`prime_rl.configs.`) | New module (`prime_rl.configs.`) | | --- | --- | | `components.base`, `entrypoints.base` | `base` | | `shared` | `blocks.{ckpt,client,deployment,log,model,run,slurm,transport,weight_broadcast}` | | `algorithm`, `monitors` | `blocks.algorithm`, `blocks.monitors` | | `algorithm` (`LengthPenaltyConfig` and its variants) | `blocks.length_penalty` | | `components.trainer` | `components.trainer` (section, config) and `components.trainer.{base,ckpt,data,loss,model,moe,optim}` | | `components.sft_trainer`, `components.pretrain_trainer` | `components.trainer.sft`, `components.trainer.pretrain` (data configs in `components.trainer.data`) | | `components.supervised_trainer` | `components.trainer.base` | | `components.orchestrator` | `components.orchestrator` and `components.orchestrator.{ckpt,curriculum,sampling,sources}` | | `components.engine` | `components.engine` and `components.engine.{deployment,kv_cache,vllm}` | | `entrypoints.supervised` | `entrypoints._supervised` | `dump_components` and `build_component_config` move from `prime_rl.utils.config` to `prime_rl.configs.base`. `env_worker_pool_key` moves to `components.env_worker_pool`. `BaseConfig` is no longer re-exported from `prime_rl.utils.config`; import it from `prime_rl.configs.base`. `TokenizerConfig` moves to `blocks.model`. Class renames: | Old | New | | --- | --- | | trainer `ModelConfig`, `CheckpointConfig` | `TrainerModelConfig`, `TrainerCheckpointConfig` | | orchestrator `ModelConfig`, `CheckpointConfig` | `OrchestratorModelConfig`, `OrchestratorCheckpointConfig` | | engine `WeightBroadcastConfig` | `EngineWeightBroadcastConfig` | | rl `DeploymentConfig`, `SingleNodeDeploymentConfig`, `MultiNodeDeploymentConfig` | `RLDeploymentConfig`, `RLSingleNodeDeploymentConfig`, `RLMultiNodeDeploymentConfig` | | supervised `SingleNodeDeploymentConfig`, `MultiNodeDeploymentConfig` | `SupervisedSingleNodeDeploymentConfig`, `SupervisedMultiNodeDeploymentConfig` | Config helpers, also with no shims: | Old | New | | --- | --- | | `prime_rl.utils.validation.propagate_shared_fields` | `prime_rl.configs.entrypoints.rl.propagate_shared_fields` | | `prime_rl.utils.config.{dump_resolved_config,default_output_dir}` | `prime_rl.configs.base` | | `prime_rl.utils.config.resolve_client_roles` | `prime_rl.configs.blocks.client` | | `prime_rl.utils.config.{rgetattr,rsetattr}` | removed (unused) | `prime-rl-configs` declares `pydantic>=2.0.0` (was `>=1.10.13`; `prime-pydantic-config` already needs 2). TOML and CLI keys do not change. ## Verification On 92c8097, on macOS without torch or vllm: - **Launcher output.** I dry-ran the 103 launcher cases. Every written file is byte-identical to #4909 (c86c474), except one sbatch comment line in 11 P/D scripts ("per-node config" → "role's engine config"). - **Imports.** For every `from prime_rl.configs… import` and `from prime_rl.utils.config import` in the repo, the module defines each name. This covers `orchestrator.py` and `eval/online.py`, which need triton to import whole. The Slim-install CI check imports the moved helpers from their new paths. - **Schemas.** On the first layout commit, the JSON schemas of all 14 entrypoint and component configs matched #4909 except the `description` text (after inlining `$ref`s, because the renames change `$defs` names). - **Tests.** The config, launch, router, resume, client, dynamo, algorithm, model-source, control, dashboard and parser tests: 921 passed. The rule tests fail when a rule breaks: | Change made | Result | | --- | --- | | Second `ComponentConfig` in `components/router.py` | `components/router.py defines ['ExtraConfig', 'RouterConfig']` | | `ComponentConfig` in `blocks/log.py` | `blocks/log.py defines ['ExtraConfig'] outside components/` | | `RouterConfig` subclasses `BaseConfig` | `components/ entries without a component config: ['router']` | | Second `LoRAConfig` in `blocks/model.py` | `LoRAConfig is defined in prime_rl.configs.blocks.model and prime_rl.configs.components.trainer.model` | | `blocks/log.py` imports a component | `blocks/log.py (blocks) imports prime_rl.configs.components.router` | | `components/router.py` imports an entrypoint | `components/router.py (components) imports prime_rl.configs.entrypoints.eval` | | `blocks/algorithm.py` grows to 459 lines | `blocks/algorithm.py has 459 lines; split it along its TOML sub-tables` | | Docstring of `ModelExpressServerConfig.port` removed | `ModelExpressServerConfig lacks docstrings for ['port']` | | Docstring of `ModelExpressServerConfig` removed | `ModelExpressServerConfig lacks docstrings for ['<class>']` | | `utils/diff.py` imports `prime_rl.configs.base` | `diff.py imports ['prime_rl.configs.base']` | ## Merge order #4899 → #4909 → this PR → #4928. Rebase onto `main` after each squash merge. - PrimeIntellect-ai/prime#1284 reads `dump_components` from `prime_rl.configs.base`. Release it before hosted runs use an image with this PR. Its schema worker uses only the `prime_rl.utils.config` module by name, so the helper moves do not break it. - This PR adds no break for the k8s operator: the commands and modules it runs do not move. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Large-scale import and module moves with no compatibility shims; any missed consumer or downstream package still on old paths will fail at import time, though runtime config behavior is meant to be unchanged. > > **Overview** > Restructures **`prime-rl-configs`** so TOML paths map to modules: shared pieces live under **`blocks/`**, per-process configs under **`components/`** (with **`trainer/`**, **`orchestrator/`**, and **`engine/`** split into submodules instead of large single files), and user entrypoints stay in **`entrypoints/`**. **`base.py`** now owns **`BaseConfig`**, **`ComponentConfig`**, **`EntrypointConfig`**, **`build_component_config`**, **`dump_components`**, **`dump_resolved_config`**, and **`default_output_dir`** (moved out of **`prime_rl.utils.config`**). **`prime_rl.utils`** is no longer allowed to import config modules; **`propagate_shared_fields`** moves to **`entrypoints.rl`**. > > This is a **breaking** change for Python imports only: old paths like **`configs.shared`**, monolithic **`components.trainer`** / **`components.engine`** / **`components.orchestrator`**, and several renamed types (**`TrainerModelConfig`**, **`OrchestratorModelConfig`**, **`EngineWeightBroadcastConfig`**, RL/supervised deployment config renames) have **no shims**. Call sites across benchmarks, CI slim checks, docs, and **`pretrain/train`** are updated. **`pydantic>=2.0.0`** is declared explicitly; README documents layout rules enforced by tests. TOML/CLI keys and launcher JSON are intended to stay unchanged. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 92c8097. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 3, 2026
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
## Summary **Why.** `[inference] router = "None"` gave `rl`, `sft` and `inference` a second topology: a bare engine on `server.port`. Configs and launchers carried both shapes: - The engine port depended on the router. - The admin URLs were set only with a router. - Three validators rejected `None` on multi-node and P/D. - Each launcher started the router behind `if config.router_config() is not None`. The multi-node and P/D launches already always run a router. **Idea.** Every deployment runs a router on `server.port`, with its engines on `backend_port`. `router` is no longer optional: ```python # before router: RouterBackendConfig | None = Field(default_factory=VllmRouterConfig) def router_config(...) -> RouterConfig | None # after router: RouterBackendConfig = VllmRouterConfig() def router_config(...) -> RouterConfig ``` - `InferenceConfig.components()` and `placement()` always hold `router`. - `rl` and `sft` hold it whenever they have an `[inference]` block. - The local `rl`, `sft` and `inference` launchers always start the router. - Clients keep `server.port`, so their URLs do not change. ## Breaking - **`router = "None"` is rejected** in `[inference]` of `rl` and `sft`, and in `inference`. Remove the line. Clients still connect on `server.port`. To reach the engine directly, use `backend_port` (`server.port + 100` by default). - **`uv run inference` on one node** now starts a router on `server.port` and the engine on `backend_port`. Before, `router = "None"` served the engine itself on `server.port`. - **Operator.** `model-factory-iac` passes `--router None` to `inference` (`roles.go`). That flag now fails. The operator should run `engine @ engine.json` instead. Its `inference @ inference.json` launch already broke with the configs split, which merged in #4928. - `ServingSection.router_config()` and `InferenceSection.router_config()` return `RouterConfig`, not `RouterConfig | None`. ## Verification **Local runs on a 2-GPU box** (RTX PRO 6000; engine on GPU 0, trainer on GPU 1). The setup is `dev/examples/reverse-text/rl.toml`, 20 steps, with `--monitors.wandb None --ckpt None`. Both runs used this branch's tree on 3c366c9d5, which is 3ef3710 applied as a patch: | Router | Exit | Wall time | Reward, step 10 | Reward, step 20 | Router processes left after exit | | --- | --- | --- | --- | --- | --- | | `vllm-router` (default) | 0 | 198 s | 0.752 | 0.838 | 0 | | `llm-d` | 0 | 196 s | 0.750 | 0.866 | 0 | **Standalone inference.** `uv run inference --router.type llm-d` on one GPU: - The engine on port 8100 is ready after 35 s. - A chat completion through the router on port 8000 returns HTTP 200. - When the router dies, `inference` shuts down within 1 s. | Change removed | Result | | --- | --- | | `router` accepts `None` again | `test_every_engine_runs_behind_a_router_on_the_backend_port` fails: did not raise | ## Merge order Stacked on #4939 (`feat/llmd-router`). Merge that first: it lets the always-on router be llm-d on one node. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes inference topology and launch behavior (breaking for `router=None`); client URLs on `server.port` stay the same but operators and IAC that started bare engines need updates. > > **Overview** > **Inference always uses a router:** `[inference].router` is required (`VllmRouterConfig` by default); `router = None` is rejected. The engine always binds `backend_port` behind the router on `server.port`, and `router_config()` / `components()` / `placement()` always include a router entry. > > **Simpler wiring:** Validators that mandated a router on multi-node SFT/RL/inference and conditional checks when setting `admin_base_url` or launching router processes are removed—those paths now assume a router is always present. > > **Launchers:** Local `inference`, `rl`, and SFT always start the router subprocess (no optional bare-engine path). Standalone `uv run inference` exposes the API on the router port, not directly on the engine. > > **Breaking:** Configs that disabled the router must drop `router = None`; direct engine access uses `backend_port` instead of `server.port`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3ef3710. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mikasenghaas
added a commit
that referenced
this pull request
Dec 3, 2026
## Summary **Why.** The Unit (CPU) job fails on `main` since 465e9b5. #4801 added `test_modelexpress_sender_publishes_current_values_of_state_dict_copies`, which imports `ModelExpressWeightBroadcastConfig` from `prime_rl.configs.shared`. #4928 moved that config to `prime_rl.configs.blocks.weight_broadcast`. Each PR passed alone. Together they fail with `ModuleNotFoundError: No module named 'prime_rl.configs.shared'`. **Idea.** The test imports the config from its new path. No other file imports `prime_rl.configs.shared`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only import path correction; no production or runtime logic is modified. > > **Overview** > Repairs a **broken import** in `test_modelexpress_sender_publishes_current_values_of_state_dict_copies` so the unit test matches where `ModelExpressWeightBroadcastConfig` now lives (`prime_rl.configs.blocks.weight_broadcast` instead of the removed `prime_rl.configs.shared` module). > > This is a one-line test fix with no behavior change—only unblocks CPU CI after the config module was relocated. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 12220dd. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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. After #4909, every process reads a complete component config. But the values in those configs were still resolved in many places:
rlcopied run-level fields (max_steps,resume,ckpt,monitors,rollout_transport) into[trainer]and[orchestrator], and then checked that the copies were equal.model_fields_set. A resolved config counts every field as set, so parsingrl.jsonorsft.jsonagain could build different components.getattr.ROLE_EXTRA, role env exports).rlandsftvalidators wrote derived values into the user's sections, so results depended on validator order.Idea. Resolve each value in one place, from values only, and validate it once:
rl. The builders pass them in, as they passoutput_dir. A setting in such a block that only one process reads stays in that process's section:[trainer.ckpt](async_save,remote,skip_dataloader,skip_optimizer),[orchestrator.ckpt](rollouts,rollouts_save_timeout),[orchestrator.monitors.file](trace_sample,live). The builders merge the two parts.None, or"auto"whereNonealready has a meaning, replace themodel_fields_setchecks (14 → 0). A client keeps its defaultbase_urluntil a launcher fills it, and the builders find that default by its value.copy_validatedreplacesmodel_copy(update=…).engine_layout()/fit_engines()incomponents/engine/layout.py.data_parallel_sizeandapi_server_countdefault to"auto".tokenizer,load_format,speculative_config,quantization_config,moe_backend,pipeline_parallel_size,headlessanddata_parallel_{start_rank,address}. ANoneis not passed to vLLM.engine-<role>.json. The sbatch passes only host-dependent values (data_parallel_address,data_parallel_rank).rl.jsonandsft.jsonkeep what the user wrote. Checks that span processes run on the built configs. So a speculative draft indecode_vllm_overridesis checked like one on[inference.vllm].run.name,weight_broadcast,deployment.num_infer_nodes,slurm.template_path) are still filled by validators.Breaking
rl. Each field now has one place:[trainer]and[orchestrator]no longer takemax_steps,resumeorrollout_transport. Set them at the top level.[ckpt]takes only what both processes share:interval,keep_last,keep_interval,output_dir. Moveintervaland the others out of[trainer.ckpt]and[orchestrator.ckpt]into[ckpt]. Moverolloutsandrollouts_save_timeoutfrom[ckpt]to[orchestrator.ckpt], andasync_saveandremotefrom[ckpt]to[trainer.ckpt](e.g.--ckpt.rollouts→--orchestrator.ckpt.rollouts). A[trainer.ckpt]or[orchestrator.ckpt]without[ckpt]raises.[monitors]turns the monitors on for both processes.[orchestrator.monitors]takes onlyfile.trace_sampleandfile.live, which leave the top-level[monitors.file].SharedWandbConfig,SharedMonitorsConfigandSharedCheckpointConfigare removed.rlrejectsmonitors.wandb.offline = true.int4/rl/prod/rl.tomlmust moverolloutsandrollouts_save_timeoutfrom[ckpt]to[orchestrator.ckpt]. Its other 112 configs that parse onmainparse unchanged.Nonemeans "derive it". To get the old result, set an explicit value:kv_load_failure_policy = "fail"under bidirectional P/D, explicitinference_metrics_roles, explicitadmin_base_url.data_parallel_sizeordata_parallel_size_localthat does not fill the GPUs now raises on multi-node and P/D (before, it was kept). An explicitapi_server_countstays, but underncclormodelexpressweight broadcast it must not be below the engine's local data parallel ranks. A lower count now raises: vLLM then starts too few workers, and the weight transfer waits forever.VllmConfig().data_parallel_sizeand.api_server_countare"auto"until a layout resolves them.max_lora_rank. An explicitinference.vllm.max_lora_ranklarger than the trainer's LoRA rank now stays. Before,rlandsftreplaced it with the trainer's rank, so vLLM now allocates the larger LoRA buffers. Remove the key to serve exactly the trainer's rank. A smaller value now raises.config.inference.vllm.enable_lora,.data_parallel_size,config.orchestrator.speculative_decoding, the score-centeringsampling.logprobsand the client URLs keep the user's values. Read the derived values fromengine_configs(),orchestrator_config(),online_eval_config()orresolved_inference().rl.jsonandsft.jsonnow hold the user's values (e.g.api_server_count = "auto"); the component JSONs are unchanged.inference.sbatch.j2andmulti_node_rl.sbatch.j2lose the template varsprefill_env_vars,decode_env_vars,prefill_vllm_extra_json,decode_vllm_extra_jsonandprefill_deepep_high_throughput. A custom template that uses them orROLE_EXTRAbreaks. A P/D role'senv_varsnow reach the engine only when it starts, not as a shell export beforeuv run. So they win over the per-rankUCX_NET_DEVICESpinning, and a variable that must exist before Python starts (e.g.LD_PRELOAD) no longer takes effect.inferencecomponent of fix(train): compile hosted runs with prime-rl's component builders prime#1284. Itslegacy_inferencedumps the[inference]section, which now keeps the user's values. I ran the worker against feat: organize prime-rl-configs into entrypoints, components and blocks #4919 and this PR. On this PR the hosted engine loses the deriveddata_parallel_sizeandapi_server_count(they become"auto", so the engine runs DP = 1 whiletrainer.jsonwaits for N transfer workers),enable_loraandmax_lora_rank,enable_return_routed_experts,enable_return_sampling_maskandload_format = "dummy". The SFT online-eval split also loses the derivedclient.admin_base_url. Fix in the worker: dumpconfig.resolved_inference()when the schema has it, and take the eval JSON fromdump_components(config)["online-eval"].InferenceSection.engine_configtakesrequire_admin_tokenbeforerole. Passrole=by keyword.trainer_config(),engine_config(), ...) that gets an invalid value raisesValueError(The TrainerConfig that this config builds is invalid: <path>: <message>), not the component'sValidationError. Entrypoint parsing still raisesValidationError.Verification
On 3603799, on macOS without torch or vllm. CI runs the full unit suite.
End to end over every checked-in config. I dry-ran the local and SLURM launchers for 104 cases. They cover every checked-in
rl,sftandinferenceTOML and documented overlay stack, plus synthetic multi-node, P/D, SLURM and SFT online-eval cases. For each case, the script checks four things:main: 102 of 104 parse onmainand on every PR of the stack. My script picks the wrong entrypoint for the other 2, so they skip onmaintoo.dump_components().vllm.tokenizer)vllm.tokenizer, P/D prefillkv_load_failure_policyrecompute→None)Launcher output vs. feat: organize prime-rl-configs into entrypoints, components and blocks #4919. The dry-run JSON differs in key order and in these fields:
trainer.jsonandorchestrator.json:monitors.file.float_decimals = 6in the twocolor-codewordconfigs now reaches both processes (it was 4).engine.json: the new typed vLLM keys at their defaults, anddata_parallel_size_local = 1(wasnull) inrecipes/intellect-3.1andrecipes/minimax-m2.5(DP = 1, so vLLM behaves the same).rl.json,sft.json: the user's values, as listed under Breaking, and inrl.jsonthe component-only checkpoint and trace settings under[trainer]and[orchestrator].The builder refactor leaves every component JSON and sbatch of feat: organize prime-rl-configs into entrypoints, components and blocks #4919 byte-identical.
P/D sbatch. Before c165715, all 72 vLLM settings in
ROLE_EXTRAand all 49 role env exports across the 11 P/D cases matchedengine-<role>.json, with 0 mismatches. So dropping them from the sbatch leaves each rank's settings unchanged.Speculative drafts in P/D overrides.
rlnow rejects score centering with a speculative draft indecode_vllm_overrides(With speculative decoding, sampler logprobs … need truncated train sampling), as it does for a draft on[inference.vllm]. feat: organize prime-rl-configs into entrypoints, components and blocks #4919 accepts it.Single-node SLURM
inferencewithdeployment.type = "multi_node"andnum_nodes = 1. The sbatch now runsengineper rank. feat: organize prime-rl-configs into entrypoints, components and blocks #4919 runsuv run inferenceon the engine-onlyinference.json, which fails.research-prod (906b2e8d). I parsed its 167 documented config stacks from
research-prod/prime-rlonmain(42e1e43) and on this PR. 113 parse onmain, and the same 113 parse here. The env packages ofint4/rl/prod/rl.tomlare missing on my machine, so I swapped its train sources for a stub. With its two[ckpt]lines moved, it resolves to the same values as onmain: trace sample 0.1 without live traces, checkpoints every 20 steps with rollouts and a 180 s timeout, and DP 8 / 8 local / 8 API servers per engine. Its NUMA sbatch template still finds its oneuv run orchestratorline.Tests. The 17 config, launch, router, resume, client, dynamo, algorithm and model-source test files: 990 passed in 7 s.
The first six rows ran on the commits of the closed #4921–#4925, before they were folded into this PR. Rows 15–19 ran on 1c92480, the last three on 3603799, the others on 2ba08c1.
_run_fields()test_run_level_fields_reach_trainer_and_orchestratorfailsfields_set)test_resolved_configs_parse_to_the_same_components[rl-pd-bidirectional]failssetattr)test_engines_and_routers_are_built_whole[rl-pd-prefill-overrides]failsengine_layouttest_rl_engine_layout[…trainer4]:(4, None, 4) != (4, None, 1)speculative_configfield (back to an extra)speculative_configstest_a_pd_role_draft_without_its_own_weights_fails_under_a_dummy_target: did not raiseresolved_inference()test_rl_sections_keep_the_values_the_user_wrotefailsresolved_inference()test_rl_nvfp4_experts_set_up_matching_enginesfailsorchestrator_config()test_modelexpress_serves_a_draft_and_swaps_itfailsorchestrator_config()test_rl_launcher_config_roundtrip:None == 4orchestrator_config()test_modelexpress_under_pd_transfers_to_every_prefill_and_decode_gpufailstest_rl_checks_settings_that_must_agree_on_the_built_configs: did not raisetest_sft_sections_keep_the_values_the_user_wrotefailsbase_urlfound by value (back tomodel_fields_set)test_resolved_configs_parse_to_the_same_components[rl-inference-port]and[sft-online-eval-port]failtest_in_memory_weight_transfer_needs_an_api_server_per_rank: did not raisebuild_component_configtest_components_share_no_run_level_instancefailstest_a_component_error_names_the_componentfailsis_multi_nodeininference.sbatch.j2(back tonum_nodes > 1)test_a_one_node_multi_node_deployment_runs_its_engine_per_rankfails[trainer.ckpt]/[orchestrator.ckpt]merged into the component checkpointtest_ckpt_takes_shared_settings_at_the_top_and_component_settings_in_the_sectionsand bothtest_ckpt_rollouts_*tests fail[orchestrator.monitors.file]mergedtest_trace_options_reach_only_the_orchestratorfails[ckpt]test_ckpt_takes_shared_settings_…: did not raiseThe old
rlcheck for llm-d with router replay is gone: the inference section's own check now catches it on the resolved config, so the test still raises.No GPU run. The P/D sbatch evidence ran on 5456cb0, before this branch's rebase onto the new #4919 tip.
Merge order
Merge last, after #4899 → #4909 → #4919. It is stacked on #4919 (
feat/configs-layout). Rebase it ontomainafter each squash merge.🤖 Generated with Claude Code
Note
High Risk
Large breaking config/API surface (CLI paths, engine layout validation, sbatch template vars) affects every RL/SFT launch; mis-derived engine DP/API counts can deadlock weight transfer.
Overview
Config layout.
rlnow owns run-wide settings only at the top level (max_steps,resume,[ckpt],[monitors],rollout_transport). Component sections hold side-specific knobs ([trainer.ckpt],[orchestrator.ckpt.rollouts],[orchestrator.monitors.file]). Builders merge run + section into validated component JSON once viabuild_component_config/copy_validated, instead of copying fields throughpropagate_shared_fieldsand post-hoc equality checks.Inference derivation. New
resolved_inference()(and SFT analogue) centralizes dummy load, LoRA, router replay, NVFP4 env, sampling masks, andengine_layout()/fit_engines()fordata_parallel_sizeandapi_server_count(defaults"auto"). vLLM options move from untyped extras to typed fields onVllmConfig. P/D role engines are built only fromengine_config()JSON—SLURM templates dropROLE_EXTRA/ role-specific vLLM override template vars.Orchestrator wiring moves into
orchestrator_config()(draft swaps, score-centering logprobs, client/admin URLs, disaggregated metrics roles). Cross-process checks (NVFP4 engines, speculative + sampler logprobs) run on builtcomponents().Docs and launchers switch CLI examples to prefixed paths (
--orchestrator.ckpt.rollouts,--trainer.ckpt.async-save). Run owners and Prime monitor readconfig.monitors/config.max_stepsat entrypoint level;rlrejects shared W&B offline mode.Reviewed by Cursor Bugbot for commit 3603799. Bugbot is set up for automated code reviews on this repo. Configure here.