trunk/4f6d43d734261f011ab0feb028c490087369c717: Support FlexAttention blockmask taking arbitrary callable (#174610)
A hidden bug was breaking major AI model exports. Here's the fix.
Deep Dive
PyTorch developers have resolved a critical integration bug (#174610) in the new FlexAttention system. The issue prevented the export of models using custom, user-defined mask functions via `torch.export`. The fix involves wrapping the user function with a `_MaskMod` wrapper that uses value-based checking, ensuring consistent reconstruction during the export process. This patch is essential for developers leveraging advanced, custom attention mechanisms in production pipelines.
Why It Matters
This fix unlocks the reliable export of cutting-edge, custom transformer models for deployment, impacting next-gen AI applications.