- Notifications
You must be signed in to change notification settings - Fork26.3k
PyTorch Workflow Cheatsheet
This is a quick cheatsheet of common operations PyTorch developers use.
git checkout upstream viable/strictgit branch my-awesome-featuregit checkout my-awesome-featureCheckout the PyTorch viable/strict branch. All PyTorch tests are guaranteed to be passing on the viable/strict branch (as opposed to the master branch, where they might not pass). viable/strict lags behind PyTorch's master branch and is automatically advanced whenever a new commit to master passes all tests.More details here
Create a new branch that is based on viable/strict and make some changes to PyTorch.
When you've made some changes to PyTorch, build and test PyTorch. PyTorch has a lot of build flags; if you turn off some of them your build will go faster. The most important one is USE_CUDA, which defaults to 1. If your machine doesn't have a GPU, you probably want to build without CUDA:USE_CUDA=0
USE_KINETO=0 BUILD_CAFFE2=0 USE_DISTRIBUTED=0 USE_NCCL=0 BUILD_TEST=0 USE_XNNPACK=0 USE_FBGEMM=0 USE_QNNPACK=0 USE_MKLDNN=0 USE_MIOPEN=0 USE_NNPACK=0 BUILD_CAFFE2_OPS=0 USE_TENSORPIPE=0 python setup.py developPyTorch has a lot of test files undertest/. You'll have to pick one (or a couple) that you want to test.
python test/test_torch.pygit push to the branch on your PyTorch fork. Then, open a pull request.
Runghstack, if you haveghstack installed.
Your Pull Request is too old and you want to rebase it onto a newer commit. What do you do?
git checkout my-awesome-featuregit pull --rebase upstream viable/strictgit push -fThe idea is to pull Pytorch into your branch while rebasing your (uncommited) commits on top of the newer ones.For example, if PyTorch's viable/strict branch looks likeA -> B -> C, and you've made a new commit D at an older stage in time (A -> D),thengit pull --rebase viable/strict will change your history to look likeA -> B -> C -> D
Your ghstack-created Pull Request is too old and you want to rebase it onto a newer commit. What do you do?
You have two options:
# Option 1: checkout the pull request using ghstackghstack checkout <pull_request_url>git pull --rebase upstream viable/strictghstack# Option 2: checkout the branch with your changes where you originally ran `ghstack`:git checkout my-awesome-featuregit pull --rebase upstream viable/strictghstackDid you rungit pull upstream viable/strict instead ofgit pull --rebase upstream viable/strict and regret it? Seehttps://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/
Unit 1: PyTorch Basics -Learn about where and how PyTorch is used
I would love to contribute to PyTorch!