-
Notifications
You must be signed in to change notification settings - Fork 65
Fix memory layout of attention outputs #2582
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR fixes the memory layout of attention outputs in the XPU implementation by adding contiguous permutation operations and replacing empty placeholder tensors with properly initialized values.
Key Changes:
- Added contiguous memory layout conversion for attention output tensor
- Replaced empty placeholder tensors with initialized tensors using
at::fullandat::scalar_tensor
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Tensor out = | ||
| attention.permute({0, 2, 1, 3}).contiguous().permute({0, 2, 1, 3}); |
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.
Why does out Tensor need to be contiguous in BLHE format?
| at::full( | ||
| {B, H, (compute_log_sumexp ? ceil_div(L, kAlignLSE) * kAlignLSE : 0)}, | ||
| 0.0, | ||
| attention.options()), |
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.
Why do we need to align L to 32?
Fix memory layout of attention outputs