Skip to content

Commit 647c3f8

Browse files
authored
Merge branch 'main' into fix/profiler-recipe-format
2 parents 652a264 + 06f9c4b commit 647c3f8

Some content is hidden

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

43 files changed

+2177
-562
lines changed

.ci/docker/requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tqdm==4.66.1
1414
numpy==1.24.4
1515
matplotlib
1616
librosa
17-
torch==2.6
17+
torch==2.7
1818
torchvision
1919
torchdata
2020
networkx
@@ -36,7 +36,7 @@ datasets
3636
transformers
3737
torchmultimodal-nightly # needs to be updated to stable as soon as it's avaialable
3838
onnx
39-
onnxscript
39+
onnxscript>=0.2.2
4040
onnxruntime
4141
evaluate
4242
accelerate>=0.20.1
@@ -67,7 +67,7 @@ iopath
6767
pygame==2.6.0
6868
pycocotools
6969
semilearn==0.3.2
70-
torchao==0.5.0
70+
torchao==0.10.0
7171
segment_anything==1.0
72-
torchrec==1.0.0; platform_system == "Linux"
73-
fbgemm-gpu==1.1.0; platform_system == "Linux"
72+
torchrec==1.1.0; platform_system == "Linux"
73+
fbgemm-gpu==1.2.0; platform_system == "Linux"

.github/scripts/docathon-label-sync.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def main():
2525
issue_number = int(re.findall(r'#(\d{1,5})', pull_request_body)[0])
2626
issue = repo.get_issue(issue_number)
2727
issue_labels = issue.labels
28-
docathon_label_present = any(label.name == 'docathon-h1-2024' for label in issue_labels)
28+
docathon_label_present = any(label.name == 'docathon-h1-2025' for label in issue_labels)
2929

3030
# if the issue has a docathon label, add all labels from the issue to the PR.
3131
if not docathon_label_present:
32-
print("The 'docathon-h1-2024' label is not present in the issue.")
32+
print("The 'docathon-h1-2025' label is not present in the issue.")
3333
return
3434
pull_request_labels = pull_request.get_labels()
3535
issue_label_names = [label.name for label in issue_labels]

