-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
[aten decomp] Update sdpa decom #108371
Closed
Closed
[aten decomp] Update sdpa decom #108371
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a55a4f5
[aten decomp] Update sdpa decom
kimishpatel 190849d
Update on "[aten decomp] Update sdpa decom"
kimishpatel 25f41fd
Update on "[aten decomp] Update sdpa decom"
kimishpatel 543ac0e
Update on "[aten decomp] Update sdpa decom"
kimishpatel 49068e0
Update on "[aten decomp] Update sdpa decom"
kimishpatel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Owner(s): ["oncall: mobile"] | ||
import copy | ||
|
||
import torch | ||
import torch._export as export | ||
|
||
from torch.testing._internal.common_quantization import skip_if_no_torchvision | ||
from torch.testing._internal.common_utils import TestCase | ||
|
||
|
||
def _get_ops_list(m: torch.fx.GraphModule): | ||
op_list = [] | ||
for n in m.graph.nodes: | ||
if n.op == "call_function": | ||
op_list.append(n.target) | ||
return op_list | ||
|
||
|
||
class TestQuantizePT2EModels(TestCase): | ||
@skip_if_no_torchvision | ||
def test_vit_aten_export(self): | ||
from torchvision.models import vit_b_16 # @manual | ||
|
||
m = vit_b_16(weights="IMAGENET1K_V1") | ||
m = m.eval() | ||
input_shape = (1, 3, 224, 224) | ||
example_inputs = (torch.randn(input_shape),) | ||
m = export.capture_pre_autograd_graph(m, copy.deepcopy(example_inputs)) | ||
m(*example_inputs) | ||
m = export.export(m, copy.deepcopy(example_inputs)) | ||
ops = _get_ops_list(m.graph_module) | ||
non_core_aten_op_found = False | ||
for op in ops: | ||
if "scaled_dot_product" in str(op): | ||
non_core_aten_op_found = True | ||
self.assertFalse(non_core_aten_op_found) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow this is so weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is indeed. flash attnetion, https://fburl.com/38pwyabk, does that while the other one does not. I am gonna check if i trigger non flash variant what happens. But surprising calls to contiguous, https://github.com/pytorch/pytorch/blob/main/torch/nn/functional.py#L5441, does not appear in trace. which is also very weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a bug? It would be great to add this explanation in the comment. What's the relationship to decomposition statement in the summary?