fix: speedup minimize and minimize-check in config_cli#1964
Conversation
Signed-off-by: Hemil Desai <hemild@nvidia.com>
📝 WalkthroughWalkthroughThe PR refactors Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@tools/config_cli.py`:
- Around line 370-389: The code loads bases asymmetrically: when base_override
is set it uses OmegaConf.load(base_path) (no inheritance expansion) but when
inferred it uses load_config(...) (fully expanded), and the shared
base_config_cache can return the wrong shape; change the explicit---base branch
to use the same expansion path as the inferred branch (call
load_config(str(base_path)) or otherwise expand defaults) before caching so
base_config_cache always stores a fully-resolved container; update references to
base_cfg_raw/base_resolved and keep using the same cache key (base_path) so
lookup behavior is consistent for both the base_override branch and the
_infer_base_from_defaults branch.
🧹 Nitpick comments (1)
tools/config_cli.py (1)
350-422: Significant code duplication between_minimize_oneand_minimize_check_one.Both helpers share nearly identical logic for: loading the child config, resolving the base (explicit vs. inferred), cache lookup/population, pruning, and reconstructing the
defaultskey. The main difference is that one writes/prints the result while the other compares it against the current file.Consider extracting a shared helper (e.g.,
_resolve_and_prune(child_path, base_override, base_config_cache) -> tuple[dict, bool, Path]) that returns the pruned config, whether the base was inferred, and the base path. Both_minimize_oneand_minimize_check_onewould then only contain their divergent "emit vs. compare" logic.Also applies to: 500-591
The minimize-check llm recipes pre-commit hook was invoking ./tools/config_cli.py minimize-check once per recipe file in a bash for-loop. With ~100 recipe YAML files, this spawned 98 separate uv run --script processes, each paying the full Python/uv startup and omegaconf import cost.
Changes:
are cached across files, so shared parents (e.g., dpo.yaml) are only loaded once.
Summary by CodeRabbit