fix(launcher): reject nemo_run overrides the executor has no attribute for - #3949
Open
kabirvashisht4-glitch wants to merge 1 commit into
Conversation
…e for `NemoRunConfig.from_dict` collects every unrecognised key of the `nemo_run:` YAML section into `overrides`, and `apply_overrides` assigned each one with a bare `setattr`. NeMo-Run executors are dataclasses with fixed fields, so a mistyped key did not fail -- it created an attribute nothing reads and left the field the user meant to set at its default. `ntasks_per_nodes: 8` leaves `ntasks_per_node` at 1 and the job runs one task per node; `paritition: gpu` leaves the job on the default partition. Neither raises, warns, or logs. Check `hasattr` before assigning and raise a ValueError naming the executor and its available attributes, matching `load_executor_from_file`'s "Available: ..." error and the `hasattr` guard `_configure_torchrun` already uses next door. The existing tests drive `apply_overrides` with a MagicMock, which fabricates any attribute on access and so cannot tell a real field from one the executor does not have; the new tests use a dataclass stand-in instead. Signed-off-by: kabirvashisht4-glitch <kabirvashisht4@gmail.com>
This branch has not been deployed
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.
What does this PR do ?
Fixes #3948: a key in the
nemo_run:YAML section that the executor has no field for wassilently absorbed instead of reported.
NemoRunConfig.from_dictcollects every unrecognised key intooverrides, andapply_overridesassigned each with a baresetattr. NeMo-Run executors are dataclasseswith fixed fields, so assigning an unknown name does not fail — it adds an attribute
nothing reads, while the field the user meant to set keeps its default:
The job is then submitted with one task per node, or on the wrong partition, with no
exception, warning, or log line. The symptom appears much later as a mis-sized job, and
nothing points back at the YAML.
Approach
Check
hasattrbefore assigning and raise aValueErrornaming the executor and itsavailable attributes. This follows two precedents rather than inventing a convention:
load_executor_from_filealready raises for an unknown executor name with"... Available: alpha, beta, gamma"; the new message mirrors it._configure_torchrun, in the same class that callsapply_overrides, already guardsthe identical operation with
if hasattr(executor, "torchrun_nproc_per_node").apply_overrideswas the outlier..agents/contributor-skills/testingalso prescribes exactly this guard for foreignsetattr, including theValueError.This is a deliberate behavior change
A config that today silently drops a key will now fail at submission. I want to be
explicit about that rather than bury it: those configs are already not doing what they
say, and failing at submit time is far cheaper than discovering it after a multi-node job
has run with the wrong topology. If you would rather this warn than raise for a release
or two, say so and I will switch it to
logger.warning— the guard and tests are thesame either way.
Why the existing tests could not catch it
Every
apply_overridestest passes amock.MagicMock(), which fabricates any attributeon access, so the suite cannot distinguish setting a real field from inventing one. No
existing test asserts that an unknown key is accepted, so the permissive behavior was
untested rather than intended. The new tests use a dataclass stand-in, which is what the
real executors are.
Changelog
apply_overridesraisesValueErrorwhen the executor has no attribute for anoverride key, naming the executor type and listing its available attributes.
Raises, plusArgs, onapply_overrides.TestApplyOverridesRejectsUnknownAttributesagainst a dataclass executorstand-in: an unknown key raises and creates no phantom attribute; the message names the
executor and its fields; known scalar/dict/list overrides still apply on a real object;
and an unknown key later in the mapping does not silently pass.
Before your PR is "Ready for review"
Pre checks:
Verified locally:
pytest tests/unit_tests/launcher/-> 104 passed (100 on cleanmain; the delta isexactly the 4 tests added here). No existing test changed behavior — the
MagicMockones still pass, since
hasattris always true on a mock.main. Reverting only thenemo_automodel/change andkeeping the tests reproduces those 3. The 4th,
test_known_keys_still_apply_on_a_real_object, passes onmainby design — it is theguard-rail that the accepted path is unaffected, not a regression test.
ruff format --checkandruff checkclean on both changed files. The test file isnot ruff-formatted on
main; I deliberately left that pre-existing churn alone, so thetest diff is additions only.
nemo_runis not installed and is not needed — the tests use a dataclassstand-in, matching how the rest of this file stubs
nemo_run.Additional Information
_resolve_executor, for the"local"executor and for anamed one from
EXECUTOR_MAP) go through the guarded path.