Skip to content

Commit e78f450

Browse files
committed
Add AOTAutogradCache to caching tutorials
1 parent 25f1156 commit e78f450

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

recipes_source/torch_compile_caching_tutorial.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ 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). 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.
26+
Most of these caches are in-memory, only used within the same process, and are transparent to the user. An exception are caches tha stores 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.
2727

2828
There are a few settings relevant to caching and to FX graph caching in particular.
2929
The settings are accessible via environment variables listed below or can be hard-coded in Inductor’s config file.
@@ -32,6 +32,12 @@ TORCHINDUCTOR_FX_GRAPH_CACHE
3232
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3333
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).
3434

35+
TORCHINDUCTOR_AUTOGRAD_CACHE
36+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37+
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+
By default, the disk location is per username, but users can enable sharing across usernames by specifying ``TORCHINDUCTOR_CACHE_DIR`` (below).
39+
`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+
3541
TORCHINDUCTOR_CACHE_DIR
3642
~~~~~~~~~~~~~~~~~~~~~~~~
3743
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``.
@@ -47,6 +53,14 @@ This setting enables the remote FX graph cache feature. The current implementati
4753

4854
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.
4955

56+
TORCHINDUCTOR_AUTOGRAD_REMOTE_CACHE
57+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58+
Like TORCHINDUCTOR_FX_GRAPH_REMOTE_CACHE, this setting enables the remote AOT AutogradCache 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:
59+
``TORCHINDUCTOR_REDIS_HOST`` (defaults to ``localhost``)
60+
``TORCHINDUCTOR_REDIS_PORT`` (defaults to ``6379``)
61+
62+
`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.
63+
5064
TORCHINDUCTOR_AUTOTUNE_REMOTE_CACHE
5165
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5266
This setting enables a remote cache for Inductor’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.
@@ -59,3 +73,4 @@ Conclusion
5973
-------------
6074
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.
6175
Additionally, we explored the various settings and environment variables that allow users to configure and optimize these caching features according to their specific needs.
76+

0 commit comments

Comments
 (0)