-
Notifications
You must be signed in to change notification settings - Fork 1
Example: PyTorch Lightning integration #17
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
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR integrates a new PyTorch Lightning example into the repository by adding a detailed example notebook and script (with supporting requirements and run script) that demonstrate NeptuneScaleLogger usage, and updates the CI workflows to include these assets in automated tests. Class Diagram for LitModel (PyTorch Lightning Module)classDiagram
class LightningModule {
<<PyTorch Lightning>>
+log()
+log_dict()
}
class LitModel {
+List training_step_outputs
+List validation_step_outputs
+List test_step_outputs
+int linear
+float learning_rate
+float decay_factor
+torch.nn.Linear layer_1
+torch.nn.Linear layer_2
+torch.nn.Linear layer_3
+NeptuneScaleLogger logger
+__init__(linear, learning_rate, decay_factor)
+forward(x) Tensor
+configure_optimizers() List
+training_step(batch) Dict
+on_train_epoch_end()
+validation_step(batch, batch_idx) Dict
+on_validation_epoch_end()
+test_step(batch) Dict
+on_test_epoch_end()
}
LightningModule <|-- LitModel
Class Diagram for MNISTDataModule (PyTorch Lightning DataModule)classDiagram
class LightningDataModule {
<<PyTorch Lightning>>
}
class MNISTDataModule {
+int batch_size
+tuple normalization_vector
+Dataset mnist_train
+Dataset mnist_val
+Dataset mnist_test
+__init__(batch_size, normalization_vector)
+prepare_data()
+setup(stage)
+train_dataloader() DataLoader
+val_dataloader() DataLoader
+test_dataloader() DataLoader
}
LightningDataModule <|-- MNISTDataModule
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @LeoRoccoBreedt - I've reviewed your changes - here's some feedback:
- Consider refactoring the Lightning model and DataModule definitions into a shared utility module to avoid duplicating the same code in both the notebook and script.
- The installation instructions rely on a custom PyTorch Lightning fork; please clarify version compatibility or plan to switch to the official release once supported to reduce long-term maintenance overhead.
Here's what I looked at during the review
- 🟡 General issues: 5 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
integrations-and-supported-tools/pytorch-lightning/scripts/Neptune_Pytorch_Lightning.py
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/scripts/Neptune_Pytorch_Lightning.py
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/scripts/Neptune_Pytorch_Lightning.py
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/scripts/Neptune_Pytorch_Lightning.py
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/scripts/Neptune_Pytorch_Lightning.py
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
"source": [ | ||
"## Define Lightning model\n", | ||
"\n", | ||
"To log metrics to Neptune, define a Lightning model with both inbuilt logging (`self.log()` or `self.log_dict()`) and custom logging (`neptune_logger.run`).\n", |
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.
How about we split this info into bullets? Something like:
To log metrics to Neptune, define a Lightning model. You can use:
- inbuilt logging methods, such as
self.log()
orself.log_dict()
neptune_logger.run
, a reference to the Neptune run object created by theNeptuneScaleLogger()
instance. + the rest of the info on it
Plus maybe a link to all Run methods? https://docs.neptune.ai/run/#methods
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.
@szaganek I updated based on comments. Let me know if all good now.
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 suggested just a tiny change in another comment.
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
Co-authored-by: Edyta <142720610+szaganek@users.noreply.github.com> Signed-off-by: Leo Breedt <101509998+LeoRoccoBreedt@users.noreply.github.com>
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
integrations-and-supported-tools/pytorch-lightning/notebooks/Neptune_PyTorch_Lightning.ipynb
Outdated
Show resolved
Hide resolved
Co-authored-by: Edyta <142720610+szaganek@users.noreply.github.com> Signed-off-by: Leo Breedt <101509998+LeoRoccoBreedt@users.noreply.github.com>
" <img alt=\"Open in GitHub\" src=\"https://img.shields.io/badge/Open_in_GitHub-blue?logo=github&labelColor=black\">\n", | ||
"</a><a target=\"_blank\" href=\"https://scale.neptune.ai/o/examples/org/pytorch-lightning/runs/table?viewId=9ea6121c-42a7-4ece-83b2-c591044837e7&detailsTab=charts&dash=table&type=experiment\"> \n", | ||
" <img alt=\"Explore in Neptune\" src=\"https://neptune.ai/wp-content/uploads/2024/01/neptune-badge.svg\">\n", | ||
"</a><!<a target=\"_blank\" href=\"https://docs.neptune.ai/integrations/pytorch_lightning\">\n", |
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.
"</a><!<a target=\"_blank\" href=\"https://docs.neptune.ai/integrations/pytorch_lightning\">\n", | |
"</a><a target=\"_blank\" href=\"https://docs.neptune.ai/integrations/pytorch_lightning\">\n", |
Description
Include a summary of the changes and the related issue.
Related to: <ClickUp/JIRA task name>
Any expected test failures?
Python 3.13 not supported for PyTorch (yet).
Add a
[X]
to relevant checklist items❔ This change
✔️ Pre-merge checklist
🧪 Test Configuration
Summary by Sourcery
Add a PyTorch Lightning integration example notebook for Neptune Scale and update the CI workflow to run tests on it.
New Features:
CI:
Summary by Sourcery
Provide a Neptune Scale integration example for PyTorch Lightning by adding a Jupyter notebook, a Python script with supporting requirements and run script, and update CI workflows to test the new integration.
New Features:
CI: