[dynamo] Guard serialization for FUNCTORCH_STACK_MATCH (#152616)

Make Functorch interpreters serializable most of the time, so that we can save the guards on functorch states.

## Test Cases:

0. torch.compile() without functorch layers present. Guard should fail with any layer being pushed.
1. torch.compile() nested in vmap.
2. torch.compile() nested in grad.
3. torch.compile() nested in jvp + vmap
4. torch.compile() nested functionalize
5. torch.compile() nested in vmap + grad

Differential Revision: [D74008787](https://our.internmc.facebook.com/intern/diff/D74008787/)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/152616
Approved by: https://github.com/zou3519
ghstack dependencies: #152615
This commit is contained in:
zhxchen17
2025-05-02 07:31:56 -07:00
committed by PyTorch MergeBot
parent 1d1cbcd8a3
commit ffd58293f7
9 changed files with 325 additions and 8 deletions

View File

@ -376,6 +376,7 @@ cc_library(
":torch_headers",
"@fbgemm",
"@ideep",
"@nlohmann",
],
alwayslink = True,
)