You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Authors:** `Oguz Ulgen <https://github.com/oulgen>`_ and `Sam Larsen <https://github.com/masnesral>`_
4
4
@@ -27,17 +27,17 @@ Inductor Cache Settings
27
27
Most of these caches are in-memory, only used within the same process, and are transparent to the user. An exception is caches that store compiled FX graphs (``FXGraphCache``, ``AOTAutogradCache``). These caches allow 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.
28
28
29
29
There are a few settings relevant to caching and to FX graph caching in particular.
30
-
The settings are accessible via environment variables listed below or can be hard-coded in Inductor’s config file.
30
+
The settings are accessible via environment variables listed below or can be hard-coded in the Inductor’s config file.
31
31
32
32
TORCHINDUCTOR_FX_GRAPH_CACHE
33
33
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34
-
This setting enables the local FX graph cache feature, i.e., by storing artifacts in the host’s temp directory. ``1`` enables, and any other value disables it. By default, the disk location is per username, but users can enable sharing across usernames by specifying ``TORCHINDUCTOR_CACHE_DIR`` (below).
34
+
This setting enables the local FX graph cache feature, which stores artifacts in the host’s temp directory. Setting it to ``1`` enables the feature while any other value disables it. By default, the disk location is per username, but users can enable sharing across usernames by specifying ``TORCHINDUCTOR_CACHE_DIR`` (below).
35
35
36
36
TORCHINDUCTOR_AUTOGRAD_CACHE
37
37
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38
-
This setting extends FXGraphCache to store cached results at the AOTAutograd level, instead of at the Inductor level. ``1`` enables, and any other value disables it.
38
+
This setting extends ``FXGraphCache`` to store cached results at the ``AOTAutograd`` level, rather than at the Inductor level. Setting it to ``1`` enables this feature, while any other value disables it.
39
39
By default, the disk location is per username, but users can enable sharing across usernames by specifying ``TORCHINDUCTOR_CACHE_DIR`` (below).
40
-
`TORCHINDUCTOR_AUTOGRAD_CACHE` requires `TORCHINDUCTOR_FX_GRAPH_CACHE` to work. The same cache dir stores cache entries for ``AOTAutogradCache`` (under `{TORCHINDUCTOR_CACHE_DIR}/aotautograd`) and ``FXGraphCache`` (under `{TORCHINDUCTOR_CACHE_DIR}/fxgraph`).
40
+
``TORCHINDUCTOR_AUTOGRAD_CACHE`` requires ``TORCHINDUCTOR_FX_GRAPH_CACHE`` to work. The same cache dir stores cache entries for ``AOTAutogradCache`` (under ``{TORCHINDUCTOR_CACHE_DIR}/aotautograd``) and ``FXGraphCache`` (under ``{TORCHINDUCTOR_CACHE_DIR}/fxgraph``).
41
41
42
42
TORCHINDUCTOR_CACHE_DIR
43
43
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -52,19 +52,21 @@ This setting enables the remote FX graph cache feature. The current implementati
52
52
``TORCHINDUCTOR_REDIS_HOST`` (defaults to ``localhost``)
53
53
``TORCHINDUCTOR_REDIS_PORT`` (defaults to ``6379``)
54
54
55
-
Note that if Inductor locates a remote cache entry, it stores the compiled artifact in the local on-disk cache; that local artifact would be served on subsequent runs on the same machine.
55
+
.. note::
56
+
57
+
Note that if Inductor locates a remote cache entry, it stores the compiled artifact in the local on-disk cache; that local artifact would be served on subsequent runs on the same machine.
56
58
57
59
TORCHINDUCTOR_AUTOGRAD_REMOTE_CACHE
58
60
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59
-
Like ``TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE``, this setting enables the remote ``AOTAutogradCache`` feature. The current implementation uses Redis. ``1`` enables caching, and any other value disables it. The following environment variables configure the host and port of the ``Redis`` server:
60
-
``TORCHINDUCTOR_REDIS_HOST`` (defaults to ``localhost``)
61
-
``TORCHINDUCTOR_REDIS_PORT`` (defaults to ``6379``)
61
+
Similar to ``TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE``, this setting enables the remote ``AOTAutogradCache`` feature. The current implementation uses Redis. Setting it to ``1`` enables caching, while any other value disables it. The following environment variables are used to configure the host and port of the ``Redis`` server:
62
+
* ``TORCHINDUCTOR_REDIS_HOST`` (defaults to ``localhost``)
63
+
* ``TORCHINDUCTOR_REDIS_PORT`` (defaults to ``6379``)
62
64
63
-
`TORCHINDUCTOR_AUTOGRAD_REMOTE_CACHE`` depends on ``TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE`` to be enabled to work. The same Redis server can store both AOTAutograd and FXGraph cache results.
65
+
`TORCHINDUCTOR_AUTOGRAD_REMOTE_CACHE`` requires ``TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE`` to be enabled in order to function. The same Redis server can be used to store both AOTAutograd and FXGraph cache results.
64
66
65
67
TORCHINDUCTOR_AUTOTUNE_REMOTE_CACHE
66
68
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67
-
This setting enables a remote cache for ``TorchInductor``’s autotuner. As with the remote FX graph cache, the current implementation uses Redis. ``1`` enables caching, and any other value disables it. The same host / port environment variables listed above apply to this cache.
69
+
This setting enables a remote cache for ``TorchInductor``’s autotuner. Similar to remote FX graph cache, the current implementation uses Redis. Setting it to ``1`` enables caching, while any other value disables it. The same host / port environment variables mentioned above apply to this cache.
Copy file name to clipboardExpand all lines: recipes_source/torch_compile_caching_tutorial.rst
+12-12Lines changed: 12 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -35,19 +35,19 @@ Caching Offerings
35
35
36
36
It is important to note that caching validates that the cache artifacts are used with the same PyTorch and Triton version, as well as, same GPU when device is set to be cuda.
End to end caching, from here onwards referred to Mega-Cache, is the ideal solution for users looking for a portable caching solution that can be stored in a database and can later be fetched possibly on a separate machine.
41
+
End to end caching, from here onwards referred to ``Mega-Cache``, is the ideal solution for users looking for a portable caching solution that can be stored in a database and can later be fetched possibly on a separate machine.
42
42
43
-
``Mega-Cache`` provides two compiler APIs
43
+
``Mega-Cache`` provides two compiler APIs:
44
44
45
45
* ``torch.compiler.save_cache_artifacts()``
46
46
* ``torch.compiler.load_cache_artifacts()``
47
47
48
48
The intended use case is after compiling and executing a model, the user calls ``torch.compiler.save_cache_artifacts()`` which will return the compiler artifacts in a portable form. Later, potentially on a different machine, the user may call ``torch.compiler.load_cache_artifacts()`` with these artifacts to pre-populate the ``torch.compile`` caches in order to jump-start their cache.
49
49
50
-
An example to this is as follows. First, compile and save the cache artifacts.
50
+
Consider the following example. First, compile and save the cache artifacts.
51
51
52
52
.. code-block:: python
53
53
@@ -64,7 +64,7 @@ An example to this is as follows. First, compile and save the cache artifacts.
64
64
65
65
# Now, potentially store these artifacts in a database
66
66
67
-
Later, the user can jump-start their cache by the following.
67
+
Later, you can jump-start the cache by the following:
68
68
69
69
.. code-block:: python
70
70
@@ -80,21 +80,21 @@ This operation populates all the modular caches that will be discussed in the ne
80
80
Modular caching of ``TorchDynamo``, ``TorchInductor``, and ``Triton``
The above described MegaCache is also compromised of individual components that can be used without any user intervention. By default, PyTorch Compiler comes with local on-disk caches for ``TorchDynamo``, ``TorchInductor``, and ``Triton``. These caches are as following.
83
+
The aforementioned ``Mega-Cache`` is composed of individual components that can be used without any user intervention. By default, PyTorch Compiler comes with local on-disk caches for ``TorchDynamo``, ``TorchInductor``, and ``Triton``. These caches include:
84
84
85
-
* ``FXGraphCache``: cache of graph-based IR components used in compilation
86
-
* ``Triton Cache``: cache of Triton-compilation results (``cubin`` files generated by ``Triton`` as well as other caching artifacts)
87
-
* ``InductorCache``: bundling of ``FXGraphCache`` and ``Triton`` cache
88
-
* ``AOTAutogradCache``: caching of joint graph artifacts
89
-
* ``PGO-cache``: cache of dynamic shape decisions to reduce number of recompilations
85
+
* ``FXGraphCache``: A cache of graph-based IR components used in compilation.
86
+
* ``TritonCache``: A cache of Triton-compilation results, including ``cubin`` files generated by ``Triton`` and other caching artifacts.
87
+
* ``InductorCache``: A bundle of ``FXGraphCache`` and ``Triton`` cache.
88
+
* ``AOTAutogradCache``: A cache of joint graph artifacts.
89
+
* ``PGO-cache``: A cache of dynamic shape decisions to reduce number of recompilations.
90
90
91
91
All these cache artifacts are written to ``TORCHINDUCTOR_CACHE_DIR`` which by default will look like ``/tmp/torchinductor_myusername``.
92
92
93
93
94
94
Remote Caching
95
95
----------------
96
96
97
-
We also provide a remote caching option for users who would like to take advantage of a ``Redis`` based cache. Check out `Compile Time Caching Configurations <https://pytorch.org/tutorials/recipes/torch_compile_caching_configuration_tutorial.html>`__ to learn more about how to enable the ``Redis`` based caching.
97
+
We also provide a remote caching option for users who would like to take advantage of a Redis based cache. Check out `Compile Time Caching Configurations <https://pytorch.org/tutorials/recipes/torch_compile_caching_configuration_tutorial.html>`__ to learn more about how to enable the Redis-based caching.
0 commit comments