Skip to content

flex attention: fix dispatch order for tensor subclasses, avoid hardcoding call to faketensor impl in dynamo #151719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update
[ghstack-poisoned]
  • Loading branch information
drisspg committed Jun 17, 2025
commit 398bc2ec7dd9750cab6b809532fec5a4f3ea084d
3 changes: 0 additions & 3 deletions torch/_higher_order_ops/flex_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def flex_attention_functionalize(
"""
from torch._dynamo._trace_wrapped_higher_order_op import TransformGetItemToIndex


if has_user_subclass(
(
query,
Expand Down Expand Up @@ -479,7 +478,6 @@ def flex_attention_fake_impl(
score_mod_other_buffers: tuple = (),
mask_mod_other_buffers: tuple = (),
) -> tuple[torch.Tensor, torch.Tensor]:

if has_user_subclass(
(
query,
Expand Down Expand Up @@ -1215,7 +1213,6 @@ def flex_attention_backward_fake_tensor_mode(
) -> tuple[
torch.Tensor, torch.Tensor, torch.Tensor, tuple[Optional[torch.Tensor], ...]
]:

if has_user_subclass(
(
query,
Expand Down
8 changes: 4 additions & 4 deletions torch/_higher_order_ops/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,14 +1102,14 @@ def wrapped_fn(*flat_args):

def has_user_subclass(args, allowed_subclasses):
"""Check if any tensor arguments are user subclasses.
This is used to determine if tensor subclasses should get a chance to run

This is used to determine if tensor subclasses should get a chance to run
their own implementation first before falling back to the default implementation.

Args:
args: Arguments to check (will be flattened with pytree)
allowed_subclasses: Tuple of allowed subclass types

Returns:
True if user tensor subclasses are found, False otherwise
"""
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy