Skip to content

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

Open
theap06 wants to merge 1 commit into
pytorch:mainfrom
theap06:ci/config-class-parity
Open

[Test] Add automated Config/Class kwarg-parity checks for Hydra configs#4048
theap06 wants to merge 1 commit into
pytorch:mainfrom
theap06:ci/config-class-parity

Conversation

@theap06

@theap06 theap06 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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).

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.
@pytorch-bot

pytorch-bot Bot commented Jul 25, 2026

Copy link
Copy Markdown

🔗 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 Failure

As of commit 36e3e74 with merge base ae421b9 (image):

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.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 25, 2026
@github-actions github-actions Bot added Tests Incomplete or broken unit tests Trainers labels Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Tests Incomplete or broken unit tests Trainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant