Skip to content

Commit f36b152

Browse files
authored
Merge branch 'main' into torch-compile
2 parents fefbe1f + e07d43b commit f36b152

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+476
-60
lines changed

.ci/docker/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ IMAGE_NAME="$1"
1111
shift
1212

1313
export UBUNTU_VERSION="20.04"
14+
export CUDA_VERSION="12.4.1"
1415

15-
export BASE_IMAGE="ubuntu:${UBUNTU_VERSION}"
16+
export BASE_IMAGE="nvidia/cuda:${CUDA_VERSION}-devel-ubuntu${UBUNTU_VERSION}"
1617
echo "Building ${IMAGE_NAME} Docker image"
1718

1819
docker build \

.ci/docker/common/common_utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ conda_run() {
2222
}
2323

2424
pip_install() {
25-
as_ci_user conda run -n py_$ANACONDA_PYTHON_VERSION pip install --progress-bar off $*
25+
as_ci_user conda run -n py_$ANACONDA_PYTHON_VERSION pip3 install --progress-bar off $*
2626
}

.ci/docker/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pytorch-lightning
3030
torchx
3131
torchrl==0.5.0
3232
tensordict==0.5.0
33-
ax-platform>==0.4.0
34-
nbformat>==5.9.2
33+
ax-platform>=0.4.0
34+
nbformat>=5.9.2
3535
datasets
3636
transformers
3737
torchmultimodal-nightly # needs to be updated to stable as soon as it's avaialable
@@ -68,4 +68,4 @@ pygame==2.1.2
6868
pycocotools
6969
semilearn==0.3.2
7070
torchao==0.0.3
71-
segment_anything==1.0
71+
segment_anything==1.0

.jenkins/metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
"intermediate_source/model_parallel_tutorial.py": {
2929
"needs": "linux.16xlarge.nvidia.gpu"
3030
},
31+
"recipes_source/torch_export_aoti_python.py": {
32+
"needs": "linux.g5.4xlarge.nvidia.gpu"
33+
},
3134
"advanced_source/pendulum.py": {
3235
"needs": "linux.g5.4xlarge.nvidia.gpu",
3336
"_comment": "need to be here for the compiling_optimizer_lr_scheduler.py to run."

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ We use sphinx-gallery's [notebook styled examples](https://sphinx-gallery.github
2222

2323
Here is how you can create a new tutorial (for a detailed description, see [CONTRIBUTING.md](./CONTRIBUTING.md)):
2424

25+
NOTE: Before submitting a new tutorial, read [PyTorch Tutorial Submission Policy](./tutorial_submission_policy.md).
26+
2527
1. Create a Python file. If you want it executed while inserted into documentation, save the file with the suffix `tutorial` so that the file name is `your_tutorial.py`.
2628
2. Put it in one of the `beginner_source`, `intermediate_source`, `advanced_source` directory based on the level of difficulty. If it is a recipe, add it to `recipes_source`. For tutorials demonstrating unstable prototype features, add to the `prototype_source`.
2729
3. For Tutorials (except if it is a prototype feature), include it in the `toctree` directive and create a `customcarditem` in [index.rst](./index.rst).
@@ -31,7 +33,7 @@ If you are starting off with a Jupyter notebook, you can use [this script](https
3133

3234
## Building locally
3335

34-
The tutorial build is very large and requires a GPU. If your machine does not have a GPU device, you can preview your HTML build without actually downloading the data and running the tutorial code:
36+
The tutorial build is very large and requires a GPU. If your machine does not have a GPU device, you can preview your HTML build without actually downloading the data and running the tutorial code:
3537

3638
1. Install required dependencies by running: `pip install -r requirements.txt`.
3739

@@ -40,8 +42,6 @@ The tutorial build is very large and requires a GPU. If your machine does not ha
4042
- If you have a GPU-powered laptop, you can build using `make docs`. This will download the data, execute the tutorials and build the documentation to `docs/` directory. This might take about 60-120 min for systems with GPUs. If you do not have a GPU installed on your system, then see next step.
4143
- You can skip the computationally intensive graph generation by running `make html-noplot` to build basic html documentation to `_build/html`. This way, you can quickly preview your tutorial.
4244

43-
> If you get **ModuleNotFoundError: No module named 'pytorch_sphinx_theme' make: *** [html-noplot] Error 2** from /tutorials/src/pytorch-sphinx-theme or /venv/src/pytorch-sphinx-theme (while using virtualenv), run `python setup.py install`.
44-
4545
## Building a single tutorial
4646

4747
You can build a single tutorial by using the `GALLERY_PATTERN` environment variable. For example to run only `neural_style_transfer_tutorial.py`, run:
@@ -59,8 +59,8 @@ The `GALLERY_PATTERN` variable respects regular expressions.
5959

6060

6161
## About contributing to PyTorch Documentation and Tutorials
62-
* You can find information about contributing to PyTorch documentation in the
63-
PyTorch Repo [README.md](https://github.com/pytorch/pytorch/blob/master/README.md) file.
62+
* You can find information about contributing to PyTorch documentation in the
63+
PyTorch Repo [README.md](https://github.com/pytorch/pytorch/blob/master/README.md) file.
6464
* Additional information can be found in [PyTorch CONTRIBUTING.md](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md).
6565

6666

_static/css/custom.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,24 @@
9191
transition: none;
9292
transform-origin: none;
9393
}
94+
95+
.pytorch-left-menu-search input[type=text] {
96+
background-image: none;
97+
}
98+
99+
.gsc-control-cse {
100+
padding-left: 0px !important;
101+
padding-bottom: 0px !important;
102+
}
103+
104+
.gsc-search-button .gsc-search-button-v2:focus {
105+
border: transparent !important;
106+
outline: none;
107+
box-shadow: none;
108+
}
109+
.gsc-search-button-v2:active {
110+
border: none !important;
111+
}
112+
.gsc-search-button-v2 {
113+
border: none !important;
114+
}

_templates/layout.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111
</script>
1212
{%- endblock %}
1313

14+
{% block sidebartitle %}
15+
{% if theme_display_version %}
16+
{%- set nav_version = version %}
17+
{% if READTHEDOCS and current_version %}
18+
{%- set nav_version = current_version %}
19+
{% endif %}
20+
{% if nav_version %}
21+
<div class="version">
22+
{{ nav_version }}
23+
</div>
24+
{% endif %}
25+
{% endif %}
26+
<div class="searchbox">
27+
<script async src="https://cse.google.com/cse.js?cx=e65585f8c3ea1440e"></script>
28+
<div class="gcse-search"></div>
29+
</div>
30+
{% endblock %}
1431

1532
{% block footer %}
1633
{{ super() }}

advanced_source/cpp_custom_ops.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ To add ``torch.compile`` support for an operator, we must add a FakeTensor kerne
174174
known as a "meta kernel" or "abstract impl"). FakeTensors are Tensors that have
175175
metadata (such as shape, dtype, device) but no data: the FakeTensor kernel for an
176176
operator specifies how to compute the metadata of output tensors given the metadata of input tensors.
177+
The FakeTensor kernel should return dummy Tensors of your choice with
178+
the correct Tensor metadata (shape/strides/``dtype``/device).
177179

178180
We recommend that this be done from Python via the `torch.library.register_fake` API,
179181
though it is possible to do this from C++ as well (see

advanced_source/dynamic_quantization_tutorial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def tokenize(self, path):
151151
model.load_state_dict(
152152
torch.load(
153153
model_data_filepath + 'word_language_model_quantize.pth',
154-
map_location=torch.device('cpu')
154+
map_location=torch.device('cpu'),
155+
weights_only=True
155156
)
156157
)
157158

advanced_source/python_custom_ops.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def display(img):
6666
######################################################################
6767
# ``crop`` is not handled effectively out-of-the-box by
6868
# ``torch.compile``: ``torch.compile`` induces a
69-
# `"graph break" <https://pytorch.org/docs/stable/torch.compiler_faq.html#graph-breaks>`_
69+
# `"graph break" <https://pytorch.org/docs/stable/torch.compiler_faq.html#graph-breaks>`_
7070
# on functions it is unable to handle and graph breaks are bad for performance.
7171
# The following code demonstrates this by raising an error
7272
# (``torch.compile`` with ``fullgraph=True`` raises an error if a
@@ -85,9 +85,9 @@ def f(img):
8585
#
8686
# 1. wrap the function into a PyTorch custom operator.
8787
# 2. add a "``FakeTensor`` kernel" (aka "meta kernel") to the operator.
88-
# Given the metadata (e.g. shapes)
89-
# of the input Tensors, this function says how to compute the metadata
90-
# of the output Tensor(s).
88+
# Given some ``FakeTensors`` inputs (dummy Tensors that don't have storage),
89+
# this function should return dummy Tensors of your choice with the correct
90+
# Tensor metadata (shape/strides/``dtype``/device).
9191

9292

9393
from typing import Sequence
@@ -130,6 +130,11 @@ def f(img):
130130
# ``autograd.Function`` with PyTorch operator registration APIs can lead to (and
131131
# has led to) silent incorrectness when composed with ``torch.compile``.
132132
#
133+
# If you don't need training support, there is no need to use
134+
# ``torch.library.register_autograd``.
135+
# If you end up training with a ``custom_op`` that doesn't have an autograd
136+
# registration, we'll raise an error message.
137+
#
133138
# The gradient formula for ``crop`` is essentially ``PIL.paste`` (we'll leave the
134139
# derivation as an exercise to the reader). Let's first wrap ``paste`` into a
135140
# custom operator:
@@ -203,7 +208,7 @@ def setup_context(ctx, inputs, output):
203208
######################################################################
204209
# Mutable Python Custom operators
205210
# -------------------------------
206-
# You can also wrap a Python function that mutates its inputs into a custom
211+
# You can also wrap a Python function that mutates its inputs into a custom
207212
# operator.
208213
# Functions that mutate inputs are common because that is how many low-level
209214
# kernels are written; for example, a kernel that computes ``sin`` may take in

0 commit comments

Comments
 (0)