Skip to content

Commit 588c86a

Browse files
authored
Merge branch 'main' into device-recipe
2 parents 95c517a + 9d9be8f commit 588c86a

17 files changed

+1528
-62
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 🐛 Bug Report
2+
description: Create a tutorial bug report
3+
title: "[BUG] - <title>"
4+
labels: [
5+
"bug"
6+
]
7+
8+
body:
9+
- type: markdown
10+
attributes:
11+
value: >
12+
#### Before submitting a bug, please make sure the issue hasn't been already addressed by searching through [the existing and past issues](https://github.com/pytorch/tutorials/issues?q=is%3Aissue+sort%3Acreated-desc+).
13+
- type: textarea
14+
attributes:
15+
label: Add Link
16+
description: |
17+
**Add the link to the tutorial***
18+
placeholder: |
19+
Link to the tutorial on the website:
20+
validations:
21+
required: true
22+
- type: textarea
23+
attributes:
24+
label: Describe the bug
25+
description: |
26+
**Add the bug description**
27+
placeholder: |
28+
Provide a detailed description of the issue with code samples if relevant
29+
```python
30+
31+
# Sample code to reproduce the problem if relevant
32+
```
33+
34+
**Expected Result:** (Describe what you were expecting to see)
35+
36+
37+
**Actual Result:** (Describe the result)
38+
39+
```
40+
The error message you got, with the full traceback.
41+
```
42+
43+
validations:
44+
required: true
45+
- type: textarea
46+
attributes:
47+
label: Describe your environment
48+
description: |
49+
**Describe the environment you encountered the bug in:**
50+
placeholder: |
51+
* Platform (i.e macOS, Linux, Google Colab):
52+
* CUDA (yes/no, version?):
53+
* PyTorch version (run `python -c "import torch; print(torch.__version__)"`):
54+
55+
validations:
56+
required: true
57+
- type: markdown
58+
attributes:
59+
value: >
60+
Thanks for contributing 🎉!
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 🚀 Feature request
2+
description: Submit a proposal for a new PyTorch tutorial or improvement of an existing tutorial
3+
title: "💡 [REQUEST] - <title>"
4+
labels: [
5+
"feature"
6+
]
7+
8+
body:
9+
- type: textarea
10+
attributes:
11+
label: 🚀 Descirbe the improvement or the new tutorial
12+
description: |
13+
**Describe the improvement**
14+
placeholder: |
15+
Explain why this improvement or new tutorial is important. For example, *"This tutorial will help users to better understand feature X of PyTorch."* If there is a tutorial that you propose to replace, add here. If this is related to another GitHub issue, add a link here.
16+
validations:
17+
required: true
18+
- type: textarea
19+
attributes:
20+
label: Existing tutorials on this topic
21+
description: |
22+
**Add a list of existing tutorials on the same topic.**
23+
placeholder: |
24+
List tutorials that already explain this functionality if exist. On pytorch.org or elsewhere.
25+
* Link
26+
* Link
27+
- type: textarea
28+
attributes:
29+
label: Additional context
30+
description: |
31+
**Add additional context**
32+
placeholder: |
33+
Add any other context or screenshots about the feature request.
34+
- type: markdown
35+
attributes:
36+
value: >
37+
Thanks for contributing 🎉!

.jenkins/get_sphinx_filenames.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from pathlib import Path
2+
from typing import List
3+
4+
from get_files_to_run import get_all_files
5+
from validate_tutorials_built import NOT_RUN
6+
7+
8+
def get_files_for_sphinx() -> List[str]:
9+
all_py_files = get_all_files()
10+
return [x for x in all_py_files if all(y not in x for y in NOT_RUN)]
11+
12+
13+
SPHINX_SHOULD_RUN = "|".join(get_files_for_sphinx())

.jenkins/validate_tutorials_built.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,49 @@
99
# the file name to explain why, like intro.html), or fix the tutorial and remove it from this list).
1010

1111
NOT_RUN = [
12-
"basics/intro", # no code
13-
"translation_transformer",
14-
"profiler",
15-
"saving_loading_models",
16-
"introyt/captumyt",
17-
"introyt/trainingyt",
18-
"examples_nn/polynomial_module",
19-
"examples_nn/dynamic_net",
20-
"examples_nn/polynomial_optim",
21-
"former_torchies/autograd_tutorial_old",
22-
"former_torchies/tensor_tutorial_old",
23-
"examples_autograd/polynomial_autograd",
24-
"examples_autograd/polynomial_custom_function",
25-
"parametrizations",
26-
"mnist_train_nas", # used by ax_multiobjective_nas_tutorial.py
27-
"fx_conv_bn_fuser",
28-
"super_resolution_with_onnxruntime",
29-
"ddp_pipeline", # requires 4 gpus
30-
"fx_graph_mode_ptq_dynamic",
31-
"vmap_recipe",
32-
"torchscript_freezing",
33-
"nestedtensor",
34-
"recipes/saving_and_loading_models_for_inference",
35-
"recipes/saving_multiple_models_in_one_file",
36-
"recipes/loading_data_recipe",
37-
"recipes/tensorboard_with_pytorch",
38-
"recipes/what_is_state_dict",
39-
"recipes/profiler_recipe",
40-
"recipes/save_load_across_devices",
41-
"recipes/warmstarting_model_using_parameters_from_a_different_model",
42-
"torch_compile_tutorial_",
43-
"recipes/dynamic_quantization",
44-
"recipes/saving_and_loading_a_general_checkpoint",
45-
"recipes/benchmark",
46-
"recipes/tuning_guide",
47-
"recipes/zeroing_out_gradients",
48-
"recipes/defining_a_neural_network",
49-
"recipes/timer_quick_start",
50-
"recipes/amp_recipe",
51-
"recipes/Captum_Recipe",
52-
"flask_rest_api_tutorial",
53-
"text_to_speech_with_torchaudio",
12+
"beginner_source/basics/intro", # no code
13+
"beginner_source/translation_transformer",
14+
"beginner_source/profiler",
15+
"beginner_source/saving_loading_models",
16+
"beginner_source/introyt/captumyt",
17+
"beginner_source/examples_nn/polynomial_module",
18+
"beginner_source/examples_nn/dynamic_net",
19+
"beginner_source/examples_nn/polynomial_optim",
20+
"beginner_source/former_torchies/autograd_tutorial_old",
21+
"beginner_source/former_torchies/tensor_tutorial_old",
22+
"beginner_source/examples_autograd/polynomial_autograd",
23+
"beginner_source/examples_autograd/polynomial_custom_function",
24+
"intermediate_source/parametrizations",
25+
"intermediate_source/mnist_train_nas", # used by ax_multiobjective_nas_tutorial.py
26+
"intermediate_source/fx_conv_bn_fuser",
27+
"advanced_source/super_resolution_with_onnxruntime",
28+
"advanced_source/ddp_pipeline", # requires 4 gpus
29+
"prototype_source/fx_graph_mode_ptq_dynamic",
30+
"prototype_source/vmap_recipe",
31+
"prototype_source/torchscript_freezing",
32+
"prototype_source/nestedtensor",
33+
"recipes_source/recipes/saving_and_loading_models_for_inference",
34+
"recipes_source/recipes/saving_multiple_models_in_one_file",
35+
"recipes_source/recipes/loading_data_recipe",
36+
"recipes_source/recipes/tensorboard_with_pytorch",
37+
"recipes_source/recipes/what_is_state_dict",
38+
"recipes_source/recipes/profiler_recipe",
39+
"recipes_source/recipes/save_load_across_devices",
40+
"recipes_source/recipes/warmstarting_model_using_parameters_from_a_different_model",
41+
"intermediate_source/torch_compile_tutorial_",
42+
"recipes_source/recipes/dynamic_quantization",
43+
"recipes_source/recipes/saving_and_loading_a_general_checkpoint",
44+
"recipes_source/recipes/benchmark",
45+
"recipes_source/recipes/tuning_guide",
46+
"recipes_source/recipes/zeroing_out_gradients",
47+
"recipes_source/recipes/defining_a_neural_network",
48+
"recipes_source/recipes/timer_quick_start",
49+
"recipes_source/recipes/amp_recipe",
50+
"recipes_source/recipes/Captum_Recipe",
51+
"intermediate_source/flask_rest_api_tutorial",
52+
"intermediate_source/text_to_speech_with_torchaudio",
53+
"intermediate_source/ax_multiobjective_nas_tutorial",
54+
"intermediate_source/tensorboard_profiler_tutorial" # reenable after 2.0 release.
5455
]
5556

5657

@@ -68,6 +69,7 @@ def main() -> None:
6869
glob_path = f"{tutorial_source_dir}/**/*.html"
6970
html_file_paths += docs_dir.glob(glob_path)
7071

72+
should_not_run = [f'{x.replace("_source", "")}.html' for x in NOT_RUN]
7173
did_not_run = []
7274
for html_file_path in html_file_paths:
7375
with open(html_file_path, "r", encoding="utf-8") as html_file:
@@ -78,9 +80,7 @@ def main() -> None:
7880
if (
7981
"Total running time of the script: ( 0 minutes 0.000 seconds)"
8082
in elem.text
81-
and not any(
82-
html_file_path.match(file) for file in NOT_RUN
83-
)
83+
and not any(html_file_path.match(file) for file in should_not_run)
8484
):
8585
did_not_run.append(html_file_path.as_posix())
8686

beginner_source/basics/tensorqs_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
######################################################################
134134
# **Joining tensors** You can use ``torch.cat`` to concatenate a sequence of tensors along a given dimension.
135135
# See also `torch.stack <https://pytorch.org/docs/stable/generated/torch.stack.html>`__,
136-
# another tensor joining op that is subtly different from ``torch.cat``.
136+
# another tensor joining option that is subtly different from ``torch.cat``.
137137
t1 = torch.cat([tensor, tensor, tensor], dim=1)
138138
print(t1)
139139

beginner_source/introyt/autogradyt_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def forward(self, x):
334334

335335
print(model.layer2.weight.grad[0][0:10])
336336

337-
optimizer.zero_grad()
337+
optimizer.zero_grad(set_to_none=False)
338338

339339
print(model.layer2.weight.grad[0][0:10])
340340

beginner_source/introyt/trainingyt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@
8181
validation_set = torchvision.datasets.FashionMNIST('./data', train=False, transform=transform, download=True)
8282

8383
# Create data loaders for our datasets; shuffle for training, not for validation
84-
training_loader = torch.utils.data.DataLoader(training_set, batch_size=4, shuffle=True, num_workers=2)
85-
validation_loader = torch.utils.data.DataLoader(validation_set, batch_size=4, shuffle=False, num_workers=2)
84+
training_loader = torch.utils.data.DataLoader(training_set, batch_size=4, shuffle=True)
85+
validation_loader = torch.utils.data.DataLoader(validation_set, batch_size=4, shuffle=False)
8686

8787
# Class labels
8888
classes = ('T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat',

beginner_source/text_sentiment_ngrams_tutorial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class TextClassificationModel(nn.Module):
148148

149149
def __init__(self, vocab_size, embed_dim, num_class):
150150
super(TextClassificationModel, self).__init__()
151-
self.embedding = nn.EmbeddingBag(vocab_size, embed_dim, sparse=True)
151+
self.embedding = nn.EmbeddingBag(vocab_size, embed_dim, sparse=False)
152152
self.fc = nn.Linear(embed_dim, num_class)
153153
self.init_weights()
154154

conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from custom_directives import IncludeDirective, GalleryItemDirective, CustomGalleryItemDirective, CustomCalloutItemDirective, CustomCardItemDirective
3939
import distutils.file_util
4040
import re
41-
from validate_tutorials_built import NOT_RUN
41+
from get_sphinx_filenames import SPHINX_SHOULD_RUN
4242

4343
import plotly.io as pio
4444
pio.renderers.default = 'sphinx_gallery'
@@ -87,8 +87,7 @@
8787
'examples_dirs': ['beginner_source', 'intermediate_source',
8888
'advanced_source', 'recipes_source', 'prototype_source'],
8989
'gallery_dirs': ['beginner', 'intermediate', 'advanced', 'recipes', 'prototype'],
90-
'filename_pattern': '.py',
91-
'ignore_pattern': re.compile(f"({'|'.join(NOT_RUN)}).py$"),
90+
'filename_pattern': re.compile(SPHINX_SHOULD_RUN),
9291
'promote_jupyter_magic': True,
9392
'backreferences_dir': None
9493
}

