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

[Doc|Train] Add Pytorch ResNet finetuning starter example #32936

Merged

Conversation

woshiyyya
Copy link
Member

@woshiyyya woshiyyya commented Mar 1, 2023

Why are these changes needed?

This example aims to provide an example of how to do finetuning on GPUs with TorchTrainer.

- Ray Train
   - examples
     - ...
     - Finetuning a Pytorch Image Classifier with Ray AIR

Task: Image Classification
Model: Pretrained Pytorch ResNet-50
Dataset: hymenoptera_data (2-class, ants and bees)

The workflow is:

  • Download hymenoptera_data dataset and create a ray dataset
  • Define the training loop (Load a pre-trained model)
  • Define the ScalingConfig and RunConfig
  • Build a TorchTrainer and run Trainer.fit()
  • Load the model weights from checkpoint file, and run an evaluation loop in pure PyTorch.

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Yunxuan Xiao and others added 6 commits February 5, 2023 18:21
Signed-off-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Signed-off-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Signed-off-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya changed the title Doc/resnet finetune starter example [Doc] Add Pytorch ResNet finetuning starter example Mar 1, 2023
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason we need to use ray data here?

Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya
Copy link
Member Author

any reason we need to use ray data here?

I've replaced ray data with prepare_dataloader().

@amogkam
Copy link
Contributor

amogkam commented Mar 1, 2023

should this be in train examples or air examples?

@woshiyyya
Copy link
Member Author

woshiyyya commented Mar 1, 2023

should this be in train examples or air examples?

I created a bookmark under the "Ray Train - Examples" section in the document.

Regarding the .ipynb file, I placed it under ray-air/examples since I could not find any other notebooks under the doc/source/train/examples folder. Is it acceptable to keep it there? Or we should move it?

Update:
I've put this example under thedoc/source/train/examples folder.

@richardliaw
Copy link
Contributor

I think we should put it in train examples for now.

woshiyyya and others added 3 commits March 3, 2023 12:47
Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya force-pushed the doc/resnet_finetune_starter_example branch from 1954168 to d0392b0 Compare March 9, 2023 19:20
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya force-pushed the doc/resnet_finetune_starter_example branch from d0392b0 to ef3a5ad Compare March 9, 2023 20:31
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya force-pushed the doc/resnet_finetune_starter_example branch from ee8cb67 to a2a3c4e Compare March 9, 2023 22:50
Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya added the train Ray Train Related Issue label Mar 10, 2023
@woshiyyya woshiyyya changed the title [Doc] Add Pytorch ResNet finetuning starter example [Doc|Train] Add Pytorch ResNet finetuning starter example Mar 10, 2023
Copy link
Contributor

@justinvyu justinvyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's pretty much ready - have some minor suggestions:

One question - should we showcase TorchTrainer(resume_from_checkpoint) as the way to take in the AIR checkpoint in this example?

woshiyyya and others added 3 commits March 13, 2023 01:48
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Signed-off-by: Yunxuan Xiao <xiaoyunxuan1998@gmail.com>
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
@woshiyyya woshiyyya requested a review from richardliaw March 16, 2023 01:37
Signed-off-by: woshiyyya <xiaoyunxuan1998@gmail.com>
Copy link
Contributor

@richardliaw richardliaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean and concise!

@richardliaw richardliaw merged commit 305dc2a into ray-project:master Mar 20, 2023
edoakes pushed a commit to edoakes/ray that referenced this pull request Mar 22, 2023
…t#32936)

Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
Signed-off-by: Edward Oakes <ed.nmi.oakes@gmail.com>
clarng pushed a commit to clarng/ray that referenced this pull request Mar 23, 2023
…t#32936)

Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
chaowanggg pushed a commit to chaowanggg/ray-dev that referenced this pull request Apr 4, 2023
…t#32936)

Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
Signed-off-by: chaowang <chaowang@anyscale.com>
elliottower pushed a commit to elliottower/ray that referenced this pull request Apr 22, 2023
…t#32936)

Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
Signed-off-by: elliottower <elliot@elliottower.com>
ProjectsByJackHe pushed a commit to ProjectsByJackHe/ray that referenced this pull request May 4, 2023
…t#32936)

Co-authored-by: angelinalg <122562471+angelinalg@users.noreply.github.com>
Co-authored-by: Justin Yu <justinvyu@anyscale.com>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MacBook-Pro.local>
Co-authored-by: Yunxuan Xiao <yunxuanx@Yunxuans-MBP.local.meter>
Signed-off-by: Jack He <jackhe2345@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
train Ray Train Related Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants