pytorch / pytorch/rl

[Feature Request] Track and shrink Hydra Config/class kwarg parity gaps

Open
#4,228 1 comment 0 reactions 1 assignee View on GitHub

@aswanth-07 is already working on this.

Since Sep 6, 2026.

Dominant language
Python
Stars
3.6k
Forks
487
Avg merge
1d 1h
Merged PRs (30d)
207

Description

Motivation

This is a tracking issue, not a request to close the ~60 Hydra Config / class kwarg-parity gaps in one PR.

Agents.md §14 (Config / class parity) says every wrapped-class __init__ kwarg must appear on the matching *Config with the same default, be popped in the factory, and be forwarded. A missing field is dropped silently by Hydra: the user thinks they set it, the constructor never sees it.

test/test_configs.py already encodes that rule, but it also carries a large allowlist and deliberately does not check default-value equality. Those gaps should be tracked here and closed one area at a time.

Solution

Keep this issue as the tracker. Confirm the process below (or amend it):

  1. Leave _CONFIG_PARITY_KNOWN_GAPS in place as the working list.
  2. One follow-up PR per area (replay buffers, collectors, transforms, env libs, …). Each PR adds the missing Config fields, forwards them, and removes only those names from the allowlist.
  3. Turn on default-equality asserts for an area once its names are gone from the allowlist.
  4. Do not dump the entire allowlist into a single PR.

Alternatives

  • Close the allowlist in one PR. That mixes unrelated modules, is hard to review, and is the opposite of what this issue is for.
  • Drop the parity test. That would make the silent-Hydra-drop problem worse.

Additional context

Allowlist (62 names) in test/test_configs.py:152-217:

_CONFIG_PARITY_KNOWN_GAPS = frozenset(
    {
        "ActionMaskConfig",
        "AggregatorConfig",
        ...
        "MultiSyncCollectorConfig",
        ...
        "PrioritizedSliceSamplerConfig",
        ...
        "ReplayBufferConfig",
        ...
        "VecNormConfig",
        "VecNormV2Config",
        "WriterConfig",
    }
)

Default equality is explicitly not enforced (test/test_configs.py:278-285):

    - Only field-name presence is checked; default-value *equality* between a
      Config field and the corresponding ``__init__`` kwarg is NOT enforced, so
      a Config default that drifts from the constructor's default still passes.
    - Wrapped ``__init__`` signatures made up purely of ``*args``/``**kwargs``
      expose no named parameters to diff, so their configs pass vacuously, and
      a ``**kwargs`` catch-all next to named parameters hides any kwarg that is
      only reachable through it.

Concrete gaps already visible in this checkout:

Replay buffers. ReplayBuffer.__init__ accepts transport and transport_options (torchrl/data/replay_buffers/replay_buffers/base.py:400-401). ReplayBufferConfig (torchrl/trainers/algorithms/configs/data.py:399-424) omits both. A Hydra user setting transport: ray has no effect.

Collectors. CollectorConfig exposes auto_register_policy_transforms, pre_collect_hook, post_collect_hook, compact_obs (collectors.py:79-82). MultiCollector.__init__ accepts the same four (torchrl/collectors/_multi_base.py:472-475). MultiSyncCollectorConfig (collectors.py:151-198) and MultiAsyncCollectorConfig (collectors.py:212-263) omit all four.

*args, **kwargs blind spot. MultiAsyncCollector.__init__ is (torchrl/collectors/_multi_async.py:131-132):

def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

The parity test therefore cannot see MultiCollector's kwargs and MultiAsyncCollectorConfig is not even on the allowlist. It can pass while missing the same fields as MultiSyncCollectorConfig.

The test docstring (test/test_configs.py:294-297) already says the allowlist should only shrink.

Checklist

  • I have checked that there is no similar issue in the repo (required)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.