Skip to content

Commit 4dd64b7

Browse files
committed
fix some formatting
1 parent 54f44bf commit 4dd64b7

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

intermediate_source/torch_compile_full_example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
# This tutorial covers an end-to-end example of training and evaluating a
1616
# real model with ``torch.compile``. For a gentle introduction to ``torch.compile``,
17-
# please check out `the introduction to ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__.
17+
# please check out `the introduction to torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__.
1818
#
1919
# **Required pip Dependencies**
2020
#
@@ -33,7 +33,7 @@
3333
# .. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
3434
# :class-card: card-prerequisites
3535
#
36-
# * `Introduction to ``torch.compile`` <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__
36+
# * `Introduction to torch.compile <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__
3737

3838
# NOTE: a modern NVIDIA GPU (H100, A100, or V100) is recommended for this tutorial in
3939
# order to reproduce the speedup numbers shown below and documented elsewhere.
@@ -233,8 +233,8 @@ def train(mod, data):
233233
# are slower than eager mode due to compilation overhead, but subsequent iterations are expected to
234234
# have speedups.
235235
#
236-
# For a gentle introduction to ``torch.compile``, please check out `the introduction to ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__.
236+
# For a gentle introduction to ``torch.compile``, please check out `the introduction to torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_tutorial.html>`__.
237237
#
238-
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the ``torch.compile`` programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
238+
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the torch.compile programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
239239
#
240240
# We hope that you will give ``torch.compile`` a try!

intermediate_source/torch_compile_tutorial.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@
66
**Author:** William Wen
77
"""
88

9-
# sphinx_gallery_start_ignore
10-
# to clear torch logs format
11-
import torch
12-
import os
13-
os.environ["TORCH_LOGS_FORMAT"] = ""
14-
torch._logging._internal.DEFAULT_FORMATTER = (
15-
torch._logging._internal._default_formatter()
16-
)
17-
torch._logging._internal._init_logs()
18-
# sphinx_gallery_end_ignore
19-
209
######################################################################
2110
# ``torch.compile`` is the new way to speed up your PyTorch code!
2211
# ``torch.compile`` makes PyTorch code run faster by
@@ -36,15 +25,15 @@
3625
# our previous PyTorch compiler solution,
3726
# `TorchScript <https://pytorch.org/docs/stable/jit.html>`__.
3827
#
39-
# For an end-to-end example on a real model, check out our `end-to-end ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
28+
# For an end-to-end example on a real model, check out our `end-to-end torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
4029
#
41-
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the ``torch.compile`` programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
30+
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the torch.compile programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
4231
#
4332
# **Contents**
4433
#
4534
# .. contents::
4635
# :local:
47-
36+
#
4837
# **Required pip dependencies for this tutorial**
4938
#
5039
# - ``torch >= 2.0``
@@ -65,6 +54,16 @@
6554

6655
import torch
6756

57+
# sphinx_gallery_start_ignore
58+
# to clear torch logs format
59+
import os
60+
os.environ["TORCH_LOGS_FORMAT"] = ""
61+
torch._logging._internal.DEFAULT_FORMATTER = (
62+
torch._logging._internal._default_formatter()
63+
)
64+
torch._logging._internal._init_logs()
65+
# sphinx_gallery_end_ignore
66+
6867
torch._logging.set_logs(graph_code=True)
6968

7069
######################################################################
@@ -141,7 +140,7 @@ def forward(self, x):
141140
# -----------------------
142141
#
143142
# Now let's demonstrate how ``torch.compile`` speeds up a simple PyTorch example.
144-
# For a demonstration on a more complex model, see our `end-to-end ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
143+
# For a demonstration on a more complex model, see our `end-to-end torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
145144

146145

147146
def foo3(x):
@@ -215,7 +214,7 @@ def timed(fn):
215214
# and the amount of data is large, then the bottleneck would be
216215
# GPU compute and the observed speedup may be less significant.
217216
#
218-
# To see speedups on a real model, check out our `end-to-end ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
217+
# To see speedups on a real model, check out our `end-to-end torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
219218

220219
######################################################################
221220
# Benefits over TorchScript
@@ -392,10 +391,10 @@ def false_branch(y):
392391
# In order to serialize graphs or to run graphs on different (i.e. Python-less)
393392
# environments, consider using ``torch.export`` instead (from PyTorch 2.1+).
394393
# One important restriction is that ``torch.export`` does not support graph breaks. Please check
395-
# `this tutorial <https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html>`__
394+
# `the torch.export tutorial <https://pytorch.org/tutorials/intermediate/torch_export_tutorial.html>`__
396395
# for more details on ``torch.export``.
397396
#
398-
# Check out our `section on graph breaks in the ``torch.compile`` programming model <https://docs.pytorch.org/docs/main/compile/programming_model.graph_breaks_index.html>`__
397+
# Check out our `section on graph breaks in the torch.compile programming model <https://docs.pytorch.org/docs/main/compile/programming_model.graph_breaks_index.html>`__
399398
# for tips on how to work around graph breaks.
400399

401400
######################################################################
@@ -406,7 +405,7 @@ def false_branch(y):
406405
# Are you looking for tips on how to best use ``torch.compile``?
407406
# Or maybe you simply want to learn more about the inner workings of ``torch.compile``?
408407
#
409-
# Check out `the ``torch.compile`` programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
408+
# Check out `the torch.compile programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
410409

411410
######################################################################
412411
# Conclusion
@@ -416,8 +415,8 @@ def false_branch(y):
416415
# basic usage, demonstrating speedups over eager mode, comparing to TorchScript,
417416
# and briefly describing graph breaks.
418417
#
419-
# For an end-to-end example on a real model, check out our `end-to-end ``torch.compile`` tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
418+
# For an end-to-end example on a real model, check out our `end-to-end torch.compile tutorial <https://pytorch.org/tutorials/intermediate/torch_compile_full_example.html>`__.
420419
#
421-
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the ``torch.compile`` programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
420+
# To troubleshoot issues and to gain a deeper understanding of how to apply ``torch.compile`` to your code, check out `the torch.compile programming model <https://docs.pytorch.org/docs/main/compile/programming_model.html>`__.
422421
#
423422
# We hope that you will give ``torch.compile`` a try!

0 commit comments

Comments
 (0)