Skip to content

fix: skip instantiation of nested configs overridden by kwargs in ConfigNode#1397

Merged
thomasdhc merged 1 commit intomainfrom
oholworthy/config-node-duplicate-instantiation
Feb 26, 2026
Merged

fix: skip instantiation of nested configs overridden by kwargs in ConfigNode#1397
thomasdhc merged 1 commit intomainfrom
oholworthy/config-node-duplicate-instantiation

Conversation

@oliverholworthy
Copy link
Copy Markdown
Contributor

@oliverholworthy oliverholworthy commented Feb 26, 2026

  • ConfigNode.instantiate() unconditionally resolved all nested _target_ configs via _instantiate_value() before applying **kwargs overrides. When callers passed a pre-built object as a kwarg, the nested config was instantiated wastefully and the result immediately discarded.
  • Added a one-line early continue to skip _instantiate_value() for keys already present in kwargs.
  • This eliminates the double-instantiation problem that recipes currently work around (e.g. del cfg_dl.dataset in biencoder, lambda-wrapping collate_fn in LLM fine-tuning).

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?

…figNode

Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>
@oliverholworthy
Copy link
Copy Markdown
Contributor Author

/ok to test b564933

Copy link
Copy Markdown
Contributor

@akoumpa akoumpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @oliverholworthy !

@akoumpa
Copy link
Copy Markdown
Contributor

akoumpa commented Feb 26, 2026

pipeline passed in https://github.com/NVIDIA-NeMo/Automodel/actions/runs/22453694117/job/65035858440 rerunning with docs-only to bypass codecov not reporting status

@akoumpa
Copy link
Copy Markdown
Contributor

akoumpa commented Feb 26, 2026

/ok to test b564933

@thomasdhc thomasdhc disabled auto-merge February 26, 2026 20:54
@thomasdhc thomasdhc merged commit 4b416b6 into main Feb 26, 2026
92 checks passed
@thomasdhc thomasdhc deleted the oholworthy/config-node-duplicate-instantiation branch February 26, 2026 20:54
linnanwang pushed a commit that referenced this pull request Apr 24, 2026
…figNode (#1397)

Signed-off-by: Oliver Holworthy <1216955+oliverholworthy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-only With great power comes great responsibility.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants