Motivation
When using the Hydra config system to instantiate collectors with policies that include
exploration modules (e.g., AdditiveGaussianModule), the exploration module cannot be
properly configured because it requires an action_spec at construction time. However,
in config-based workflows, the policy is instantiated before the environment is created
inside the collector, making the spec unavailable.
The workflow that should be possible:
- Policy configs (including exploration modules) are defined in YAML
- Hydra instantiates the policy from configs
- The collector creates environments internally
- The exploration module needs the env's action_spec to clip/bound noisy actions
Currently, this fails for several reasons:
AdditiveGaussianModule.__init__ requires that spec is not None.
- The exploration module's spec requires access to the environment, but the environment is instantiated inside the collector. There is currently no way to set the spec on the policy from inside the collector.
Solution
- Allow
AdditiveGaussianModule (and other exploration modules) to accept spec=None at construction
- Add a
spec property setter for delayed initialization
- Inside
Collector.__init__, instantiate the environment and set the spec property on any exploration modules which exist in the policy.
Alternatives
Additional context
Checklist
Motivation
When using the Hydra config system to instantiate collectors with policies that include
exploration modules (e.g.,
AdditiveGaussianModule), the exploration module cannot beproperly configured because it requires an
action_specat construction time. However,in config-based workflows, the policy is instantiated before the environment is created
inside the collector, making the spec unavailable.
The workflow that should be possible:
Currently, this fails for several reasons:
AdditiveGaussianModule.__init__requires thatspecis not None.Solution
AdditiveGaussianModule(and other exploration modules) to acceptspec=Noneat constructionspecproperty setter for delayed initializationCollector.__init__, instantiate the environment and set thespecproperty on any exploration modules which exist in the policy.Alternatives
Additional context
Checklist