Skip to content

Commit e6b6dd2

Browse files
committed
Update on "Add tutorial about inductor caching"
cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng wenzhe-nrv jiayisunx peterbell10 ipiszy yf225 chenyang78 kadeng muchulee8 ColinPeppler amjames desertfire chauhang [ghstack-poisoned]
1 parent c634774 commit e6b6dd2

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

recipes_source/torch_compile_caching_tutorial.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Introduction
66
------------------
77

88
PyTorch Inductor implements several caches to reduce compilation latency. These caches are transparent to the user.
9-
This recipes demonstrates how you to configure various parts of the caching in ``torch.compile``.
9+
This recipe demonstrates how you can configure various parts of the caching in ``torch.compile``.
1010

1111
Prerequisites
1212
-------------------
@@ -23,23 +23,24 @@ Before starting this recipe, make sure that you have the following:
2323
Inductor Cache Settings
2424
----------------------------
2525

26-
Most of these caches are in-memory, only used within the same process, and are transparent to the user. An exception is the FX graph cache that stores compiled FX graphs. This cache allows Inductor to avoid recompilation across process boundaries when it encounters the same graph with the same Tensor input shapes (and the same configuration, etc.). The default implementation stores compiled artifacts in the system temp directory. An optional feature also supports sharing those artifacts within a cluster by storing them in Redis.
26+
Most of these caches are in-memory, only used within the same process, and are transparent to the user. An exception is the FX graph cache that stores compiled FX graphs. This cache allows Inductor to avoid recompilation across process boundaries when it encounters the same graph with the same Tensor input shapes (and the same configuration). The default implementation stores compiled artifacts in the system temp directory. An optional feature also supports sharing those artifacts within a cluster by storing them in a Redis database.
2727

28-
There are a few settings relevant to caching and to FX graph caching in particular. The settings are accessible via environment variables, or can be hard-coded in Inductor’s config file.
28+
There are a few settings relevant to caching and to FX graph caching in particular.
29+
The settings are accessible via environment variables listed below or can be hard-coded in the Inductor’s config file.
2930

3031
TORCHINDUCTOR_FX_GRAPH_CACHE
3132
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3233
This setting enables the local FX graph cache feature, i.e., by storing artifacts on the host’s temp directory. ``1`` enables, and any other value disables. By default, the disk location is per username, but users can enable sharing across usernames by specifying ``TORCHINDUCTOR_CACHE_DIR`` (below).
3334

3435
TORCHINDUCTOR_CACHE_DIR
3536
~~~~~~~~~~~~~~~~~~~~~~~~
36-
This setting specifies the location of all on-disk caches. By default, the location is in the system temp directory under ``torchinductor_<username>``, e.g., ``/tmp/torchinductor_myusername``.
37+
This setting specifies the location of all on-disk caches. By default, the location is in the system temp directory under ``torchinductor_<username>``, for example, ``/tmp/torchinductor_myusername``.
3738

38-
Note that if ``TRITON_CACHE_DIR`` is not set in the environment, Inductor sets the Triton cache directory to this same temp location (under the Triton subdirectory).
39+
Note that if ``TRITON_CACHE_DIR`` is not set in the environment, Inductor sets the Triton cache directory to this same temp location, under the Triton subdirectory.
3940

4041
TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE
4142
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42-
This setting enables the remote FX graph cache feature. The current implementation uses Redis. ``1`` enables, and any other value disables. The following environment variables configure the host and port of the Redis server:
43+
This setting enables the remote FX graph cache feature. The current implementation uses Redis. ``1`` enables cache, and any other value disables. The following environment variables configure the host and port of the Redis server:
4344

4445
``TORCHINDUCTOR_REDIS_HOST`` (defaults to ``localhost``)
4546
``TORCHINDUCTOR_REDIS_PORT`` (defaults to ``6379``)
@@ -52,4 +53,9 @@ This setting enables a remote cache for Inductor’s autotuner. As with the remo
5253

5354
TORCHINDUCTOR_FORCE_DISABLE_CACHES
5455
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55-
Set this value to ``1`` to disable all Inductor caching. This setting is useful to, e.g., experiment with cold-start compile time, or to force recompilation for debugging purposes.
56+
Set this value to ``1`` to disable all Inductor caching. This setting is useful for tasks like experimenting with cold-start compile times or forcing recompilation for debugging purposes.
57+
58+
Conclusion
59+
-------------
60+
In this recipe, we have learned that PyTorch Inductor's caching mechanisms significantly reduce compilation latency by utilizing both local and remote caches, which operate seamlessly in the background without requiring user intervention.
61+
Additionally, we explored the various settings and environment variables that allow users to configure and optimize these caching features according to their specific needs.

0 commit comments

Comments
 (0)