Skip to content

[cuda_xpu_alignment] Fix Triton HOP clone for strided mutated views (#184050)#31

Draft
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-5
Draft

[cuda_xpu_alignment] Fix Triton HOP clone for strided mutated views (#184050)#31
Stonepia wants to merge 1 commit into
mainfrom
agent/issue-5

Conversation

@Stonepia

Copy link
Copy Markdown
Collaborator

[cuda_xpu_alignment] Fix Triton HOP clone for strided mutated views (pytorch#184050)

Fixes https://github.com/intel-sandbox/agentic_xpu/issues/5

Root Cause: In torch/_higher_order_ops/triton_kernel_wrap.py, the triton_kernel_wrapper_functional_dense and triton_kernel_wrapper_functional_fake_tensor_mode functions use clone_preserve_strides to clone mutated Triton kernel arguments. For strided views (e.g., x[::2]), clone_preserve_strides copies the full storage span, which can read past the bounds of compact Inductor temporaries, producing incorrect values. The upstream fix (commit 9a8a62c) replaces this with a new clone_preserve_strides_for_triton_kernel_wrapper that allocates stride-compatible storage and copies only logical elements via out.copy_(x).


Diff stat:

test/inductor/test_triton_kernels.py          | 80 ++++++++++++++++++++++++++-
 torch/_higher_order_ops/triton_kernel_wrap.py | 34 ++++++++++--
 2 files changed, 106 insertions(+), 8 deletions(-)

[cuda_xpu_alignment] Fix Triton HOP clone for strided mutated views (pytorch#184050)
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.

1 participant