torch.compiler.nonstrict_trace
- torch.compiler.nonstrict_trace(traceable_fn)
Decorator to mark a function as nonstrict-traceable for dynamo.
A nonstrict-traced function appears as an opaque call in the dynamo graph. Dynamo does not trace into the function body (hence the “nonstrict”), but aot_autograd will trace into it.
This is similar to
allow_in_graphbut with enhanced support for: - User-defined classes as inputs (must be registered with pytree) -nn.Moduleas input arguments (parameters and buffers are tracked for autograd) - Global/captured tensors treated as constants (assumed not updated during execution)