Skip to content

feat: set the run-level fields of rl once - #4921

Closed
mikasenghaas wants to merge 24 commits into
feat/configs-layoutfrom
feat/run-level-fields
Closed

mikasenghaas wants to merge 24 commits into
feat/configs-layoutfrom
feat/run-level-fields

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Why. The trainer and the orchestrator of an rl run always share max_steps, resume, rollout_transport, monitors and the checkpoint policy. Still, rl accepted each of them at the top level and again under [trainer] and [orchestrator]. propagate_shared_fields copied the top-level value into the raw input by dotted path, validate_shared_configs checked the copies for equality, and auto_setup_rollout_transport copied the value back up. The copying also lost data: it carried only monitors.file.path, so the other [monitors.file] fields never reached the processes.

Idea. Each of these fields exists once, at the top level of rl. The builders pass them into trainer.json and orchestrator.json, the same way they pass output_dir. [ckpt] becomes one block with the fields of both sides (RLCheckpointConfig), and each builder narrows it to its own side.

def trainer_config(self) -> TrainerConfig:
    return build_component_config(
        TrainerConfig,
        self.trainer,
        **self._run_fields(),  # max_steps, resume, rollout_transport, monitors
        ckpt=self.ckpt and build_component_config(TrainerCheckpointConfig, self.ckpt),
        ...
    )
  • model.name, seq_len, tokenizer and log can legitimately differ per component. They keep their top-level default and their per-component override.
  • TrainerRunConfig holds ckpt, max_steps and their validators (trace length, scheduler steps). The SFT and pretrain sections and the RL trainer component use it. The RL [trainer] section does not.
  • The component JSON of every process keeps all of its fields, so the processes, the k8s operator and the fix(train): compile hosted runs with prime-rl's component builders prime#1284 worker read the same files as before.
  • rl rejects monitors.wandb.offline = true. Before, the only way to set it was per component; the shared W&B run needs the W&B server.
  • Out of scope: tokenizer.chat_template must also match across components. It stays per component with the equality check.

Breaking

  • [trainer] and [orchestrator] of rl no longer take max_steps, resume, ckpt, monitors or rollout_transport. Each one now fails as an unknown key. Migration: set them at the top level, e.g. [trainer.ckpt] skip_optimizer = true → [ckpt] skip_optimizer = true, --trainer.ckpt.async-save → --ckpt.async-save. No checked-in config used them.
  • RLConfig.trainer.ckpt, .monitors, .resume, .max_steps, .rollout_transport (and the same on orchestrator) are gone from the Python API. Read them from RLConfig or from trainer_config() / orchestrator_config().
  • SharedWandbConfig, SharedMonitorsConfig and SharedCheckpointConfig are removed. RLConfig.monitors is a MonitorsConfig, RLConfig.ckpt an RLCheckpointConfig, and RLConfig.rollout_transport is never None.
  • Hosted training: a user TOML that sets one of the removed keys fails at prime train run with the unknown-key error. Nothing in the operator or the platform changes.

Verification

On f8fcb74, on macOS without torch or vllm:

  • Launcher output. I dry-ran the local and SLURM launchers for 103 cases (every checked-in rl, sft and inference config that loads, plus synthetic multi-node, P/D, SLURM and sft online-eval cases) and diffed every written file against feat: organize prime-rl-configs into entrypoints, components and blocks #4919 at 95b8fdd.
    • trainer.json, orchestrator.json and sft.json differ only in key order, except one value: the two dev/examples/color-codeword configs set [monitors.file] float_decimals = 6, which now reaches both processes (it was 4).
    • rl.json drops the per-component copies and holds the full monitors and ckpt blocks.
  • Tests. The config, launch, router, resume and monitor tests: 713 passed, 1 failed, 1 error. feat: organize prime-rl-configs into entrypoints, components and blocks #4919 gives the same failure set: test_pathing.py cannot import a module my env lacks, and the monitor load test is timing-dependent (it passes on rerun).
Change removed Result
run-level fields in _run_fields() test_run_level_fields_reach_trainer_and_orchestrator fails
ckpt narrowing in a builder test_ckpt_splits_into_the_trainer_and_orchestrator_fields fails
TrainerSection based on TrainerRunConfig (keeps ckpt, max_steps) test_run_level_fields_are_set_once_for_the_run fails for trainer ckpt and max_steps
W&B name → Prime run name default test_an_explicit_wandb_name_also_names_the_prime_run fails
validate_wandb_online test_rl_rejects_offline_wandb fails

Merge order

Stacked on #4919 (#4899 → #4905 → #4909 → #4919 → this PR). It merges after #4919.

🤖 Generated with Claude Code


Note

Medium Risk
Breaking change for TOML/API: run-level fields under [trainer] or [orchestrator] now fail validation; migration to top-level keys is required. Config wiring is central to every RL launch, though behavior is intended to match prior resolved trainer.json/orchestrator.json.

Overview
Consolidates shared RL run settings so max_steps, resume, ckpt, monitors, and rollout_transport live only on the top-level rl config—not duplicated under [trainer] or [orchestrator]. The launcher injects them into each process config via _run_fields() and narrowed RLCheckpointConfig/TrainerCheckpointConfig/OrchestratorCheckpointConfig, replacing the old propagate_shared_fields copies and cross-component equality checks.

Config model cleanup: SharedWandbConfig, SharedMonitorsConfig, and SharedCheckpointConfig are removed in favor of MonitorsConfig and a unified [ckpt] block. [trainer] / [orchestrator] sections shed those keys (unknown key if set); TrainerRunConfig holds ckpt/max_steps for SFT/pretrain and full TrainerConfig/OrchestratorConfig for RL launches. rl now rejects monitors.wandb.offline = true because trainer and orchestrator share one W&B run.

Runtime/docs: Launch and Prime monitor code read config.monitors / config.ckpt / config.max_steps from RLConfig instead of per-component paths. Docs drop redundant --trainer.ckpt.* / [trainer.ckpt.remote] aliases in favor of top-level ckpt flags.

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

mikasenghaas and others added 24 commits December 2, 2026 16:42
Entrypoint configs (rl, sft, pretrain, eval, inference) are what users
write. Component configs (trainer, orchestrator, router, env worker
pool, online eval) are what one process reads: an entrypoint resolves
them, or an external launcher such as the Kubernetes operator writes
them. Keeping both in one flat configs/ package hid that boundary.

Move the config modules into configs/entrypoints and
configs/components, and the component process mains into
prime_rl.components. Top-level configs/ modules stay as the blocks
both use. EntrypointConfig and ComponentConfig mark each class, and
test_config_layout checks the scripts, markers and import direction.

Rename RouterEntrypointConfig to RouterConfig and the router backend
union to RouterBackendConfig. Fields are unchanged: the JSON schemas
of the moved configs match main. Old import paths such as
prime_rl.configs.rl now fail with ImportError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
configs/inference.py splits into components/engine.py and
components/router.py, which now holds the router backend blocks.
configs/algorithm.py moves to components/algorithm.py, and
configs/diff.py moves to utils/diff.py.

The old import paths fail loudly; there are no shims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The algorithm block is no component config: the orchestrator, the env
workers, the sample server and the transports all use it. Keep it at
prime_rl.configs.algorithm, its path on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uv run inference was both the public entrypoint (a router plus an
engine, or a SLURM job) and the bare engine that each SLURM rank runs.
EngineConfig now holds the fields that one engine process reads, and
InferenceConfig extends it with the router, deployment and SLURM
fields. The new `engine` script serves one EngineConfig without a
router, and the per-rank SLURM launches use it.

EngineConfig ignores unknown keys, so it reads any inference config,
including the existing per-rank and P/D role JSON. InferenceConfig
still rejects unknown keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SLURM writers now keep only the engine fields in the per-rank and
P/D role files that `engine` reads. EngineConfig then rejects unknown
keys and CLI flags like every other config. dump_rl_components and
dump_pd_components are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An entrypoint used to nest whole component configs, so users could set
fields that the launcher always overwrites. Each component config now
extends a public section with the launcher-filled fields only, and the
entrypoint nests the section. Builders validate the component config
from the section plus the wired values.

