Skip to content

[inductor] Fix CPP wrapper lazy compile for scalar tensor args - #178478

Closed
desertfire wants to merge 1 commit into
gh/desertfire/685/basefrom
gh/desertfire/685/head
Closed

desertfire wants to merge 1 commit into
gh/desertfire/685/basefrom
gh/desertfire/685/head

Conversation

@desertfire

@desertfire desertfire commented Mar 26, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

In the lazy compile path, runTritonKernelWithAutotune passes all
args to the Python run_triton_kernel_with_autotune which calls
kernel_fn.run(). The C++ convertArgToPython converts
AtenTensorHandle to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via codegen_tensor_item before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Mar 26, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ No Failures

As of commit ce68b3d with merge base a1915b6 (image):
💚 Looks good so far! There are no failures yet. 💚

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

desertfire added a commit that referenced this pull request Mar 26, 2026
In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

ghstack-source-id: 92d087b
Pull Request resolved: #178478
@desertfire
desertfire requested a review from atalman March 26, 2026 13:39
@desertfire
desertfire requested a review from PaulZhang12 March 26, 2026 13:39
@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge -f "cpp wrapper fix only and the CI has passed. force merge to make CI green"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

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

@atalman

atalman commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Thank you @desertfire for fixing #178509 and #178413 - once fix is confirmed will close these issues

Copilot AI pushed a commit that referenced this pull request Mar 27, 2026
In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: #178478
Approved by: https://github.com/PaulZhang12

Co-authored-by: Xia-Weiwen <[email protected]>
AaronWang04 pushed a commit to AaronWang04/pytorch that referenced this pull request Mar 31, 2026
…ch#178478)

In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: pytorch#178478
Approved by: https://github.com/PaulZhang12
pytorch-bot Bot pushed a commit that referenced this pull request Apr 2, 2026
In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: #178478
Approved by: https://github.com/PaulZhang12
nklshy-aws pushed a commit to nklshy-aws/pytorch that referenced this pull request Apr 7, 2026
…ch#178478)

In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: pytorch#178478
Approved by: https://github.com/PaulZhang12
@github-actions
github-actions Bot deleted the gh/desertfire/685/head branch April 26, 2026 02:26
gplutop7 pushed a commit to gplutop7/pytorch that referenced this pull request Jul 15, 2026
…ch#178478)

In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: pytorch#178478
Approved by: https://github.com/PaulZhang12
aws-kingrj pushed a commit to amazon-contributing/upstream-to-pytorch that referenced this pull request Jul 29, 2026
…ch#178478)

In the lazy compile path, `runTritonKernelWithAutotune` passes all
args to the Python `run_triton_kernel_with_autotune` which calls
`kernel_fn.run()`. The C++ `convertArgToPython` converts
`AtenTensorHandle` to Python tensors, but for UnwrapUnspecArg (0-dim
scalar tensors like uint8/bfloat16), Triton's launcher now expects
Python scalars, not tensors.

Extract the scalar value via `codegen_tensor_item` before the
autotune call, matching the direct kernel launch path which already
does this.

Authored with Claude.

Pull Request resolved: pytorch#178478
Approved by: https://github.com/PaulZhang12
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.

4 participants