Skip to content

Vulkan: handle a single tensor output arriving as a list - #22308

Open
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/vulkan-repsets-single-tensor-list
Open

Vulkan: handle a single tensor output arriving as a list#22308
msluszniak wants to merge 1 commit into
pytorch:mainfrom
msluszniak:ms/vulkan-repsets-single-tensor-list

Conversation

@msluszniak

@msluszniak msluszniak commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #22306.

num_tensors_in_node() counts the tensors associated with a node rather than the nesting of meta["val"], so it returns 1 both for a bare FakeTensor and for a one-element list. OpRepSets treats that count as proof of the former and passes meta["val"] straight to filter_invalid_reprs(), which then does tensor_val.shape on a list:

  File "backends/vulkan/utils.py", line 1203, in filter_invalid_reprs
    extents = required_image_extents(tensor_val.shape, memory_layout)
AttributeError: 'list' object has no attribute 'shape'

Any op declared to return Tensor[] hits this whenever it happens to produce exactly one tensor. aten.split_with_sizes_copy.default is the case seen in the wild (lowering RF-DETR nano). Because the exception escapes the partitioner, one such node aborts partitioning for the whole model instead of the node being reported unsupported.

Unwrap the single element before filtering, matching what the multiple-output branch immediately below already does per element.

Test plan

New case in backends/vulkan/test/test_vulkan_tensor_repr.py building an OpRepSets for split_with_sizes_copy whose meta["val"] is a one-element list. It reproduces the AttributeError on main and passes with this change.

pytest backends/vulkan/test/test_vulkan_tensor_repr.py
88 passed

pytest backends/vulkan/test/test_vulkan_passes.py backends/vulkan/test/test_serialization.py
15 passed

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

num_tensors_in_node() counts the tensors associated with a node rather
than the nesting of meta["val"], so it returns 1 both for a bare
FakeTensor and for a one-element list. OpRepSets treats that count as
proof of the former and passes meta["val"] straight to
filter_invalid_reprs(), which then does tensor_val.shape on a list:

  File "backends/vulkan/utils.py", line 1203, in filter_invalid_reprs
    extents = required_image_extents(tensor_val.shape, memory_layout)
  AttributeError: 'list' object has no attribute 'shape'

Any op declared to return Tensor[] hits this whenever it happens to
produce exactly one tensor. aten.split_with_sizes_copy.default is the
case seen in the wild (RF-DETR); it aborts partitioning for the whole
model instead of the node being reported unsupported.

Unwrap the single element before filtering, matching what the
multiple-output branch below already does per element.
@msluszniak
msluszniak requested a review from SS-JIA as a code owner August 29, 2026 14:27
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Aug 29, 2026
@pytorch-bot

pytorch-bot Bot commented Aug 29, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⚠️ 15 Awaiting Approval

As of commit 4cd0217 with merge base c27baa8 (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

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

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 29, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Vulkan] Partitioner raises AttributeError on an op returning a one-element Tensor[], aborting the whole lowering

2 participants