Repository navigation
feat: add an engine component config and script - #4905
Closed
mikasenghaas wants to merge 7 commits into
Closed
mikasenghaas wants to merge 7 commits into
mikasenghaas wants to merge 7 commits into
Conversation
This was referenced Dec 2, 2026
mikasenghaas
force-pushed
the
feat/engine-component
branch
from
December 2, 2026 19:36
5bc53dd to
6bb236b
Compare
mikasenghaas
changed the base branch from
feat/move-config-blocks
to
fix/shared-file-monitor
December 2, 2026 19:36
This was referenced Dec 2, 2026
mikasenghaas
force-pushed
the
fix/shared-file-monitor
branch
from
December 2, 2026 22:05
553c6a5 to
574a254
Compare
mikasenghaas
force-pushed
the
feat/engine-component
branch
2 times, most recently
from
December 2, 2026 22:33
594b0fd to
0f24151
Compare
mikasenghaas
force-pushed
the
fix/shared-file-monitor
branch
from
December 2, 2026 22:37
574a254 to
c12e608
Compare
mikasenghaas
changed the base branch from
fix/shared-file-monitor
to
feat/public-internal-configs
December 2, 2026 22:44
mikasenghaas
force-pushed
the
feat/engine-component
branch
from
December 2, 2026 22:48
0f24151 to
83dcf5b
Compare
Member
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 83dcf5b. Configure here.
mikasenghaas
force-pushed
the
feat/engine-component
branch
from
December 3, 2026 00:15
83dcf5b to
93732c8
Compare
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>
mikasenghaas
force-pushed
the
feat/engine-component
branch
from
December 3, 2026 00:47
93732c8 to
8705e0d
Compare
mikasenghaas
force-pushed
the
feat/public-internal-configs
branch
from
December 3, 2026 00:47
92cc32f to
48de560
Compare
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>
mikasenghaas
force-pushed
the
feat/engine-component
branch
from
December 3, 2026 01:13
8705e0d to
bdc56e3
Compare
This was referenced Dec 3, 2026
mikasenghaas
force-pushed
the
feat/public-internal-configs
branch
from
December 3, 2026 03:29
ab4c7ee to
2569ff7
Compare
Member
Author
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>
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.
uv run inferenceplays two roles. Users run it as the public entrypoint: a router plus an engine locally, or a multi-node or P/D job with[slurm]. The SLURM launchers also run it as the bare engine on each rank, withrouter = None. So one config mixes public topology (router,deployment,slurm,dry_run) with the fields that one engine process reads. External launchers have no engine component to target.Idea. Split
InferenceConfigalong the process boundary, as #4899 did for the other components. The engine blocks already live inconfigs/components/engine.py(#4899), and the new class joins them:A new
enginescript (prime_rl.components.engine:main) serves oneEngineConfigwithout a router._launch_rank.sh.j2(multi-node and P/D ranks ofinference,rlandsft) now runsuv run engine @ "$CONFIG_PATH"instead ofuv run inference.keep_engine_fields) in the files the ranks read:inference.jsonof multi-nodeinference,rlandsft, andinference-{prefill,decode}.json. Before, these files held the whole inference config withrouter = None.EngineConfigis strict like every other config, so a mistyped key or flag fails.InferenceConfigkeeps all its fields, keys and defaults. Its JSON schema changes only by a new class description. The localinferenceandrllaunches still runuv run inference.apply_multi_node_dp_env(thePRL_DP_*pod env frommain) moves toprime_rl.components.engineand runs insetup_engine_process. Soengineandinferenceboth resolve the multi-node DP rank and head address.setup_dummy_loadandMODEL_NAME_DRAFT_METHODSmove tocomponents/engine.py. The P/D role overrides reach them through the newvllm_overridesproperty.dump_rl_componentsanddump_pd_componentsare unchanged, so the k8s operator's input is unchanged. To runengine, the operator must applykeep_engine_fieldsto their output.Breaking
setup_dummy_loadandMODEL_NAME_DRAFT_METHODSfromprime_rl.configs.components.engine, not fromprime_rl.configs.entrypoints.inference.apply_multi_node_dp_envfromprime_rl.components.engine, not fromprime_rl.entrypoints.inference.Verification
On 0f24151 (now bdc56e3, after rebases that add #4899's CI filter and
algorithmpath commits andmainup to 42e1e43), on macOS without torch. The schema check and the mutation table ran on 3382ffd, before the rebase ontomain.test_engine_serves_per_rank_configs_like_a_routerless_inferencebuilds a multi-node and a bidirectional P/DInferenceConfigwith native KV offload. It writes the per-rank and role JSON with the SLURM writers (write_config(engine_only=True),write_pd_configs). It parses each file with the per-rank flags underEngineConfig, and underInferenceConfigwith--router None, which is what the ranks ran before. It asserts the same engine fields and the same vLLM namespace, includingkv_transfer_config.model_json_schema()of the 9 script configs is identical to the base branch, except the newInferenceConfigdescription.wandb_gql, env tasksets).engine --server-prot 1fails with1 validation error for EngineConfig.keep_engine_fieldsinwrite_configtest_engine_serves_per_rank_configs_like_a_routerless_inference:router: Extra inputs are not permittedkeep_engine_fieldsinwrite_pd_configsenginein[project.scripts]test_config_layout:KeyError: 'engine'engineparsescli(EngineConfig)test_config_layout:`engine` does not parse EngineConfigNot covered locally: the
keep_engine_fieldscalls in the multi-noderlwriter (write_subconfigs) and thesftwriter (write_eval_subconfigs). Building those configs needs tasksets that my env lacks. No GPU run.Merge order
Merge after #4899. This PR is stacked on #4899 (
feat/public-internal-configs). Rebase it ontomainafter each squash merge. Stack, in merge order: #4899 → #4905 → #4909 → #4919.🤖 Generated with Claude Code
Note
Medium Risk
Touches multi-node/P/D launch paths and per-rank config JSON; mis-filtered fields would break SLURM ranks, but unit tests assert engine parity with routerless inference.
Overview
Splits inference config along the router vs. per-rank engine process boundary: new
EngineConfiginprime-rl-configsholds everything one vLLM worker needs (to_namespace, KV transfer, dummy-load, validators), andInferenceConfigsubclasses it with launcher-only fields (router,deployment,slurm, …).Adds
uv run engine(prime_rl.components.engine) for a routerless vLLM process, withsetup_engine_process(env, multi-nodePRL_DP_*, file limits) shared by localuv run inference. SLURM_launch_rank.sh.j2and writers now invokeengineand persistkeep_engine_fieldsJSON so ranks only see strictEngineConfigkeys—not full inference withrouter: null.Breaking: import
setup_dummy_loadfromprime_rl.configs.components.engineandapply_multi_node_dp_envfromprime_rl.components.engine.Reviewed by Cursor Bugbot for commit 83dcf5b. Bugbot is set up for automated code reviews on this repo. Configure here.