Files
pytorch/docs/source/torch.compiler_api.md
T
zhxchen17 20badc5bad [precompile] Add an option to keep tensor, shape and global state guards. (#170082)
Creating a new guard filter for AOT precompile that only preserve the following 3 types of guards:
1. TENSOR_MATCH
2. SHAPE_ENV
3. GLOBAL_STATE

These are the guards that matter empirically in AOT use cases like large scale training.

Other types of dynamo guards are dropped from this policy because:
1. Serialization on those guards often require complex pickling behavior that brings additional implementation cost.
2. Those guards (global variable id matches, class matches, etc) usually doesn't change a lot in training.
3. More guards will introduce more overhead during runtime. By default we'd rather keep guards checking minimal at runtime if possible.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170082
Approved by: https://github.com/bobrenjc93
ghstack dependencies: #170081
2025-12-17 16:23:20 +00:00

806 B

.. currentmodule:: torch.compiler
.. automodule:: torch.compiler

(torch.compiler_api)=

torch.compiler API reference

For a quick overview of torch.compiler, see {ref}torch.compiler_overview.

.. autosummary::
    :toctree: generated
    :nosignatures:

     compile
     reset
     allow_in_graph
     substitute_in_graph
     assume_constant_result
     list_backends
     disable
     set_stance
     set_enable_guard_collectives
     cudagraph_mark_step_begin
     is_compiling
     is_dynamo_compiling
     is_exporting
     keep_portable_guards_unsafe
     skip_guard_on_inbuilt_nn_modules_unsafe
     skip_guard_on_all_nn_modules_unsafe
     keep_tensor_guards_unsafe
     skip_guard_on_globals_unsafe
     skip_all_guards_unsafe
     nested_compile_region