Skip to content

Commit c39605f

Browse files
committed
update alternative compiler
1 parent d2e1f27 commit c39605f

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

prototype_source/inductor_windows_cpu.rst

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,70 +4,72 @@ 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+
------------
79

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.
10+
TorchInductor is the new compiler backend that compiles the FX Graphs generated by TorchDynamo into optimized C++/Triton kernels.
1011

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

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

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.
1815

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

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

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

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.
24+
C++ compiler is required for torchinductor optimization, let's take Microsoft Visual C++ (MSVC) as an example.
3125

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

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

3630
.. note::
3731

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>`_.
32+
Windows inductor also support C++ compiler `LLVM Compiler <https://github.com/llvm/llvm-project/releases>`_ and `Intel Compiler <https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler-download.html>`_ for better performance.
33+
Please check Alternative Compiler for better performance:`my-reference-label`.
3934

35+
.. _my-reference-label:
4036

41-
3. Download and install `Miniforge3-Windows-x86_64.exe <https://github.com/conda-forge/miniforge/releases/latest/>`__.
37+
Alternative Compiler for better performance
38+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4239

43-
Set Up the Environment
44-
------------------------------
40+
To enhance performance on Windows inductor, you can use the Intel Compiler or LLVM Compiler. However, windows inductor rely on the runtime libraries from Microsoft Visual C++ (MSVC). Therefore, your first step should be to install MSVC.
4541

46-
#. Open the command line environment via ``cmd.exe``.
47-
#. Activate `MSVC` with the following command::
42+
Intel Compiler
43+
~~~~~~~~~~~~~~
44+
#. Download and install `Intel Compiler <https://www.intel.com/content/www/us/en/developer/tools/oneapi/dpc-compiler-download.html>`_ with Windows version.
45+
#. Set environment variable for compiler `CXX=icx-cl`
4846

49-
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
50-
#. Activate `conda` with the following command:
51-
52-
.. code-block:: sh
47+
LLVM Compiler
48+
~~~~~~~~~~~~~
49+
#. Download and install `LLVM Compiler <https://github.com/llvm/llvm-project/releases>`_ and choose Windows version.
50+
#. Set environment variable for compiler `CXX=clang-cl`
5351

54-
"C:/ProgramData/miniforge3/Scripts/activate.bat"
55-
#. Create and activate a customer conda environment:
56-
57-
.. code-block:: sh
52+
Install Miniforge
53+
^^^^^^^^^^^^^^^^^
5854

59-
conda create -n inductor_cpu_windows python=3.10 -y
60-
conda activate inductor_cpu_windows
55+
Download and install `Miniforge <https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe>`_.
6156

62-
#. Install `PyTorch 2.5 <https://pytorch.org/get-started/locally/>`_ or later.
57+
Set Up Environment
58+
^^^^^^^^^^^^^^^^^^
6359

64-
Using TorchInductor on Windows CPU
65-
----------------------------------------
60+
#. Open a command line environment via cmd.exe.
61+
#. Activate `MSVC` via below command::
6662

67-
Here’s a simple example to demonstrate how to use TorchInductor:
63+
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat"
64+
#. Activate `conda` via below command::
6865

69-
.. code-block:: python
66+
"C:/ProgramData/miniforge3/Scripts/activate.bat"
67+
#. Create and activate customer conda environment::
7068

69+
conda create -n inductor_cpu_windows python=3.10 -y
70+
conda activate inductor_cpu_windows
71+
#. Install `PyTorch 2.5 <https://pytorch.org/get-started/locally/>`_ or later.
72+
#. Use torchinductor on Windows CPU::
7173

7274
import torch
7375
def foo(x, y):
@@ -77,9 +79,7 @@ Here’s a simple example to demonstrate how to use TorchInductor:
7779
opt_foo1 = torch.compile(foo)
7880
print(opt_foo1(torch.randn(10, 10), torch.randn(10, 10)))
7981

80-
The code above returns the following output:
81-
82-
.. code-block:: sh
82+
#. Output of the above example::
8383

8484
tensor([[-3.9074e-02, 1.3994e+00, 1.3894e+00, 3.2630e-01, 8.3060e-01,
8585
1.1833e+00, 1.4016e+00, 7.1905e-01, 9.0637e-01, -1.3648e+00],
@@ -105,4 +105,4 @@ The code above returns the following output:
105105
Conclusion
106106
----------
107107

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

0 commit comments

Comments
 (0)