[Test] Add automated Config/Class kwarg-parity checks for Hydra configs - #4048
Open
theap06 wants to merge 1 commit into
Open
[Test] Add automated Config/Class kwarg-parity checks for Hydra configs#4048theap06 wants to merge 1 commit into
theap06 wants to merge 1 commit into
Conversation
CLAUDE.md section 14 requires every kwarg of a wrapped class's __init__ to appear as a field on its Hydra *Config dataclass, but only one narrow, hand-written parity test existed (checkpoint default only, 10 of 212 classes). Adds a generic check that discovers every leaf Config dataclass, resolves the class or factory named by its _target_ (via the factory's return-type annotation where needed), and asserts every required constructor parameter has a same-named Config field. 128 classes pass strictly today and regress immediately if a future kwarg addition isn't mirrored into its Config. 62 classes have a pre-existing gap and are marked xfail(strict=True) as a ratchet: fixing one without removing it from the allowlist turns CI red, so the allowlist can only shrink. 5 configs are skipped with an explicit reason (composite/polymorphic factories with no single wrapped class, or a couple of _target_ values that reference classes which no longer exist). Also adds return-type annotations to 8 _make_*/make_* factory functions that lacked them, needed for the resolution step and independently correct per CLAUDE.md section 5.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4048
Note: Links to docs will display an error until the docs builds have been completed. ❌ 36 New Failures, 20 Unrelated Failures, 1 Unclassified FailureAs of commit 36e3e74 with merge base ae421b9 ( NEW FAILURES - The following jobs have failed:
UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
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.
Summary
CLAUDE.md section 14 requires every kwarg of a wrapped class's
__init__toappear as a field on its Hydra
*Configdataclass (same default), but onlyone narrow, hand-written parity test existed (
test_checkpoint_config_parity,checking a single field's default across 10 of 212 config classes). This adds
a generic, automatically-discovered check:
TestConfigClassParitywalks every leaf*Configdataclass reachable fromtorchrl.trainers.algorithms.configs, resolves the class or factory namedby its
_target_(via the factory's return-type annotation for the_make_*/make_*indirection cases), and asserts every requiredconstructor parameter has a same-named Config field.
future kwarg addition to a wrapped class isn't mirrored into its Config —
closing the exact silent-drift risk CLAUDE.md section 14 calls out.
xfail(strict=True)as a ratchet: fixing one of them without also removingit from
_CONFIG_PARITY_KNOWN_GAPSturns CI red (XPASS), so the allowlistcan only shrink, never silently grow.
passing: two wrap a composite/polymorphic factory with no single
constructor to diff against (
BatchedEnvConfig,TanhNormalModelConfig),and three have a
_target_that references a class which no longer existsin the codebase (
StorageEnsembleWriterConfig,KLRewardTransformConfig,LionConfig— pre-existing breakage, out of scope here, left visible viathe skip reason rather than swept under a blanket exclusion).