PyTorch's tutorial factory turns .py files into Colab notebooks
This repo generates the official PyTorch tutorial site from executable Python scripts, auto-producing HTML documentation and Jupyter notebooks for Google Colab.

What it does
This repository is the build pipeline behind the official PyTorch tutorials. It uses Sphinx-Gallery to turn plain Python script files into HTML documentation, auto-generating Jupyter notebooks for Google Colab along the way. Contributors drop your_tutorial.py files into beginner_source, intermediate_source, advanced_source, recipes_source, or prototype_source directories, and the build system handles the rest.
The interesting bit
The project treats notebooks as an output format rather than a source format. By version-controlling plain Python instead of messy JSON notebook blobs, it keeps diffs readable while still handing users a one-click Colab experience.
Key highlights
- Sphinx-Gallery workflow: write a Python script, get both an HTML page and an auto-generated Colab-ready Jupyter notebook
- Five content tiers from beginner recipes to unstable prototype features
- Single-tutorial builds supported via regex with
GALLERY_PATTERN - A lightweight
html-noplotbuild target skips code execution for quick local previews
Caveats
- Full documentation builds require a GPU and can take about 60–120 minutes.
- Spell checking for
.rstfiles is currently limited to thebeginner/directory.
Verdict
Tutorial contributors and docs-infrastructure nerds will find the machinery here; if you just want to learn PyTorch, read the rendered site instead.
Frequently asked
- What is pytorch/tutorials?
- This repo generates the official PyTorch tutorial site from executable Python scripts, auto-producing HTML documentation and Jupyter notebooks for Google Colab.
- Is tutorials open source?
- Yes — pytorch/tutorials is open source, released under the BSD-3-Clause license.
- What language is tutorials written in?
- pytorch/tutorials is primarily written in Python.
- How popular is tutorials?
- pytorch/tutorials has 9.3k stars on GitHub.
- Where can I find tutorials?
- pytorch/tutorials is on GitHub at https://github.com/pytorch/tutorials.