Vulkan squeeze errors out for negative (relative) dims
Open
Nobody has claimed this yet.
backend tester
module: vulkan
- Dominant language
- Python
- Stars
- 5k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 581
Description
🐛 Describe the bug
Squeeze operations on Vulkan error out when dim is negative (end-relative). Unsqueeze appears to work as expected with negative dims.
Repro:
import torch
from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner
from executorch.exir import to_edge_transform_and_lower, EdgeCompileConfig, to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
from typing import Callable, List, Optional, Tuple, Union
class Model(torch.nn.Module):
def __init__(
self,
):
super().__init__()
def forward(self, x):
return torch.squeeze(x, dim=-1)
model = Model()
inputs = (
torch.randn(8, 1),
)
eager_outputs = model(*inputs)
ep = torch.export.export(model.eval(), inputs)
print(ep)
lowered = to_edge_transform_and_lower(
ep,
partitioner=[VulkanPartitioner()],
compile_config=EdgeCompileConfig(_check_ir_validity=False)
).to_executorch()
print(lowered.exported_program())
et_model = _load_for_executorch_from_buffer(lowered.buffer)
et_outputs = et_model([*inputs])[0]
print(f"Inputs: {inputs}")
print(f"Eager: {eager_outputs}")
print(f"ET: {et_outputs}")
Outputs:
IndexError Traceback (most recent call last)
Cell In[48], line 31
24 lowered = to_edge_transform_and_lower(
25 ep,
26 partitioner=[VulkanPartitioner()],
27 compile_config=EdgeCompileConfig(_check_ir_validity=False)
28 ).to_executorch()
29 print(lowered.exported_program())
---> 31 et_model = _load_for_executorch_from_buffer(lowered.buffer)
32 et_outputs = et_model([*inputs])[0]
34 print(f"Inputs: {inputs}")
IndexError: vector::_M_range_check: __n (which is 18446744073709551615) >= this->size() (which is 2)
Versions
Run on Meta internal master, Jul 3, fbcode/SwiftShader
cc @SS-JIA @manuelcandales @cbilgin
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at executorch.backends.vulkan.partitioner.vulkan_partitioner.VulkanPartitioner and run the supplied negative-dimension squeeze repro against the Vulkan backend. Compare the result with eager execution; done means torch.squeeze with a negative dim lowers and executes without the reported IndexError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100