-
Notifications
You must be signed in to change notification settings - Fork 45
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
Setup LightningCLI trainer script #24
Conversation
Parsing of command line options, yaml/jsonnet config files and/or environment variables based on argparse! Also adding the signatures extras (which includes typeshed-client).
Setting up the command-line interface to run Lightning. Created a placeholder BaseDataModule and BaseLitModule to hold the data pipeline and model architecture respectively under the src/ folder. Documented in the main README.md on how to run the LightningCLI commands, and also created a src/README.md to document what the python modules in that folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, since we're trying to move fast, I'll leave this open for about a day for reviews, otherwise will merge directly 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to put these files under src/
? Or do folks prefer another folder name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am good with putting under src/
cli = LightningCLI( | ||
model_class=BaseLitModule, | ||
datamodule_class=BaseDataModule, | ||
save_config_callback=save_config_callback, | ||
seed_everything_default=seed_everything_default, | ||
trainer_defaults=trainer_defaults, | ||
args=args, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to discuss on whether LightningCLI is ok to use, or if we want to go with something a bit more customizable like Hydra (note: not exactly apples-to-apples comparison, see e.g. ashleve/lightning-hydra-template#443 (comment)).
We could also stick with LightningCLI for now (since it's built-in to Lightning), and move on to something else later when there's a need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you suggested, let us start with lightning-cli
& if we feel constrained anytime during the project, we can switch to hydra
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am good with putting under src/
import torch | ||
|
||
|
||
# %% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have the artifact %%
before starting a class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are used to make code blocks in Python scripts, and are supported by a few editors, see https://jupytext.readthedocs.io/en/latest/formats-scripts.html#the-percent-format.
cli = LightningCLI( | ||
model_class=BaseLitModule, | ||
datamodule_class=BaseDataModule, | ||
save_config_callback=save_config_callback, | ||
seed_everything_default=seed_everything_default, | ||
trainer_defaults=trainer_defaults, | ||
args=args, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you suggested, let us start with lightning-cli
& if we feel constrained anytime during the project, we can switch to hydra
.
Thanks @srmsoumya! I"ll merge this in and work on setting up Continuous Integration next. |
Some boilerplate code for the Lightning Trainer we'll be using later to train the neural network.
The Trainer is controlled using LightningCLI v2, and there's a placeholder BaseDataModule (data pipeline) and BaseLitModule (model architecture) in this Pull Request that can be modified later once we have decided on the data and model.
References:
Adapted from developmentseed/chabud2023#8