Skip to content

Commit 3ea5e05

Browse files
authored
Editorial and formatting fixes
1 parent d0c485b commit 3ea5e05

File tree

1 file changed

+42
-24
lines changed

1 file changed

+42
-24
lines changed

prototype_source/inductor_windows_cpu.rst

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,70 @@ How to use TorchInductor on Windows CPU
44
**Author**: `Zhaoqiong Zheng <https://github.com/ZhaoqiongZ>`_, `Xu, Han <https://github.com/xuhancn>`_
55

66

7-
Introduction
8-
------------
97

10-
TorchInductor is the new compiler backend that compiles the FX Graphs generated by TorchDynamo into optimized C++/Triton kernels.
8+
TorchInductor is a new compiler backend that compiles FX Graphs generated by TorchDynamo into optimized C++/Triton kernels.
9+
This tutorial will guide you through the process of using TorchInductor on a Windows CPU.
1110

12-
This tutorial introduces the steps for utilizing TorchInductor on Windows CPU.
11+
.. grid:: 2
1312

13+
.. grid-item-card:: :octicon:`mortar-board;1em;` What you will learn
14+
:class-card: card-prerequisites
1415

16+
* How to compile and execute a Python function with PyTorch, optimized for Windows CPU
17+
* Basics of TorchInductor's optimization using C++/Triton kernels.
1518

16-
Software Installation
17-
---------------------
19+
.. grid-item-card:: :octicon:`list-unordered;1em;` Prerequisites
20+
:class-card: card-prerequisites
1821

19-
Now, we will walk you through a step-by-step tutorial for how to use torchinductor on Windows CPU.
22+
* PyTorch v2.5 or later
23+
* Microsoft Visual C++ (MSVC)
24+
* Miniforge for Windows
2025

21-
Install a Compiler
22-
^^^^^^^^^^^^^^^^^^
26+
Install the Required Software
27+
---------------------
2328

24-
C++ compiler is required for torchinductor optimization, let's take Microsoft Visual C++ (MSVC) as an example.
29+
First, let's install the required software. C++ compiler is required for TorchInductor optimization.
30+
We will use Microsoft Visual C++ (MSVC) for this example.
2531

26-
Download and install `MSVC <https://visualstudio.microsoft.com/downloads/>`_.
32+
1. Download and install `MSVC <https://visualstudio.microsoft.com/downloads/>`_.
2733

28-
During Installation, chosse `Desktop Development with C++` in the `Desktop & Mobile` Section and then install.
34+
1. During the installation, choose **Desktop Development with C++** in the **Desktop & Mobile** section. Then install the software
2935

30-
.. note::
36+
.. note::
3137

32-
We recommend C++ compiler `Clang <https://github.com/llvm/llvm-project/releases>`_ and `Intel Compiler <https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html>`_.
38+
We recommend C++ compiler `Clang <https://github.com/llvm/llvm-project/releases>`_ and `Intel Compiler <https://www.intel.com/content/www/us/en/developer/tools/oneapi/base-toolkit-download.html>`_.
3339

34-
Install Miniforge
35-
^^^^^^^^^^^^^^^^^
3640

37-
Download and install `Miniforge <https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe>`_.
41+
1. Download and install `Miniforge3-Windows-x86_64.exe <https://github.com/conda-forge/miniforge/releases/latest/>`__.
3842

3943
Set Up Environment
4044
^^^^^^^^^^^^^^^^^^
4145

42-
#. Open a command line environment via cmd.exe.
43-
#. Activate `MSVC` via below command::
46+
#. Open the command line environment via ``cmd.exe``.
47+
#. Activate `MSVC` with the following command::
4448

4549
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
46-
#. Activate `conda` via below command::
50+
#. Activate `conda` with the following command:
51+
52+
.. code-block:: sh
4753
4854
"C:/ProgramData/miniforge3/Scripts/activate.bat"
49-
#. Create and activate customer conda environment::
55+
#. Create and activate a customer conda environment:
56+
57+
.. code-block:: sh
5058
5159
conda create -n inductor_cpu_windows python=3.10 -y
5260
conda activate inductor_cpu_windows
61+
5362
#. Install `PyTorch 2.5 <https://pytorch.org/get-started/locally/>`_ or later.
54-
#. Use torchinductor on Windows CPU::
63+
64+
Using TorchInductor on Windows CPU
65+
----------------------------------------
66+
67+
Here’s a simple example to demonstrate how to use TorchInductor:
68+
69+
.. code-block:: python
70+
5571
5672
import torch
5773
def foo(x, y):
@@ -61,7 +77,9 @@ Set Up Environment
6177
opt_foo1 = torch.compile(foo)
6278
print(opt_foo1(torch.randn(10, 10), torch.randn(10, 10)))
6379
64-
#. Output of the above example::
80+
The code above returns the following output:
81+
82+
.. code-block:: sh
6583
6684
tensor([[-3.9074e-02, 1.3994e+00, 1.3894e+00, 3.2630e-01, 8.3060e-01,
6785
1.1833e+00, 1.4016e+00, 7.1905e-01, 9.0637e-01, -1.3648e+00],
@@ -87,4 +105,4 @@ Set Up Environment
87105
Conclusion
88106
----------
89107

90-
With this tutorial, we introduce how to use Inductor on Windows CPU with PyTorch 2.5 or later.
108+
In this tutorial, we have learned how to use Inductor on Windows CPU with PyTorch 2.5 or later.

0 commit comments

Comments
 (0)