index.rst

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,34 @@ What's new in PyTorch tutorials?
417417
:link: intermediate/forward_ad_usage.html
418418
:tags: Frontend-APIs
419419

420+
.. customcarditem::
421+
:header: Jacobians, Hessians, hvp, vhp, and more
422+
:card_description: Learn how to compute advanced autodiff quantities using torch.func
423+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
424+
:link: intermediate/jacobians_hessians.html
425+
:tags: Frontend-APIs
426+
427+
.. customcarditem::
428+
:header: Model Ensembling
429+
:card_description: Learn how to ensemble models using torch.vmap
430+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
431+
:link: intermediate/ensembling.html
432+
:tags: Frontend-APIs
433+
434+
.. customcarditem::
435+
:header: Per-Sample-Gradients
436+
:card_description: Learn how to compute per-sample-gradients using torch.func
437+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
438+
:link: intermediate/per_sample_grads.html
439+
:tags: Frontend-APIs
440+
441+
.. customcarditem::
442+
:header: Neural Tangent Kernels
443+
:card_description: Learn how to compute neural tangent kernels using torch.func
444+
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
445+
:link: intermediate/neural_tangent_kernels.html
446+
:tags: Frontend-APIs
447+
420448
.. Model Optimization
421449
422450
.. customcarditem::
@@ -502,7 +530,7 @@ What's new in PyTorch tutorials?
502530
:image: _static/img/thumbnails/cropped/generic-pytorch-logo.png
503531
:link: intermediate/torchserve_with_ipex_2
504532
:tags: Model-Optimization,Production
505-
533+
506534
.. customcarditem::
507535
:header: Introduction to nvFuser
508536
:card_description: An introduction to nvFuser
@@ -524,6 +552,13 @@ What's new in PyTorch tutorials?
524552
:link: intermediate/torch_compile_tutorial.html
525553
:tags: Model-Optimization
526554

555+
.. customcarditem::
556+
:header: (beta) Implementing High-Performance Transformers with SCALED DOT PRODUCT ATTENTION
557+
:card_description: This tutorial explores the new torch.nn.functional.scaled_dot_product_attention and how it can be used to construct Transformer components.
558+
:image: _static/img/thumbnails/cropped/pytorch-logo.png
559+
:link: intermediate/scaled_dot_product_attention_tutorial.html
560+
:tags: Model-Optimization,Attention,Transformer
561+
527562
.. Parallel-and-Distributed-Training
528563
529564
@@ -870,6 +905,10 @@ Additional Resources
870905

871906
intermediate/memory_format_tutorial
872907
intermediate/forward_ad_usage
908+
intermediate/jacobians_hessians
909+
intermediate/ensembling
910+
intermediate/per_sample_grads
911+
intermediate/neural_tangent_kernels.py
873912
advanced/cpp_frontend
874913
advanced/torch-script-parallelism
875914
advanced/cpp_autograd
@@ -909,6 +948,7 @@ Additional Resources
909948
intermediate/nvfuser_intro_tutorial
910949
intermediate/ax_multiobjective_nas_tutorial
911950
intermediate/torch_compile_tutorial
951+
intermediate/scaled_dot_product_attention_tutorial
912952

913953
.. toctree::
914954
:maxdepth: 2

0 commit comments

Comments
 (0)