Remove public keys that no process reads or that the launcher always
fills: sft [eval] run fields, unused log fields, rl wandb offline.
Derive inference.backend_port from server.port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rl entrypoint always fills the trainer's and orchestrator's
output_dir and weight_broadcast, and used to reject other user values.
Move these fields from the sections to TrainerConfig and
OrchestratorConfig, and fill them in RLConfig.trainer_config() and
orchestrator_config(). RLConfig now runs every builder when it
validates, so the component validators still run at resolve time.

Write the config rules into the prime-rl-configs README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SFTConfig.inference_config() built a single-node deployment, so an
llm-d router failed when the launcher wrote the eval configs of a
multi-node run. Build the inference deployment from [deployment], and
run the builder when SFTConfig validates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every entrypoint now gives the config of each process it launches
through one API: components() returns the built configs, keyed by the
JSON file stem, and placement() says where each runs under the same
keys. dump_components() dumps them whole, with no excludes. The local,
SLURM and external launchers all use it, so the per-process JSON is
the same for every launcher.

- InferenceConfig no longer subclasses EngineConfig. The engine and
  router configs come from engine_config(role=...) and router_config().
  The P/D role logic moves from for_pd_role into engine_config.
- RouterConfig is strict and holds only what vllm-router reads. The
  local launchers run the router and engine as separate processes.
- The SFT and pretrain trainer configs move to configs/components with
  a SupervisedTrainerSection. The trainer reads a trainer.json without
  launch fields.
- Files: inference.json -> engine.json (engine-<role>.json under P/D),
  eval.json -> online-eval.json, new router.json. <entrypoint>.json is a
  full dump; the single-node SLURM relaunch overrides slurm, dry_run and
  clean.
- Env worker pools are keyed envs/<split>/<source> in components() and
  in PRL_ENV_ADDRESSES.
- The SFT check that an in-memory weight broadcast needs inference
  moves from the launcher into SFTConfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The k8s operator ran the server with the trainer's JSON, so its config
had to ignore unknown keys. components() now emits a
modelexpress-server config (port and log dir) with a CPU-only
placement whenever the run starts its own server, and the config
rejects unknown keys like every other component. The local launchers
take the port from the same builder.

The operator must pass --port and --log-dir (or the new JSON) instead
of trainer.json; the old config already accepts both flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The public [weight_broadcast] of rl and sft no longer takes the NCCL
host or inference_world_size. Both were launcher-filled: validators
wrote inference_world_size into the section, and the NCCL host was
"localhost" except on the multi-node trainer. The process configs
(WeightBroadcastConfig) still carry both fields. The builders fill
them from the deployment, so trainer.json and orchestrator.json are
complete before allocation.

The multi-node sft trainer now reads host 0.0.0.0 from its JSON, so
the sbatch drops the flag. Host-dependent flags ($MASTER_ADDR, the
ModelExpress host) stay on the command line. ModelExpress keeps its
public host: it names a server that the run does not start.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EngineConfig took three flat P/D fields (use_pd_kv_transfer,
pd_decode_blocks_ttl_s, pd_spill_to_store) that only the launcher
sets. One pd_kv_transfer sub-config replaces them. It holds the
deployment's bidirectional_kv_transfer, and only engine_config(role=)
sets it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The launchers still changed component configs after components():
write_component_configs filled the env pools' address_file and made
their output_dir absolute, the sft launcher swapped in an online-eval
config with a resolved resume_step, the local launchers passed
--server.require-admin-token and the attempt log dir, and the
multi-node sbatch scripts built the vllm-router command from template
variables instead of router.json.

Now each JSON is the whole config that its process reads:

- The rl and sft engine builders set server.require_admin_token.
- The online-eval config carries the trainer's resume and checkpoint
  root. The process resolves its resume step at start. The trainer
  blocks in its startup broadcast until online-eval receives it, so
  it cannot add a checkpoint first. A resume_step from an external
  launcher (eval-resume.json) still takes precedence.
- The ModelExpress server config keeps the run's log dir.
- The multi-node scripts run `router @ router.json` and pass only the
  engine URLs (--worker-urls, or --prefill-urls and --decode-urls).

Host- and attempt-dependent wiring stays on the command line at
process start: the env pools' --address-file, the attempt log dir of
a local ModelExpress server, and the engine URLs. The env pools'
output_dir stays relative: set_save_root resolves it in each process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The disaggregated engine_config validated one EngineConfig with the
section's kv_cache_offload and hisparse, then set the role's values.
Native offload on prefill with HiSparse on decode then failed at
resolve, though main accepts it. Pass the role's kv_cache_offload and
hisparse into the build so the validators see the final values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Give the prime-rl-configs package one layout that a reader can
navigate by TOML path. base.py holds the contract. entrypoints/ holds
the configs users write. components/ holds one entry per process
(packages for trainer, orchestrator and engine, split along their
TOML sub-tables). blocks/ holds what several modules share.

A layout test enforces the rules in the package README: one
ComponentConfig per components/ module, unique class names, imports
only toward base, and modules under ~400 lines. Same-named classes get
a component prefix (TrainerModelConfig, OrchestratorModelConfig, ...).

No field, default or launcher output changes; old import paths fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a package rule: each config class and each field has a docstring
that says what it does, without repeating the type, the default or
the bounds that --help already prints from the annotation. The rules
test now fails on an undocumented class or field.

The docstrings push blocks/algorithm.py over the module size limit,
so the length penalties move to blocks/length_penalty.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
@mikasenghaas
mikasenghaas added this pull request to stack #4918 December 3, 2026 03:10
@mikasenghaas
mikasenghaas removed this pull request from stack #4918 December 3, 2026 03:30
@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).

mikasenghaas added a commit that referenced this pull request Dec 3, 2026
## Summary

**Why.** After #4909, every process reads a complete component config.
But the values in those configs were still resolved in many places:

- `rl` copied run-level fields (`max_steps`, `resume`, `ckpt`,
`monitors`, `rollout_transport`) into `[trainer]` and `[orchestrator]`,
and then checked that the copies were equal.
- Defaults applied only when a field was absent from `model_fields_set`.
A resolved config counts every field as set, so parsing `rl.json` or
`sft.json` again could build different components.
- Builders set values on configs that were already validated, and those
values skipped the validators.
- Six code paths sized the engines' data parallelism and API servers,
each with its own rules.
- prime-rl read nine untyped vLLM pass-through keys with `getattr`.
- P/D role settings reached a rank twice: from the engine JSON, and from
the sbatch (`ROLE_EXTRA`, role env exports).
- The `rl` and `sft` validators 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:

```
user TOML ──► RLConfig (sections as written; validators only check)
                 │
                 ├─ resolved_inference()   LoRA, router replay, NVFP4, dummy load,
                 │                         sampling masks, engine_layout()
                 ├─ orchestrator_config()  draft swaps, score-centering logprobs,
                 │                         client URLs, metrics roles
                 ▼
            components()  ──► built and validated once ──► cross-process checks
                                                         (NVFP4, speculative logprobs)
```

