-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Improve LightningCLI #15115
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
Improve LightningCLI #15115
Comments
I am investigating what to do about this. |
@gianmarcoaversanoenx the second example with For the torchvision example, again the proper fix is that they add type hints to the transforms. I checked to see what is the state of that, see pytorch/vision#2025 comment. Seems there is still some time to go until this happens. Since for projects like torchvision the types take time, I created a pull request to support classes when the type is Do note that supporting instantiation with type |
Hello I still have a question: I do have type hints in place for everything, but why are they so necessary? I mean, with Hydra, one can simply write whatever and it works out of the box. Example: trainer:
callbacks:
- _target_: my_package.my_module.CoolCallback
arg1: val1
arg2: val2
arg3:
_target_: torchvision.transform.Compose
# etc and Hydra will simply try to import whatever is specified in the |
A purpose of the parser is that when given wrong input it fails as early as possible with a useful message. And the parser uses the type hints to know how to validate the input. Imagine that you add the wrong value in a config, str instead of int, this value is used after the first epoch ends, and an epoch takes hours. If the code does have a type hint then the CLI will fail after a couple of seconds saying that an int was expected. Without a type hint it will fail after hours and most likely with a not easy to understand stack trace. |
@gianmarcoaversanoenx will you test and review the pull request? |
Alright! I'll check it out. |
I git-cloned the branch and tried to run my script and all good. See: omni-us/jsonargparse#182 |
@gianmarcoaversanoenx this issue can be closed. There is no need to change anything in pytorch-lightning. Whoever needs this can just update to the latest version of jsonargparse. |
This issue has been automatically marked as stale because it hasn't had any recent activity. This issue will be closed in 7 days if no further activity occurs. Thank you for your contributions - the Lightning Team! |
Uh oh!
There was an error while loading. Please reload this page.
🚀 Feature
Allow declaration of any object in LightningCLI, similarly to Hydra.
Motivation
LightningCLI can't be used for complex cases as is.
Pitch
Setting up the list of
transforms
won't work.Another examples with callbacks
I need lists of non-custom objects, which requires other non-custom objects as input arguments, but no way to achieve it.
Alternatives
If this is already possible, then there should be an example in the doc, which only covers the most basic cases.
cc @carmocca @mauvilsa
If you enjoy Lightning, check out our other projects! ⚡
Metrics: Machine learning metrics for distributed, scalable PyTorch applications.
Lite: enables pure PyTorch users to scale their existing code on any kind of device while retaining full control over their own loops and optimization logic.
Flash: The fastest way to get a Lightning baseline! A collection of tasks for fast prototyping, baselining, fine-tuning, and solving problems with deep learning.
Bolts: Pretrained SOTA Deep Learning models, callbacks, and more for research and production with PyTorch Lightning and PyTorch.
Lightning Transformers: Flexible interface for high-performance research using SOTA Transformers leveraging PyTorch Lightning, Transformers, and Hydra.
The text was updated successfully, but these errors were encountered: