Skip to content

Conversation

@leslie-fang-intel
Copy link
Collaborator

@leslie-fang-intel leslie-fang-intel commented Oct 29, 2024

Stack from ghstack (oldest at bottom):

Summary
In the case of LLaMA2, for a linear operation with an activation size of (4, 1, 4096) and a stride of (4096, 128, 1) which has been decomposed into matmul. And the decomposition of matmul results in bmm due to a strict continuity check. We can align the continuity check with ATen by skip dim of size 1 to enable decomposition into mm instead.

Test Plan

python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_linear_input_non_contiguous_3D_wo_bias

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang @aakhundov

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 29, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139172

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 61d0eed with merge base 52c80f6 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
leslie-fang-intel added a commit that referenced this pull request Oct 30, 2024
return all(
st1 == st2 * s2 if s2 != 1 else True
for (st1, st2, s2) in zip(t1_stride[:-2], t1_stride[1:-1], t1_shape[1:-1])
(isinstance(size, utils.IntWithoutSymInt) and size == 1) or left == right
Copy link
Collaborator

Choose a reason for hiding this comment

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

Checking size == 1 is not enough?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, in the PreCI, we met a UT which the size seems to be a unbacked int as symbol of u0 which failed in _maybe_evaluate_static.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ezyang Is this the recommended way for checking size is concrete and is 1?

Copy link
Contributor

Choose a reason for hiding this comment

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

No it's not... usually guard_size_oblivious(size == 1) is what you want here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comment and change to use guard_size_oblivious.

return all(
st1 == st2 * s2 if s2 != 1 else True
for (st1, st2, s2) in zip(t1_stride[:-2], t1_stride[1:-1], t1_shape[1:-1])
(isinstance(size, utils.IntWithoutSymInt) and size == 1) or left == right
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ezyang Is this the recommended way for checking size is concrete and is 1?

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

nope don't do it this way

[ghstack-poisoned]
leslie-fang-intel added a commit that referenced this pull request Nov 3, 2024
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

sympy is BANNED from decompositions.py it should never be necessary to explicitly work with sympy there

[ghstack-poisoned]
leslie-fang-intel added a commit that referenced this pull request Nov 5, 2024
@leslie-fang-intel
Copy link
Collaborator Author

sympy is BANNED from decompositions.py it should never be necessary to explicitly work with sympy there

Changed without sympy . I think the failure is irrelevant.

@ezyang
Copy link
Contributor

ezyang commented Nov 5, 2024

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
…orch#139172)

**Summary**
In the case of LLaMA2, for a linear operation with an activation size of `(4, 1, 4096)` and a stride of `(4096, 128, 1)` which has been decomposed into `matmul`. And the decomposition of `matmul` results in `bmm` due to a strict continuity check. We can align the continuity check with ATen by skip dim of size 1 to enable decomposition into `mm` instead.

**Test Plan**
```
python -u -m pytest -s -v test/inductor/test_mkldnn_pattern_matcher.py -k test_linear_input_non_contiguous_3D_wo_bias
```

Pull Request resolved: pytorch#139172
Approved by: https://github.com/jgong5, https://github.com/ezyang
@github-actions github-actions bot deleted the gh/leslie-fang-intel/157/head branch December 6, 2024 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants