Skip to content

Conversation

@chunhuanMeng
Copy link
Contributor

Fix memory layout of attention outputs

Copilot AI review requested due to automatic review settings December 16, 2025 05:53
@chunhuanMeng chunhuanMeng changed the title fix layout Fix memory layout of attention outputs Dec 16, 2025
Copy link
Contributor

Copilot AI left a 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::full and at::scalar_tensor

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +371 to +372
Tensor out =
attention.permute({0, 2, 1, 3}).contiguous().permute({0, 2, 1, 3});
Copy link
Contributor

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?

Comment on lines +375 to +378
at::full(
{B, H, (compute_log_sumexp ? ceil_div(L, kAlignLSE) * kAlignLSE : 0)},
0.0,
attention.options()),
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants