rl
rl copied to clipboard
[Test] Add automated Config/Class kwarg-parity checks for Hydra configs
Summary
CLAUDE.md section 14 requires every kwarg of a wrapped class's __init__ to
appear as a field on its Hydra *Config dataclass (same default), but only
one 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 named by its_target_(via the factory's return-type annotation for the_make_*/make_*indirection cases), and asserts every required constructor parameter has a same-named Config field.- 128 classes pass strictly today and will regress immediately if a 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.
- 62 classes have a pre-existing gap and are marked
xfail(strict=True)as a ratchet: fixing one of them without also removing it from_CONFIG_PARITY_KNOWN_GAPSturns CI red (XPASS), so the allowlist can only shrink, never silently grow. - 5 configs are skipped with an explicit reason instead of silently
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 exists in the codebase (StorageEnsembleWriterConfig,KLRewardTransformConfig,LionConfig— pre-existing breakage, out of scope here, left visible via the skip reason rather than swept under a blanket exclusion).
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4048
- :page_facing_up: Preview Python docs built from this PR
Note: Links to docs will display an error until the docs builds have been completed.
:x: 5 New Failures
As of commit 1038a3e7f03dea700ad7654651a13b6c16e9ee80 with merge base 4bf281a7c7cb8aad6c1e49a657d7cec64610f266 ():
NEW FAILURES - The following jobs have failed:
- SOTA Tests on Linux / tests (3.10, 13.0, 1) / linux-job (gh)
RuntimeError: Command docker exec -t ca1f48dfefcd8d5667b69e91da79dd2a7e53566d90b4043fd45e994aa8942a68 /exec failed with exit code 1 - SOTA Tests on Linux / tests (3.10, 13.0, 2) / linux-job (gh)
RuntimeError: Command docker exec -t f64eef64cb88214e0f636345f48bd8e063f1f188a2cc5c77b249708543623702 /exec failed with exit code 1 - Unit-tests on Linux / tests-cpu (3.10, bulk) / linux-job (gh)
test/test_configs.py::TestConfigClassParity::test_wrapped_class_kwargs_have_config_fields[LBFGSConfig] - Unit-tests on Linux / tests-cpu (3.13, bulk) / linux-job (gh)
test/test_configs.py::TestConfigClassParity::test_wrapped_class_kwargs_have_config_fields[LBFGSConfig] - Unit-tests on Linux / tests-cpu (3.14, bulk) / linux-job (gh)
test/test_configs.py::TestConfigClassParity::test_wrapped_class_kwargs_have_config_fields[LBFGSConfig]
This comment was automatically generated by Dr. CI and updates every 15 minutes.