Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of an explicit overrides node #48

Open
omry opened this issue Mar 17, 2021 · 11 comments
Open

Usage of an explicit overrides node #48

omry opened this issue Mar 17, 2021 · 11 comments

Comments

@omry
Copy link

omry commented Mar 17, 2021

Heya,

I think this not a great idea, happy to discuss why:

max_horizon = cfg.overrides.get(

@luisenp
Copy link
Contributor

luisenp commented Mar 18, 2021

Hey, curious to know why.

@omry
Copy link
Author

omry commented Mar 18, 2021

The core idea behind Hydra is that it gives you the config you need.
The app should not worry about overrides and such, it should just get the config it needs to consume.

Is there a reason you prefer this over offloading this logic to Hydra's config composition?

@luisenp
Copy link
Contributor

luisenp commented Mar 18, 2021

I'm still using Hydra composition, but maybe the name overrides is misleading?

The reason for this config group (overrides) is that I can give users default hyperparameter values that work well for each specific environment, in separate files. Maybe cfg.hyperparameters is a clearer name?

Of course, if there is a better pattern for this I'm happy to use it, I couldn't find one at the time I wrote this.

@natolambert
Copy link
Contributor

I uploaded a version that uses nested defaults to get around overrides specifying algorithm and model
https://github.com/natolambert/conf-structure/tree/main/conf

@omry
Copy link
Author

omry commented Mar 18, 2021

I'm still using Hydra composition, but maybe the name overrides is misleading?

The reason for this config group (overrides) is that I can give users default hyperparameter values that work well for each specific environment, in separate files. Maybe cfg.hyperparameters is a clearer name?

Of course, if there is a better pattern for this I'm happy to use it, I couldn't find one at the time I wrote this.

How you represent the configs in the config dir is one thing, what the application is getting is another.
The version uploaded by @natolambert is using nested config groups (not nested defaults) and this pattern which incidentally was created specifically for this use case :).

Hydra 1.1 will actually have nested default lists, which will probably offer an even cleaner solution for those.
It will also clean up the syntax of the pattern Nathan is using.
You can try Hydra 1.1 dev release, in fact as your project is still in development I recommend that you switch to it already.
The dev release is stable enough and there aren't going to be many changes before it gets to a release candidate.

@luisenp
Copy link
Contributor

luisenp commented Mar 18, 2021

I'm a bit confused by this sentence:

"How you represent the configs in the config dir is one thing, what the application is getting is another."

What is this other thing the application is getting? I'm using exactly the configuration that I specify in my yaml file. Or, on second look, are you referring to the fact that I'm using another config path as a default (cfg.algorithm.agent.planning_horizon)? If so, then I can see why that's not desirable, I can revisit this.

@omry
Copy link
Author

omry commented Mar 18, 2021

What I am going for is that the config the application is getting should be exactly what it needs.
The application needs a value, it should get it in the place it expects it.
it should not apply override logic to get the right value, Hydra can do it when it creates the config object.

If you buy into that, the question becomes: "How do we get Hydra to build the config object you need?"

(Of course, if your application actually needs both values for some reason what you are doing is fine, but I suspect you are using one or the other. never both).

@luisenp
Copy link
Contributor

luisenp commented Mar 20, 2021

@natolambert Thanks for sharing. Keep in mind that the original reason I went with the current design is to avoid having a bunch of dynamics_model and optimizer folders replicated for each environment, since most of them will look exactly the same. I'd rather have some default configurations for model and planner, then for each experiment (i.e., combination of model+algorithm+env) I can just change some of the default parameters (for all groups) in a single file. This seems to me way easier to read.

My ideal scenario would be that Hydra lets me do something like the structure below. @omry is this already possible?

model_cfg
  -param1: default_model_p1
  -param2: default_model_p2

planner_cfg:
  -param1: default_planner_p1
  -param2: default_planner_p2

experiment_specific_cfg:
  -model_cfg.param1 = override_with_something
  -planner_cfg.param2 = override_with_something_else

PS: Writing this, I think cfg.experiment is probably a better name than cfg.overrides.

@omry
Copy link
Author

omry commented Mar 20, 2021

Hydra 1. 1 offers several ways to avoid config repetition:

Look at those 3 docs.

The last one is a cleaner form of what mbrl was using (that predated anything close to nested defaults, which enables the first two).
Reading your description of the problem, I think what you are really after is possible by extending configs.

@luisenp
Copy link
Contributor

luisenp commented Mar 20, 2021

Thanks @omry, I'll take a look at those!

@omry
Copy link
Author

omry commented Mar 20, 2021

Cool. They are all implementations of what is described in https://hydra.cc/docs/next/advanced/defaults_list, be sure to read it first.
(It's a bit more dense, but will give you a solid foundation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants