[Train][Doc] LightningTrainer end-2-end starter example [no_early_kickoff]#33494
Merged
richardliaw merged 58 commits intoMar 24, 2023
Merged
Conversation
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com> Co-authored-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
… air/lightning_log_and_checkpoint
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
justinvyu
reviewed
Mar 22, 2023
Contributor
justinvyu
left a comment
There was a problem hiding this comment.
Looks good!
Can we also add usage of the LightningPredictor at the end? As a separate path to trainer.test.
Comment on lines
250
to
+261
| args = ["--path", "doc/source/train/examples/pytorch/pytorch_resnet_finetune.ipynb"] | ||
| ) | ||
|
|
||
| py_test( | ||
| name = "lightning_mnist_example", | ||
| size = "large", | ||
| main = "test_myst_doc.py", | ||
| srcs = ["test_myst_doc.py"], | ||
| tags = ["exclusive", "team:ml", "gpu", "ray_air"], | ||
| data = ["//doc/source/train/examples/lightning:lightning_mnist_example"], | ||
| args = ["--path", "doc/source/train/examples/lightning/lightning_mnist_example.ipynb"] | ||
| ) |
Contributor
There was a problem hiding this comment.
Can we use py_test_run_all_notebooks for these two?
Member
Author
There was a problem hiding this comment.
Actually these two ipynb files are in different folders. We can't aggregate them in a single build object.
justinvyu
reviewed
Mar 22, 2023
Co-authored-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
…air/lightning_e2e_example
Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Member
Author
@justinvyu Seems that it's much complex to use from ray.train.lightning import LightningPredictor
predictor = LightningPredictor.from_checkpoint(checkpoint, MNISTClassifier, use_gpu=False)
def accuracy(logits, labels):
preds = np.argmax(logits, axis=1)
correct_preds = np.sum(preds == labels)
return correct_preds
corrects = total = 0
for batch in test_dataloader:
inputs, labels = batch
inputs, labels = inputs.numpy(), labels.numpy()
logits = predictor.predict(inputs)["predictions"]
total += labels.size
corrects += accuracy(logits, labels)
print("Accuracy: ", corrects / total) |
Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
richardliaw
reviewed
Mar 24, 2023
…o air/lightning_e2e_example
elliottower
pushed a commit
to elliottower/ray
that referenced
this pull request
Apr 22, 2023
…koff] (ray-project#33494) Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com> Co-authored-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: elliottower <elliot@elliottower.com>
ProjectsByJackHe
pushed a commit
to ProjectsByJackHe/ray
that referenced
this pull request
May 4, 2023
…koff] (ray-project#33494) Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com> Co-authored-by: Justin Yu <justinvyu@anyscale.com> Signed-off-by: Jack He <jackhe2345@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
We need to provide end-to-end examples for users to onboard LightningTrainer. This is a starter example which uses
pl.LightningDataModuleas input data sourcepl.Trainer.test()for evaluationWe'll also have an advanced example using Ray Data + BatchPredictor + Ray Tune later.
Related issue number
Checks
git commit -s) in this PR.scripts/format.shto lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/under thecorresponding
.rstfile.