Repository navigation
fix(vllm): merge policy hf_config_overrides into generation hf_overrides #4907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lonexreb
wants to merge
4
commits into
NVIDIA-NeMo:main
Choose a base branch
from
lonexreb:fix/3728-merge-hf-overrides
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9f6be7b
fix(vllm): merge policy hf_config_overrides into generation hf_overrides
lonexreb ff378e1
fix(vllm): reject conflicting hf_overrides instead of warning
lonexreb eeec9f4
Merge main into the hf_overrides merge fix
lonexreb 6cfd561
Merge main
lonexreb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
88 changes: 88 additions & 0 deletions
88
tests/unit/models/generation/test_vllm_policy_hf_overrides.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # Copyright (c) 2025, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Regression tests for syncing ``policy.hf_config_overrides`` into vLLM kwargs. | ||
|
|
||
| The algorithm entry points used to assign ``vllm_kwargs["hf_overrides"]`` | ||
| wholesale, which silently dropped any generation-only overrides the user set | ||
| under ``policy.generation.vllm_kwargs.hf_overrides`` (#3728). | ||
| """ | ||
|
|
||
| import warnings | ||
|
|
||
| import pytest | ||
|
|
||
| from nemo_rl.models.generation.vllm.config import merge_policy_hf_overrides | ||
|
|
||
|
|
||
| def test_generation_only_overrides_survive(): | ||
| vllm_kwargs = {"hf_overrides": {"max_position_embeddings": 8192}} | ||
|
|
||
| merge_policy_hf_overrides(vllm_kwargs, None) | ||
|
|
||
| assert vllm_kwargs["hf_overrides"] == {"max_position_embeddings": 8192} | ||
|
|
||
|
|
||
| def test_policy_overrides_are_added_without_conflict(): | ||
| vllm_kwargs = {"hf_overrides": {"max_position_embeddings": 8192}} | ||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("error") | ||
| merge_policy_hf_overrides(vllm_kwargs, {"rope_theta": 1_000_000.0}) | ||
|
|
||
| assert vllm_kwargs["hf_overrides"] == { | ||
| "max_position_embeddings": 8192, | ||
| "rope_theta": 1_000_000.0, | ||
| } | ||
|
|
||
|
|
||
| def test_conflicting_values_raise(): | ||
| vllm_kwargs = {"hf_overrides": {"rope_theta": 1.0, "other": "keep"}} | ||
|
|
||
| with pytest.raises(ValueError, match=r"\['rope_theta'\]"): | ||
| merge_policy_hf_overrides(vllm_kwargs, {"rope_theta": 2.0}) | ||
|
|
||
|
|
||
| def test_equal_values_do_not_warn(): | ||
| vllm_kwargs = {"hf_overrides": {"rope_theta": 2.0}} | ||
|
|
||
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("error") | ||
| merge_policy_hf_overrides(vllm_kwargs, {"rope_theta": 2.0}) | ||
|
|
||
| assert vllm_kwargs["hf_overrides"] == {"rope_theta": 2.0} | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("existing", [{}, {"hf_overrides": None}, {"hf_overrides": {}}]) | ||
| def test_no_overrides_anywhere_yields_empty_mapping(existing): | ||
| vllm_kwargs = dict(existing) | ||
|
|
||
| merge_policy_hf_overrides(vllm_kwargs, {}) | ||
|
|
||
| assert vllm_kwargs["hf_overrides"] == {} | ||
|
|
||
|
|
||
| def test_policy_overrides_are_copied_not_aliased(): | ||
| policy_overrides = {"rope_theta": 2.0} | ||
| vllm_kwargs = {} | ||
|
|
||
| merge_policy_hf_overrides(vllm_kwargs, policy_overrides) | ||
| vllm_kwargs["hf_overrides"]["extra"] = 1 | ||
|
|
||
| assert policy_overrides == {"rope_theta": 2.0} | ||
|
|
||
|
|
||
| def test_non_mapping_generation_overrides_are_rejected(): | ||
| with pytest.raises(ValueError, match="must be a mapping"): | ||
| merge_policy_hf_overrides({"hf_overrides": "oops"}, {}) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C1 · 1 action item.
TL;DR — when both override dicts set one key to different values, vLLM gets the policy value and the run goes on with only a warning in the driver log. Elsewhere the repo raises a setup-time
ValueErrorwhen two user settings disagree.For example,
policy.hf_config_overrides.rope_theta: 1e6pluspolicy.generation.vllm_kwargs.hf_overrides.rope_theta: 5e5: the run starts and vLLM uses 1e6. The user asked for two different values and is never asked to pick one.Other places in the repo reject the config instead of picking a winner:
_reject_conflicting_engine_kwargs: "nvfp4_pertoken cannot overwrite explicit vLLM settings".No recipe on any public branch sets one key to different values in these two dicts, so a raise blocks no existing config.
AI-1
Could you replace the warning with a
ValueErrorthat names the keys and the fix?This is a plain block, not a one-click suggestion, because three other spots describe the warning and need to change with it:
test_policy_wins_on_conflict_and_warnsbecomespytest.raises(ValueError, match=r"\['rope_theta'\]")and drops its result assert;Where the new error fires in distillation and single-controller setup (no action needed)
With a raise, where the call sits starts to matter:
_build_generation, in parallel with the trainer build.Moving these two calls earlier, before any model is built (distillation already has an early vLLM block), would make the error appear first. Not part of this ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ff378e1: conflicting keys now raise your
ValueError(names the keys and says to set them only inpolicy.hf_config_overrides). Updated the docstring, replaced the warn test withtest_conflicting_values_raise(pytest.raises(ValueError, match=r"\['rope_theta'\]")), and changed the YaRN guide sentence. Equal values and generation-only keys behave as before. I also checked that no config underexamples/configsorresearch/setsvllm_kwargs.hf_overrides, so nothing existing trips it. Left the call-site ordering in distillation / non-colocated SC as is, per your note. Thanks for the careful review and for deferring #4949.