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

Setup LightningCLI trainer script #24

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Setup LightningCLI trainer script #24

merged 3 commits into from
Nov 9, 2023

Conversation

weiji14
Copy link
Contributor

@weiji14 weiji14 commented Nov 9, 2023

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

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.
@weiji14 weiji14 added the enhancement New feature or request label Nov 9, 2023
@weiji14 weiji14 added this to the v0 Release milestone Nov 9, 2023
@weiji14 weiji14 requested a review from a team November 9, 2023 03:18
@weiji14 weiji14 self-assigned this Nov 9, 2023
@weiji14 weiji14 marked this pull request as ready for review November 9, 2023 04:14
Copy link
Contributor Author

@weiji14 weiji14 left a 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 👼

Copy link
Contributor Author

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?

Copy link
Collaborator

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/

Comment on lines +29 to +36
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,
)
Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Collaborator

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


# %%
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Comment on lines +29 to +36
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,
)
Copy link
Collaborator

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.

@weiji14
Copy link
Contributor Author

weiji14 commented Nov 9, 2023

Thanks @srmsoumya! I"ll merge this in and work on setting up Continuous Integration next.

@weiji14 weiji14 merged commit 503a723 into main Nov 9, 2023
@weiji14 weiji14 deleted the model/base branch November 9, 2023 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants