Louis M
Louis M

Reputation: 4314

Hydra: Referring to a config group option in the parent directory

I can't find a way to load config group options from parent directories in hydra. E.g. here I want to load the config group option from datamodule/wikipedia1m.yaml from variant/default.yaml but it does not give what I expected.

Here are my hydra setup:


conf
├── config.yaml
├── datamodule
│   ├── dummy.yaml
│   └── wikipedia1m.yaml
├── task
│   ├── concat_t5_base.yaml
│   ├── concat.yaml
└── variant
    └── default.yaml

config.yaml

defaults:
  - variant: default
  - _self_

variant/default.yaml

# @package _global_

task: concat_t5_base
datamodule: wikipedia1m

Resulting config:

  task: concat_t5_base
  datamodule: wikipedia1m

Expected config:

  task:
    _target_: xxx
    model_name: t5-base
    shuffle_labels: true
  datamodule:
    _target_: xxx
    num_workers: 4
    batch_size: 8

Any idea on how to achieve the expected behaviour?

Upvotes: 3

Views: 2143

Answers (1)

Omry Yadan
Omry Yadan

Reputation: 33646

This is supported in Hydra 1.1 and newer. You need a defaults list in variant.yaml, and you need to refer to the parent parent with a / prefix.

What you are trying to do is described in the Configuring Experiments page.

Upvotes: 3

Related Questions