Repository navigation
feat(workers): Add config-driven worker extension FQNs - #3809
Conversation
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
pstjohn
left a comment
There was a problem hiding this comment.
Reviewed by a team of 5 agents (RL expert, bug finder, test agent, design reviewer, devil's advocate). Nice, tightly-scoped change — and failing loudly on conflicting config-vs-constructor values instead of silently picking one is the right call.
Verification run locally:
- Linters clean:
ruff,ruff-format,taplo, whitespace, andpyrefly check(0 errors). - All 4 new tests pass on 8xH100. They were mutation-tested and kill 4 real mutants (dropping the vLLM override; moving the quant check after PG init; the async/sync kwargs split) — these are not tautologies.
cluster._init_placement_groups.assert_not_called()in particular has teeth: moving the check after the PG call makes the test fail. - The YAML nesting was checked hard by three agents independently and is correct —
VllmGeneration.self.cfgis thepolicy.generationdict, so the key is read where it's set. Not a silent no-op.
3 inline comments, all suggestions, none blocking.
Two lower-confidence items I'm noting here rather than inline, both arguably tracking issues rather than work for this PR:
TeacherWorkerGroupdeep-copies the student policy config and hardcodesMegatronPolicyWorker, sopolicy.worker_extension_cls_fqnis silently dropped for distillation teachers — the same hole it already warns-and-clears forquant_cfg. Debatable whether that's even wrong (a frozen teacher on the stock worker seems fine).- Nothing in the suite pins an exemplar YAML key to the dict level its consumer reads. Harmless here since the value is
nulland both consumers use.get(), but see below.
Unrelated repo-level find, worth its own issue: _collect_mismatched_keys in tests/unit/test_config_v2.py:101 is one-directional. Deleting a key from an exemplar while leaving the reference config intact still passes all 14 tests, so exemplar-side drift is invisible in both directions.
Generated by Claude Code
|
/ok to test ab2f594 |
yuki-97
left a comment
There was a problem hiding this comment.
Scope: the two new worker_extension_cls_fqn fields and their wiring in lm_policy.py / vllm_generation.py, plus the exemplar + reference YAMLs and the two new test modules.
Checked:
- Config placement — the generation-level key is read at the same level
quant_cfgandrefit_transportlive at, and the reference config mirrors the exemplar, sotest_reference_configs_up_to_datestays green. - Guard ordering — the quant exclusion correctly precedes
cluster._init_placement_groups; traced where each other invalid-FQN case actually surfaces, and how much is allocated by then. - Backend reach — which of the five generation backends can see the key after
defaults:inheritance, and which of them read it. - Test mutation — dropped each new production line in turn and confirmed a new test fails; the default no-extension path is unchanged from
main. - Exemplar convention — compared against how other
NotRequiredPolicyConfigkeys are spread across the five base configs.
Remaining comments are three fail-early / validation suggestions, one fix to a backend list in a YAML comment, and a pointer to #4032 for the longer-term consolidation (no action needed here).
Before merge: could you rebase and run CI? The branch is 69 commits behind main, and nemo_rl/models/generation/__init__.py has moved there since it branched — that is the file the vllm/config.py comment asks you to add a guard to, so it is worth rebasing before picking that one up. I have added CI:Lfast; all unit shards were skipped on ab2f594, so the four new tests have not run in CI yet.
Add one optional worker_extension_cls_fqn field to PolicyConfig and VllmConfig. Signed-off-by: Peter St. John <[email protected]>
Address review feedback on the config-driven worker extension FQNs. The quant_cfg mutual exclusion applied to both the config field and the pre-existing Policy constructor argument, which narrowed the constructor's contract. Previously the override ran after resolve_policy_worker_cls and printed the resolved class name, so extending the quant-resolved worker via the constructor was supported. Restrict the exclusion to the config-supplied FQN, where the config author cannot know which worker quant_cfg resolves to. Cover the two branches that had no test: config and constructor set to the same value (the equality clause was dead code with respect to the suite), and the constructor argument combined with quant_cfg. Both were mutation-verified to fail without the corresponding source change. Note in the exemplar that the generation-level key is vLLM-only, since sglang/trtllm/dynamo inherit this config and ignore it, and disambiguate it from vLLM's own worker_extension_cls engine argument. Signed-off-by: Peter St. John <[email protected]>
Signed-off-by: Peter St. John <[email protected]>
ab2f594 to
f934c26
Compare
|
/ok to test f934c26 |
This change is to make it easier to plug in custom workers and policies.
Policy.__init__already accepts aworker_extension_cls_fqn, but standard policy configs cannot set it. The vLLM generation path has no equivalent extension hook. A caller that needs custom policy and vLLM workers therefore has to wrap or replace Policy and monkeypatch the vLLM worker resolver.This PR adds one optional
worker_extension_cls_fqnfield toPolicyConfigandVllmConfig.Policyreads the field directly from its config, so normal construction paths honor it without algorithm-specific forwarding. The existing constructor argument remains supported.If config and the constructor provide different FQNs, construction fails rather than choosing one silently.
VllmGenerationapplies its configured FQN after the existing worker resolver for both synchronous and asynchronous engines.On both paths,
worker_extension_cls_fqnis mutually exclusive withquant_cfg, because both settings replace the backend’s resolved worker. Invalid combinations fail before worker or placement-group allocation. The canonical GRPO exemplar and its reference config include the two optional entries, as required for the existing TypedDict config schema.