- **Run-level fields** exist once, at the top level of `rl`. The
builders pass them in, as they pass `output_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.
- **Explicit "derive it" values.** `None`, or `"auto"` where `None`
already has a meaning, replace the `model_fields_set` checks (14 → 0). A
client keeps its default `base_url` until a launcher fills it, and the
builders find that default by its value.
- **Validate once.** The builders merge every value first and validate
once. `copy_validated` replaces `model_copy(update=…)`.
- **One layout function.** `engine_layout()` / `fit_engines()` in
`components/engine/layout.py`. `data_parallel_size` and
`api_server_count` default to `"auto"`.
- **Typed vLLM fields.** `tokenizer`, `load_format`,
`speculative_config`, `quantization_config`, `moe_backend`,
`pipeline_parallel_size`, `headless` and
`data_parallel_{start_rank,address}`. A `None` is not passed to vLLM.
- **P/D role settings** come only from `engine-<role>.json`. The sbatch
passes only host-dependent values (`data_parallel_address`,
`data_parallel_rank`).
- **Builders derive, validators check.** `rl.json` and `sft.json` keep
what the user wrote. Checks that span processes run on the built
configs. So a speculative draft in `decode_vllm_overrides` is checked
like one on `[inference.vllm]`.
- Out of scope: the top-level run fields (`run.name`,
`weight_broadcast`, `deployment.num_infer_nodes`, `slurm.template_path`)
are still filled by validators.

## Breaking

- **Run-level fields of `rl`.** Each field now has one place:
- `[trainer]` and `[orchestrator]` no longer take `max_steps`, `resume`
or `rollout_transport`. Set them at the top level.
- `[ckpt]` takes only what both processes share: `interval`,
`keep_last`, `keep_interval`, `output_dir`. Move `interval` and the
others out of `[trainer.ckpt]` and `[orchestrator.ckpt]` into `[ckpt]`.
Move `rollouts` and `rollouts_save_timeout` from `[ckpt]` to
`[orchestrator.ckpt]`, and `async_save` and `remote` from `[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 only `file.trace_sample` and
`file.live`, which leave the top-level `[monitors.file]`.
- `SharedWandbConfig`, `SharedMonitorsConfig` and
`SharedCheckpointConfig` are removed. `rl` rejects
`monitors.wandb.offline = true`.
- research-prod at 906b2e8d: `int4/rl/prod/rl.toml` must move `rollouts`
and `rollouts_save_timeout` from `[ckpt]` to `[orchestrator.ckpt]`. Its
other 112 configs that parse on `main` parse unchanged.
- **`None` means "derive it".** To get the old result, set an explicit
value: `kv_load_failure_policy = "fail"` under bidirectional P/D,
explicit `inference_metrics_roles`, explicit `admin_base_url`.
- **Engine layout.** An explicit `data_parallel_size` or
`data_parallel_size_local` that does not fill the GPUs now raises on
multi-node and P/D (before, it was kept). An explicit `api_server_count`
stays, but under `nccl` or `modelexpress` weight 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_size` and `.api_server_count` are
`"auto"` until a layout resolves them.
- **`max_lora_rank`.** An explicit `inference.vllm.max_lora_rank` larger
than the trainer's LoRA rank now stays. Before, `rl` and `sft` replaced
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.
- **Typed vLLM keys.** A wrong type in one of the nine keys fails at
resolve time instead of in vLLM.
- **Derived values leave the sections.**
`config.inference.vllm.enable_lora`, `.data_parallel_size`,
`config.orchestrator.speculative_decoding`, the score-centering
`sampling.logprobs` and the client URLs keep the user's values. Read the
derived values from `engine_configs()`, `orchestrator_config()`,
`online_eval_config()` or `resolved_inference()`. `rl.json` and
`sft.json` now hold the user's values (e.g. `api_server_count =
"auto"`); the component JSONs are unchanged.
- **sbatch templates.** `inference.sbatch.j2` and
`multi_node_rl.sbatch.j2` lose the template vars `prefill_env_vars`,
`decode_env_vars`, `prefill_vllm_extra_json`, `decode_vllm_extra_json`
and `prefill_deepep_high_throughput`. A custom template that uses them
or `ROLE_EXTRA` breaks. A P/D role's `env_vars` now reach the engine
only when it starts, not as a shell export before `uv run`. So they win
over the per-rank `UCX_NET_DEVICES` pinning, and a variable that must
exist before Python starts (e.g. `LD_PRELOAD`) no longer takes effect.
- **Hosted runs: the `inference` component of
PrimeIntellect-ai/prime#1284.** Its `legacy_inference` dumps the
`[inference]` section, which now keeps the user's values. I ran the
worker against #4919 and this PR. On this PR the hosted engine loses the
derived `data_parallel_size` and `api_server_count` (they become
`"auto"`, so the engine runs DP = 1 while `trainer.json` waits for N
transfer workers), `enable_lora` and `max_lora_rank`,
`enable_return_routed_experts`, `enable_return_sampling_mask` and
`load_format = "dummy"`. The SFT online-eval split also loses the
derived `client.admin_base_url`. Fix in the worker: dump
`config.resolved_inference()` when the schema has it, and take the eval
JSON from `dump_components(config)["online-eval"]`.
- `InferenceSection.engine_config` takes `require_admin_token` before
`role`. Pass `role=` by keyword.
- **Builder errors.** A builder (`trainer_config()`, `engine_config()`,
...) that gets an invalid value raises `ValueError` (`The TrainerConfig
that this config builds is invalid: <path>: <message>`), not the
component's `ValidationError`. Entrypoint parsing still raises
`ValidationError`.
- No checked-in config changes.

## 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`, `sft`
and `inference` TOML and documented overlay stack, plus synthetic
multi-node, P/D, SLURM and SFT online-eval cases. For each case, the
script checks four things:

1. The entrypoint parses, as on `main`: 102 of 104 parse on `main` and
on every PR of the stack. My script picks the wrong entrypoint for the
other 2, so they skip on `main` too.
2. **Round trip.** The entrypoint's dump parses again to the same dump
and the same `dump_components()`.
3. **Fixed point.** Each of the 402 component JSONs parses into its
class and dumps unchanged.
4. **Per-process values** match the snapshot of #4919.

| Tip | Entrypoint dump not a fixed point | Components change after
re-parse | Component JSON not a fixed point |
| --- | --- | --- | --- |
| #4909 (c86c474) | 3 (SFT `vllm.tokenizer`) | 11 (SFT
`vllm.tokenizer`, P/D prefill `kv_load_failure_policy` `recompute` →
`None`) | 0 |
| #4919 (92c8097) | 3 | 11 | 0 |
| this PR (3603799) | 0 | 0 | 0 |

- **Launcher output vs. #4919.** The dry-run JSON differs in key order
and in these fields:
- `trainer.json` and `orchestrator.json`: `monitors.file.float_decimals
= 6` in the two `color-codeword` configs now reaches both processes (it
was 4).
- `engine.json`: the new typed vLLM keys at their defaults, and
`data_parallel_size_local = 1` (was `null`) in `recipes/intellect-3.1`
and `recipes/minimax-m2.5` (DP = 1, so vLLM behaves the same).
- `rl.json`, `sft.json`: the user's values, as listed under Breaking,
and in `rl.json` the component-only checkpoint and trace settings under
`[trainer]` and `[orchestrator]`.

The builder refactor leaves every component JSON and sbatch of #4919
byte-identical.
- **P/D sbatch.** Before c165715, all 72 vLLM settings in `ROLE_EXTRA`
and all 49 role env exports across the 11 P/D cases matched
`engine-<role>.json`, with 0 mismatches. So dropping them from the
sbatch leaves each rank's settings unchanged.
- **Speculative drafts in P/D overrides.** `rl` now rejects score
centering with a speculative draft in `decode_vllm_overrides` (`With
speculative decoding, sampler logprobs … need truncated train
sampling`), as it does for a draft on `[inference.vllm]`. #4919 accepts
it.
- **Single-node SLURM `inference` with `deployment.type = "multi_node"`
and `num_nodes = 1`.** The sbatch now runs `engine` per rank. #4919 runs
`uv run inference` on the engine-only `inference.json`, which fails.
- **research-prod (906b2e8d).** I parsed its 167 documented config
stacks from `research-prod/prime-rl` on `main` (42e1e43) and on this
PR. 113 parse on `main`, and the same 113 parse here. The env packages
of `int4/rl/prod/rl.toml` are 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 on `main`: 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 one `uv run orchestrator` line.
- **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.

| Change removed | Result |
| --- | --- |
| run-level fields in `_run_fields()` |
`test_run_level_fields_reach_trainer_and_orchestrator` fails |
| prefill policy derived from the value (back to `fields_set`) |
`test_resolved_configs_parse_to_the_same_components[rl-pd-bidirectional]`
fails |
| role vLLM overrides validated with the build (back to `setattr`) |
`test_engines_and_routers_are_built_whole[rl-pd-prefill-overrides]`
fails |
| LoRA → 1 API server in `engine_layout` |
`test_rl_engine_layout[…trainer4]`: `(4, None, 4) != (4, None, 1)` |
| `speculative_config` field (back to an extra) | 130 tests fail |
| P/D role drafts in `speculative_configs` |
`test_a_pd_role_draft_without_its_own_weights_fails_under_a_dummy_target`:
did not raise |
| LoRA in `resolved_inference()` |
`test_rl_sections_keep_the_values_the_user_wrote` fails |
| NVFP4 env defaults in `resolved_inference()` |
`test_rl_nvfp4_experts_set_up_matching_engines` fails |
| NVFP4 check on the built engines | same test: did not raise |
| draft fill in `orchestrator_config()` |
`test_modelexpress_serves_a_draft_and_swaps_it` fails |
| score-centering logprobs in `orchestrator_config()` |
`test_rl_launcher_config_roundtrip`: `None == 4` |
| metrics roles in `orchestrator_config()` |
`test_modelexpress_under_pd_transfers_to_every_prefill_and_decode_gpu`
fails |
| speculative sampler-logprobs check on the built configs |
`test_rl_checks_settings_that_must_agree_on_the_built_configs`: did not
raise |
| SFT LoRA, client URLs or dummy load in the builders |
`test_sft_sections_keep_the_values_the_user_wrote` fails |
| default `base_url` found by value (back to `model_fields_set`) |
`test_resolved_configs_parse_to_the_same_components[rl-inference-port]`
and `[sft-online-eval-port]` fail |
| API-server check under in-memory weight broadcast |
`test_in_memory_weight_transfer_needs_an_api_server_per_rank`: did not
raise |
| wired configs copied in `build_component_config` |
`test_components_share_no_run_level_instance` fails |
| component name in builder errors |
`test_a_component_error_names_the_component` fails |
| `is_multi_node` in `inference.sbatch.j2` (back to `num_nodes > 1`) |
`test_a_one_node_multi_node_deployment_runs_its_engine_per_rank` fails |
| `[trainer.ckpt]` / `[orchestrator.ckpt]` merged into the component
checkpoint |
`test_ckpt_takes_shared_settings_at_the_top_and_component_settings_in_the_sections`
and both `test_ckpt_rollouts_*` tests fail |
| trace options of `[orchestrator.monitors.file]` merged |
`test_trace_options_reach_only_the_orchestrator` fails |
| check that a component ckpt section needs `[ckpt]` |
`test_ckpt_takes_shared_settings_…`: did not raise |

The old `rl` check 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 onto `main` after each squash merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!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.** `rl` now 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 via `build_component_config` /
`copy_validated`, instead of copying fields through
`propagate_shared_fields` and post-hoc equality checks.
> 
> **Inference derivation.** New `resolved_inference()` (and SFT
analogue) centralizes dummy load, LoRA, router replay, NVFP4 env,
sampling masks, and **`engine_layout()`** / `fit_engines()` for
`data_parallel_size` and `api_server_count` (defaults `"auto"`). vLLM
options move from untyped extras to typed fields on `VllmConfig`. P/D
role engines are built only from `engine_config()` JSON—SLURM templates
drop `ROLE_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 built `components()`.
> 
> **Docs and launchers** switch CLI examples to prefixed paths
(`--orchestrator.ckpt.rollouts`, `--trainer.ckpt.async-save`). Run
owners and Prime monitor read `config.monitors` / `config.max_steps` at
entrypoint level; `rl` rejects shared W&B offline mode.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3603799. 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>
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