Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyTorch Workflow Cheatsheet

Manuel edited this pageJul 3, 2024 ·3 revisions

Context

This is a quick cheatsheet of common operations PyTorch developers use.

Developing a new feature

git checkout upstream viable/strictgit branch my-awesome-featuregit checkout my-awesome-feature

Checkout 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.

Building and testing 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 develop

PyTorch 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.py

More details here

Submitting a change (the traditional way)

git push to the branch on your PyTorch fork. Then, open a pull request.

Submitting a change (using ghstack)

Runghstack, if you haveghstack installed.

Rebasing your Pull Request (the traditional way)

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 -f

The 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

Rebasing your Pull Request (if it was submitted via ghstack)

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/strictghstack

How to undo (almost) anything with Git

Did 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/

Next

Unit 1: PyTorch Basics -Learn about where and how PyTorch is used

I would love to contribute to PyTorch!

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp