Skip to content

feat: validate each built config once with all its values - #4923

Closed
mikasenghaas wants to merge 1 commit into
feat/explicit-autofrom
feat/validate-once
Closed

mikasenghaas wants to merge 1 commit into
feat/explicit-autofrom
feat/validate-once

Conversation

@mikasenghaas

@mikasenghaas mikasenghaas commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Summary

Why. BaseConfig has no validate_assignment, so a value set after validation skips every validator. The builders did that to the configs they had just validated:

  • InferenceSection.engine_config(role=…) built an engine, then set the role's port, DP sizes and env vars, and setattr the role's vLLM overrides.
  • RLConfig.engine_configs() and SupervisedConfig.engine_configs() set server.require_admin_token on the built engines.
  • InferenceSection.router_config() set pd_bidirectional_ttl_s on the built router.
  • model_copy(update=…) changed train samplings (score-centering logprobs, the truncated-sampling top_k default) without validation.

So a P/D override reached the engine as written. With prefill_vllm_overrides = {enable_lora = true, max-lora-rank = 24}, the prefill engine got max_lora_rank = 24, which vLLM rejects (the validator rounds it to 32). It also got api_server_count = 8, but LoRA needs exactly 1.

Idea. Compute every value first, then validate once. The builders pass the role and launch values into build_component_config:

return super().engine_config(
    weight_broadcast,
    require_admin_token,
    kv_cache_offload=self.kv_cache_offload_by_role[role],
    pd_kv_transfer=PDKVTransferConfig(bidirectional=deployment.bidirectional_kv_transfer),
    server={"port": port},
    vllm={**dump_resolved_config(self.vllm), "data_parallel_size": ..., **role_vllm},
    env_vars={**self.env_vars, **role_env},
)
  • engine_config and engine_configs take require_admin_token. router_config takes the TTL as a field of the build.
  • copy_validated(config, **update) in prime_rl.configs.base replaces model_copy(update=…).
  • Out of scope: the entrypoint validators still assign values on their own sections (e.g. the engine sizing in RLConfig.auto_setup_deployment). The builders validate those values again when they build the components. The next PR moves the sizing into one function.

Breaking

  • InferenceSection.engine_config takes require_admin_token as its second positional argument, before role. A caller that passes role by position must pass it by keyword. All callers in the repo pass role=.

Verification

On 99c0d44, on macOS without torch or vllm:

Change removed Result
role vLLM overrides validated with the build (back to setattr after it) test_engines_and_routers_are_built_whole[rl-pd-prefill-overrides] and test_pd_role_overrides_pass_the_vllm_validators fail
router TTL set after the build, to a value its validator rejects (-1) test_engines_and_routers_are_built_whole[rl-pd-bidirectional] fails. A valid TTL set after the build would pass: the test catches values a validator changes or rejects.

Merge order

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

🤖 Generated with Claude Code


Note

Medium Risk
Changes how inference engine and router JSON is produced for RL/SFT launches; behavior is intended to match prior output except where validators now correct invalid overrides (e.g. P/D vLLM settings).

Overview
Adds copy_validated so copies with field updates re-run Pydantic validators (replacing model_copy(update=…) for train sampling defaults, score-centering logprobs, and frozen train-group updates).

Engine and router builders no longer mutate configs after build_component_config. Role-specific P/D values (server port, vllm overrides, env vars, require_admin_token, router TTL) are assembled into wired dicts and validated in a single build—fixing cases where post-build setattr left invalid values (e.g. max_lora_rank / api_server_count on prefill LoRA overrides).

RL/SFT entrypoints pass require_admin_token=True into engine_configs instead of patching engine.server afterward.

New tests assert each built EngineConfig / RouterConfig round-trips through model_validate unchanged.

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

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>
@mikasenghaas

Copy link
Copy Markdown
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant