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

Add _decorator_ keyword to Monai Bundle Configuration #7563

Open
johnzielke opened this issue Mar 20, 2024 · 0 comments · May be fixed by #7730
Open

Add _decorator_ keyword to Monai Bundle Configuration #7563

johnzielke opened this issue Mar 20, 2024 · 0 comments · May be fixed by #7730
Labels
enhancement New feature or request Feature request

Comments

@johnzielke
Copy link
Contributor

johnzielke commented Mar 20, 2024

When using Monai Bundle Configuration, I frequently have the need to wrap some component or function call. Examples include torch.compile or loading some weights in the instantiated model/modify a layer.
If I now want to use torch.compile for my model, a key such previously as model#channels now needs to be changed to model#model#channels. This makes referring to the config more error-prone, less intuitive and repetitive (IMHO). If I ever decide to not use torch.compile anymore, I now need to either use an identity lambda under model or I need to modify all configs again.

Describe the solution you'd like
I could imagine a keyword such as _decorator_ or _wrapper_ in addition to the existing special words. Under this, a single or (maybe a list of) decorators could be defined that are added to the item in question when it is instantiated.

Describe alternatives you've considered
Keep using nested configs.

Additional context
Now I fully understand that there are two sides to this coin. And adding this feature has potential drawbacks such as making the config more complicated, it might lead to errors where there are unexpected decorators in place when overwriting parts of a config, and more possible support requests using this functionality.
This feature could be implemented without breaking changes AFAIK, and should be very clearly marked as experimental to gather support and provide the option to change or remove it in the future if it does not provide the desired outcomes.

If there is support for such a feature and we agree on a API, I'd be happy to contribute to MONAI again and create a PR for this feature.

@KumoLiu KumoLiu added enhancement New feature or request Feature request labels Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants