rl icon indicating copy to clipboard operation
rl copied to clipboard

[Test] Add automated Config/Class kwarg-parity checks for Hydra configs

Open theap06 opened this issue 4 months ago • 1 comments

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:

  • TestConfigClassParity walks every leaf *Config dataclass reachable from torchrl.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_GAPS turns 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).

theap06 avatar Jul 25 '26 06:07 theap06

:link: Helpful Links

:test_tube: 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.

:x: 5 New Failures

As of commit 1038a3e7f03dea700ad7654651a13b6c16e9ee80 with merge base 4bf281a7c7cb8aad6c1e49a657d7cec64610f266 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

pytorch-bot[bot] avatar Jul 25 '26 06:07 pytorch-bot[bot]