.github/workflows/docathon-assign.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828
repo: context.repo.repo,
2929
issue_number: issueNumber
3030
});
31-
const hasLabel = issue.labels.some(label => label.name === 'docathon-h1-2024');
31+
const hasLabel = issue.labels.some(label => label.name === 'docathon-h1-2025');
3232
if (hasLabel) {
3333
if (issue.assignee !== null) {
3434
await github.rest.issues.createComment({
3535
owner: context.repo.owner,
3636
repo: context.repo.repo,
3737
issue_number: issueNumber,
38-
body: "The issue is already assigned. Please pick an opened and unnasigned issue with the [docathon-h1-2024 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h1-2024)."
38+
body: "The issue is already assigned. Please pick an opened and unnasigned issue with the [docathon-h1-2025 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h1-2025)."
3939
});
4040
} else {
4141
await github.rest.issues.addAssignees({
@@ -46,7 +46,7 @@ jobs:
4646
});
4747
}
4848
} else {
49-
const commmentMessage = "This issue does not have the correct label. Please pick an opened and unnasigned issue with the [docathon-h1-2024 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h1-2024)."
49+
const commmentMessage = "This issue does not have the correct label. Please pick an opened and unnasigned issue with the [docathon-h1-2025 label](https://github.com/pytorch/pytorch/issues?q=is%3Aopen+is%3Aissue+label%3Adocathon-h1-2025)."
5050
await github.rest.issues.createComment({
5151
owner: context.repo.owner,
5252
repo: context.repo.repo,

.jenkins/build.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ sudo apt-get install -y pandoc
2222
#Install PyTorch Nightly for test.
2323
# Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
2424
# Install 2.5 to merge all 2.4 PRs - uncomment to install nightly binaries (update the version as needed).
25-
# sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata
26-
# sudo pip3 install torch==2.6.0 torchvision --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124
2725
# sudo pip uninstall -y fbgemm-gpu torchrec
26+
# sudo pip uninstall -y torch torchvision torchaudio torchtext torchdata torchrl tensordict
2827
# sudo pip3 install fbgemm-gpu==1.1.0 torchrec==1.0.0 --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu124
29-
28+
# pip3 install torch==2.7.0 torchvision torchaudio --no-cache-dir --index-url https://download.pytorch.org/whl/test/cu126
3029
# Install two language tokenizers for Translation with TorchText tutorial
3130
python -m spacy download en_core_web_sm
3231
python -m spacy download de_core_news_sm

.jenkins/validate_tutorials_built.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"prototype_source/vmap_recipe",
3232
"prototype_source/torchscript_freezing",
3333
"prototype_source/nestedtensor",
34+
"prototype_source/gpu_direct_storage", # requires specific filesystem + GPUDirect Storage to be set up
3435
"recipes_source/recipes/saving_and_loading_models_for_inference",
3536
"recipes_source/recipes/saving_multiple_models_in_one_file",
3637
"recipes_source/recipes/tensorboard_with_pytorch",
@@ -51,7 +52,7 @@
5152
"intermediate_source/text_to_speech_with_torchaudio",
5253
"intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release.
5354
"advanced_source/semi_structured_sparse", # reenable after 3303 is fixed.
54-
"recipes_source/recipes/reasoning_about_shapes"
55+
"intermediate_source/torchrec_intro_tutorial", # reenable after 3302 is fixe
5556
]
5657

5758
def tutorial_source_dirs() -> List[Path]:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ You can submit the following types of issues:
2020

2121
We use sphinx-gallery's [notebook styled examples](https://sphinx-gallery.github.io/stable/tutorials/index.html) to create the tutorials. Syntax is very simple. In essence, you write a slightly well formatted Python file and it shows up as an HTML page. In addition, a Jupyter notebook is autogenerated and available to run in Google Colab.
2222

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

2525
NOTE: Before submitting a new tutorial, read [PyTorch Tutorial Submission Policy](./tutorial_submission_policy.md).
2626

40.8 KB
Loading

_static/img/install_msvc.png

131 KB
Loading
117 KB
Loading

_templates/layout.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,5 @@
211211

212212
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>
213213

214-
<script>
215-
//temporarily add a link to survey
216-
var survey = '<div class="survey-banner"><p><i class="fas fa-poll" aria-hidden="true">&nbsp </i> Take the <a href="https://forms.gle/KZ4xGL65VRMYNbbG6">PyTorch Docs/Tutorials survey</a>.</p></div>'
217-
if ($(".pytorch-call-to-action-links").length) {
218-
$(".pytorch-call-to-action-links").before(survey);
219-
} else {
220-
$("#pytorch-article").prepend(survey);
221-
}
222-
</script>
223214

224215
{% endblock %}

advanced_source/dynamic_quantization_tutorial.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,18 @@ def tokenize(self, path):
134134
# -----------------------------
135135
#
136136
# This is a tutorial on dynamic quantization, a quantization technique
137-
# that is applied after a model has been trained. Therefore, we'll simply load some
138-
# pretrained weights into this model architecture; these weights were obtained
139-
# by training for five epochs using the default settings in the word language model
140-
# example.
137+
# that is applied after a model has been trained. Therefore, we'll simply
138+
# load some pretrained weights into this model architecture; these
139+
# weights were obtained by training for five epochs using the default
140+
# settings in the word language model example.
141+
#
142+
# Before running this tutorial, download the required pre-trained model:
143+
#
144+
# .. code-block:: bash
145+
#
146+
# wget https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth
147+
#
148+
# Place the downloaded file in the data directory or update the model_data_filepath accordingly.
141149

142150
ntokens = len(corpus.dictionary)
143151

beginner_source/basics/README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Learn the Basics
1313
Tensors
1414
https://pytorch.org/tutorials/beginner/basics/tensor_tutorial.html
1515

16-
4. dataquickstart_tutorial.py
16+
4. data_tutorial.py
1717
Datasets & DataLoaders
1818
https://pytorch.org/tutorials/beginner/basics/data_tutorial.html
1919

beginner_source/basics/data_tutorial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120

121121
import os
122122
import pandas as pd
123-
from torchvision.io import read_image
123+
from torchvision.io import decode_image
124124

125125
class CustomImageDataset(Dataset):
126126
def __init__(self, annotations_file, img_dir, transform=None, target_transform=None):
@@ -134,7 +134,7 @@ def __len__(self):
134134

135135
def __getitem__(self, idx):
136136
img_path = os.path.join(self.img_dir, self.img_labels.iloc[idx, 0])
137-
image = read_image(img_path)
137+
image = decode_image(img_path)
138138
label = self.img_labels.iloc[idx, 1]
139139
if self.transform:
140140
image = self.transform(image)
@@ -184,7 +184,7 @@ def __len__(self):
184184
# ^^^^^^^^^^^^^^^^^^^^
185185
#
186186
# The __getitem__ function loads and returns a sample from the dataset at the given index ``idx``.
187-
# Based on the index, it identifies the image's location on disk, converts that to a tensor using ``read_image``, retrieves the
187+
# Based on the index, it identifies the image's location on disk, converts that to a tensor using ``decode_image``, retrieves the
188188
# corresponding label from the csv data in ``self.img_labels``, calls the transform functions on them (if applicable), and returns the
189189
# tensor image and corresponding label in a tuple.
190190

beginner_source/basics/optimization_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def forward(self, x):
7676
# (`read more <https://pytorch.org/tutorials/beginner/hyperparameter_tuning_tutorial.html>`__ about hyperparameter tuning)
7777
#
7878
# We define the following hyperparameters for training:
79-
# - **Number of Epochs** - the number times to iterate over the dataset
79+
# - **Number of Epochs** - the number of times to iterate over the dataset
8080
# - **Batch Size** - the number of data samples propagated through the network before the parameters are updated
8181
# - **Learning Rate** - how much to update models parameters at each batch/epoch. Smaller values yield slow learning speed, while large values may result in unpredictable behavior during training.
8282
#

beginner_source/colab.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PyTorch Version in Google Colab
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1212

1313
Wen you are running a tutorial that requires a version of PyTorch that has
14-
jst been released, that version might not be yet available in Google Colab.
14+
just been released, that version might not be yet available in Google Colab.
1515
To check that you have the required ``torch`` and compatible domain libraries
1616
installed, run ``!pip list``.
1717

@@ -27,7 +27,7 @@ Using Tutorial Data from Google Drive in Colab
2727
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2828

2929
We've added a new feature to tutorials that allows users to open the
30-
ntebook associated with a tutorial in Google Colab. You may need to
30+
notebook associated with a tutorial in Google Colab. You may need to
3131
copy data to your Google drive account to get the more complex tutorials
3232
to work.
3333

beginner_source/examples_autograd/polynomial_autograd.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
PyTorch: Tensors and autograd
43
-------------------------------

beginner_source/examples_autograd/polynomial_custom_function.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
PyTorch: Defining New autograd Functions
43
----------------------------------------
@@ -34,8 +33,11 @@ def forward(ctx, input):
3433
"""
3534
In the forward pass we receive a Tensor containing the input and return
3635
a Tensor containing the output. ctx is a context object that can be used
37-
to stash information for backward computation. You can cache arbitrary
38-
objects for use in the backward pass using the ctx.save_for_backward method.
36+
to stash information for backward computation. You can cache tensors for
37+
use in the backward pass using the ``ctx.save_for_backward`` method. Other
38+
objects can be stored directly as attributes on the ctx object, such as
39+
``ctx.my_object = my_object``. Check out `Extending torch.autograd <https://docs.pytorch.org/docs/stable/notes/extending.html#extending-torch-autograd>`_
40+
for further details.
3941
"""
4042
ctx.save_for_backward(input)
4143
return 0.5 * (5 * input ** 3 - 3 * input)

beginner_source/introyt/introyt1_tutorial.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,21 @@ def num_flat_features(self, x):
303303
# The values passed to the transform are the means (first tuple) and the
304304
# standard deviations (second tuple) of the rgb values of the images in
305305
# the dataset. You can calculate these values yourself by running these
306-
# few lines of code:
307-
# ```
308-
# from torch.utils.data import ConcatDataset
309-
# transform = transforms.Compose([transforms.ToTensor()])
310-
# trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
306+
# few lines of code::
307+
#
308+
# from torch.utils.data import ConcatDataset
309+
# transform = transforms.Compose([transforms.ToTensor()])
310+
# trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
311311
# download=True, transform=transform)
312312
#
313-
# #stack all train images together into a tensor of shape
314-
# #(50000, 3, 32, 32)
315-
# x = torch.stack([sample[0] for sample in ConcatDataset([trainset])])
313+
# # stack all train images together into a tensor of shape
314+
# # (50000, 3, 32, 32)
315+
# x = torch.stack([sample[0] for sample in ConcatDataset([trainset])])
316316
#
317-
# #get the mean of each channel
318-
# mean = torch.mean(x, dim=(0,2,3)) #tensor([0.4914, 0.4822, 0.4465])
319-
# std = torch.std(x, dim=(0,2,3)) #tensor([0.2470, 0.2435, 0.2616])
320-
#
321-
# ```
317+
# # get the mean of each channel
318+
# mean = torch.mean(x, dim=(0,2,3)) # tensor([0.4914, 0.4822, 0.4465])
319+
# std = torch.std(x, dim=(0,2,3)) # tensor([0.2470, 0.2435, 0.2616])
320+
#
322321
#
323322
# There are many more transforms available, including cropping, centering,
324323
# rotation, and reflection.

conf.py

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
sys.path.insert(0, os.path.abspath('./.jenkins'))
3434
import pytorch_sphinx_theme
3535
import torch
36-
import numpy
37-
import gc
3836
import glob
3937
import random
4038
import shutil
@@ -49,6 +47,46 @@
4947
pio.renderers.default = 'sphinx_gallery'
5048

5149

50+
import sphinx_gallery.gen_rst
51+
import multiprocessing
52+
53+
# Monkey patch sphinx gallery to run each example in an isolated process so that
54+
# we don't need to worry about examples changing global state.
55+
#
56+
# Alt option 1: Parallelism was added to sphinx gallery (a later version that we
57+
# are not using yet) using joblib, but it seems to result in errors for us, and
58+
# it has no effect if you set parallel = 1 (it will not put each file run into
59+
# its own process and run singly) so you need parallel >= 2, and there may be
60+
# tutorials that cannot be run in parallel.
61+
#
62+
# Alt option 2: Run sphinx gallery once per file (similar to how we shard in CI
63+
# but with shard sizes of 1), but running sphinx gallery for each file has a
64+
# ~5min overhead, resulting in the entire suite taking ~2x time
65+
def call_fn(func, args, kwargs, result_queue):
66+
try:
67+
result = func(*args, **kwargs)
68+
result_queue.put((True, result))
69+
except Exception as e:
70+
result_queue.put((False, str(e)))
71+
72+
def call_in_subprocess(func):
73+
def wrapper(*args, **kwargs):
74+
result_queue = multiprocessing.Queue()
75+
p = multiprocessing.Process(
76+
target=call_fn,
77+
args=(func, args, kwargs, result_queue)
78+
)
79+
p.start()
80+
p.join()
81+
success, result = result_queue.get()
82+
if success:
83+
return result
84+
else:
85+
raise RuntimeError(f"Error in subprocess: {result}")
86+
return wrapper
87+
88+
sphinx_gallery.gen_rst.generate_file_rst = call_in_subprocess(sphinx_gallery.gen_rst.generate_file_rst)
89+
5290
try:
5391
import torchvision
5492
except ImportError:
@@ -97,14 +135,6 @@
97135

98136
# -- Sphinx-gallery configuration --------------------------------------------
99137

100-
def reset_seeds(gallery_conf, fname):
101-
torch.cuda.empty_cache()
102-
torch.manual_seed(42)
103-
torch.set_default_device(None)
104-
random.seed(10)
105-
numpy.random.seed(10)
106-
gc.collect()
107-
108138
sphinx_gallery_conf = {
109139
'examples_dirs': ['beginner_source', 'intermediate_source',
110140
'advanced_source', 'recipes_source', 'prototype_source'],
@@ -115,7 +145,6 @@ def reset_seeds(gallery_conf, fname):
115145
'first_notebook_cell': ("# For tips on running notebooks in Google Colab, see\n"
116146
"# https://pytorch.org/tutorials/beginner/colab\n"
117147
"%matplotlib inline"),
118-
'reset_modules': (reset_seeds),
119148
'ignore_pattern': r'_torch_export_nightly_tutorial.py',
120149
'pypandoc': {'extra_args': ['--mathjax', '--toc'],
121150
'filters': ['.jenkins/custom_pandoc_filter.py'],

en-wordlist.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,3 +698,14 @@ TorchServe
698698
Inductor’s
699699
onwards
700700
recompilations
701+
BiasCorrection
702+
ELU
703+
GELU
704+
NNCF
705+
OpenVINO
706+
OpenVINOQuantizer
707+
PReLU
708+
Quantizer
709+
SmoothQuant
710+
quantizer
711+
quantizers

0 commit comments

Comments
 (0)