Skip to content

Commit 5bea171

Browse files
authored
Merge branch 'main' into patch-1
2 parents 2c2d49a + bdeca26 commit 5bea171

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

intermediate_source/torch_compile_tutorial.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,11 @@ def forward(self, x):
101101
return torch.nn.functional.relu(self.lin(x))
102102

103103
mod = MyModule()
104-
opt_mod = torch.compile(mod)
105-
print(opt_mod(t))
104+
mod.compile()
105+
print(mod(t))
106+
## or:
107+
# opt_mod = torch.compile(mod)
108+
# print(opt_mod(t))
106109

107110
######################################################################
108111
# torch.compile and Nested Calls
@@ -135,8 +138,8 @@ def forward(self, x):
135138
return torch.nn.functional.relu(self.outer_lin(x))
136139

137140
outer_mod = OuterModule()
138-
opt_outer_mod = torch.compile(outer_mod)
139-
print(opt_outer_mod(t))
141+
outer_mod.compile()
142+
print(outer_mod(t))
140143

141144
######################################################################
142145
# We can also disable some functions from being compiled by using
@@ -197,6 +200,12 @@ def outer_function():
197200
# 4. **Compile Leaf Functions First:** In complex models with multiple nested
198201
# functions and modules, start by compiling the leaf functions or modules first.
199202
# For more information see `TorchDynamo APIs for fine-grained tracing <https://pytorch.org/docs/stable/torch.compiler_fine_grain_apis.html>`__.
203+
#
204+
# 5. **Prefer ``mod.compile()`` over ``torch.compile(mod)``:** Avoids ``_orig_`` prefix issues in ``state_dict``.
205+
#
206+
# 6. **Use ``fullgraph=True`` to catch graph breaks:** Helps ensure end-to-end compilation, maximizing speedup
207+
# and compatibility with ``torch.export``.
208+
200209

201210
######################################################################
202211
# Demonstrating Speedups

prototype_source/inductor_windows.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ Install a Compiler
2222

2323
C++ compiler is required for TorchInductor optimization, let's take Microsoft Visual C++ (MSVC) as an example.
2424

25-
1. Download and install `MSVC <https://visualstudio.microsoft.com/downloads/>`_.
25+
#. Download and install `MSVC <https://visualstudio.microsoft.com/downloads/>`_.
2626

27-
1. During Installation, select **Workloads** and then **Desktop & Mobile**.
28-
1. Select a checkmark on **Desktop Development with C++** and install.
27+
#. During Installation, select **Workloads** and then **Desktop & Mobile**. Select a checkmark on **Desktop Development with C++** and install.
2928

3029
.. image:: ../_static/img/install_msvc.png
3130

0 commit comments

Comments
 (0)