facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.41k stars 609 forks source link

[Feature Request] Concatenating parameter sweeps #2851

Open Sola85 opened 4 months ago

Sola85 commented 4 months ago

🚀 Feature Request: Concatenating parameter sweeps

Issues #1918 and #1258 have already proposed adding "tuple sweeps" where a fixed list of parameter combinations is used for a sweep instead of a cartesian product of all parameter lists. These issues are still open because work arounds exist, like defining a top-level dict of all desired parameter combination and using interpolation.

However, to my understanding, this means that you have to manually define all parameter combinations you want so sweep over. This means that there are three options:

I would like to propose the following new option, which would solve the two issues mentioned above, while at the same time being more flexible than the proposed workarounds: E.g.:

hydra:
  mode: MULTIRUN
  sweeper:
    params1:
      variable1: 1, 5, 8, 19, 32
      variable2: 0, 1, 800, 1000, 3000
      variable3: true
    params2:
      variable1: 0
      variable2: -1, -2, -3
      variable3: false

Here we have multiple params fields, that are treated independently from each other. Within one params field, everything behaves as usual with the cartesian product. The above example would generate 5*5+3 jobs. You could also call this "sweeping over the sweeper params".

This has a few advantages:

In case I missed something and a solution to this already exists, I'd be happy to close this issue.

gil2rok commented 4 months ago

Great idea! +1

libokj commented 3 months ago

It does sound like a pretty general solution to all those paired sweep problems. It's been a pain to create extra sweep configs to accommodate those sweeps for me, where I need to pair a pytorch lightning model checkpoint to its model config file. For better parsing and look, maybe using a list of dictionaries should be considered? Also, correct me if I'm wrong - I thought spaces were not allowed in a sweep variable, that it must be purely comma-seperated? If this solution becomes widely accepted, I'd be more than happy to help with implementation.

hydra:
  mode: MULTIRUN
  sweeper:
    params:
      - variable1: 1,5,8,19,32
        variable2: 0,1,800,1000,3000
        variable3: true
      - variable1: 0
        variable2: -1,-2,-3
        variable3: false
stefangstark commented 1 month ago

this would be great, and it would be nice if there is a way to include variables that are shared across all concatenated sweeps

florian6973 commented 3 weeks ago

Any update by any chance?