pytorch/pytorch
Development workflow
Day-to-day cycle
# 1. Get up to date
git fetch origin
git checkout -b my-feature origin/main
# 2. Build (incremental builds reuse most of the previous compilation)
pip install -e . -v --no-build-isolation
# 3. Iterate
# ... edit code ...
# rebuild whichever changed:
pip install -e . -v --no-build-isolation
# or for Python-only changes, no rebuild needed (editable install)
# 4. Run a relevant test subset
python test/test_torch.py -v -k matmul
python test/test_nn.py -v
pytest test/inductor/test_torchinductor.py -k vec_kernel
# 5. Lint
spin lint
spin fixlint # apply auto-fixes
# 6. Push and open a PR
git push -u origin my-feature
# Open the PR via the GitHub UI (or `gh pr create`).Common build environment variables
| Variable | Effect |
|---|---|
USE_CUDA=0 |
CPU-only build (much faster) |
USE_DISTRIBUTED=0 |
Skip building distributed C++ bits |
MAX_JOBS=N |
Limit parallel build jobs |
DEBUG=1 |
Build with debug symbols (-O0 -g) |
REL_WITH_DEB_INFO=1 |
Release build with debug info |
BUILD_TEST=0 |
Skip C++ test binaries |
TORCH_CUDA_ARCH_LIST |
Compile only specific GPU architectures (e.g., 8.0;9.0) |
CMAKE_BUILD_PARALLEL_LEVEL |
Parallelism for CMake |
BUILD_CAFFE2=0 |
Skip Caffe2 (almost always desirable) |
The full list lives in setup.py and CMakeLists.txt. For the canonical build command and rationale see CLAUDE.md and README.md.
CI flow tags
PyTorch CI uses ciflow tags to opt PRs into additional test sets:
| Tag | What it runs |
|---|---|
ciflow/trunk |
Same as the post-merge trunk CI |
ciflow/inductor |
Full inductor test suite |
ciflow/dynamo |
Dynamo test suite |
ciflow/torchtitan |
Torchtitan integration |
ciflow/rocm-mi300 |
ROCm MI300 jobs |
ciflow/h100 |
H100 inductor perf jobs |
ciflow/mps |
MPS tests on macOS |
ciflow/binaries |
Build wheels for all platforms |
ciflow/periodic-rocm-mi300 |
Long-running ROCm tests |
Add a tag by labelling the PR. The merge bot won't merge until the relevant CI is green.
ghstack
Inside Meta and for stacked PRs ghstack is the canonical tool. Per CLAUDE.md:
- ghstack creates one branch per stack entry under
gh/USERNAME/N. - Don't
git pushto those branches; letghstackmanage them. - Preserve the
Pull-Request:andghstack-source-id:trailers in commit messages. - Use
ghstack --no-stackto update only the current commit's PR; fullghstackupdates the whole stack. - Use
ghstack -uto push only an updated commit message (e.g., for editing a PR body).
External contributors can ignore ghstack and use the regular GitHub PR flow.
Reverts
If a landed PR breaks trunk, the merge bot can revert it. Comment @pytorchbot revert -m "<reason>" -c "ghfirst" (or nosignal/landrace/weird) on the original PR. This produces a revert PR that auto-merges.
Troubleshooting CI
- Looks unrelated → click "Re-run jobs" on the GitHub Actions run.
- Flaky test → comment
@pytorchbot rebaseto pick up trunk fixes. - Lint failures →
spin fixlintlocally and push the fix. - Real failure on a platform you can't reproduce → tag the relevant module owner.
Where to read next
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.