Skip to content

modify the conditions as PythonModuleVariable #116856

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 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
4 changes: 1 addition & 3 deletions test/test_transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from torch.nn.attention.bias import CausalVariant, causal_lower_right, causal_upper_left
from torch.nn.parameter import Parameter
import unittest
from unittest import expectedFailure as xfail
from unittest.mock import patch, MagicMock, ANY
import math
from torch.backends.cuda import sdp_kernel, SDPBackend
Expand Down Expand Up @@ -3290,13 +3289,12 @@ def test_causal_variants(self, device, causal_variant: CausalVariant, shape: Lis

self.run_test(device, False, make_q_tensor, make_kv_tensor, attn_bias, forw_tol, grad_tol)

@skipIfRocm # No support for the second variant for now
@unittest.skip("This test fails on some parameters and on some CI machines")
@parametrize("causal_variant", [CausalVariant.UPPER_LEFT, CausalVariant.LOWER_RIGHT])
@parametrize(
"shape",
[(16, 16, 128, 128, 16), (16, 16, 128, 256, 32), (16, 16, 256, 128, 32), (1, 1, 23, 56, 15)],
)
@xfail
def test_causal_variants_compile(self, device, causal_variant: CausalVariant, shape: List[Tuple[int]]):
make_tensor = partial(
torch.rand, device=device, dtype=torch.float16, requires_grad=True
Expand Down
2 changes: 1 addition & 1 deletion torch/_dynamo/variables/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ def build_key_value(k, v):
istype(value, (types.ModuleType, replay_record.DummyModule))
# type(torch.backends.cudnn) -> <class 'torch.backends.cudnn.CudnnModule'>
# type(torch.ops) -> <class 'torch._ops._Ops'>
or value in [torch.backends.cudnn, torch.ops]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this isn't working, wouldn't:

Suggested change
or value in [torch.backends.cudnn, torch.ops]
or any(value is obj for obj in (torch.backends.cudnn, torch.ops))

work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, thanks!

or any(value is obj for obj in (torch.backends.cudnn, torch.ops))
or isinstance(value, torch._ops._OpNamespace)
):
self.install_guards(GuardBuilder.FUNCTION_MATCH)
Expand Down
Loading