Vulkan index select outputs don't match eager/portable
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
When running the following repro on the Vulkan delegate, outputs differ from eager mode. ET portable matches eager.
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
class IndexSelectModel(torch.nn.Module):
def __init__(self, dim=0):
super().__init__()
self.dim = dim
def forward(self, x, indices):
return torch.index_select(x, self.dim, indices)
model = IndexSelectModel(dim=0)
indices = torch.tensor([0, 1], dtype=torch.int64)
inputs = (
torch.randn(5, 5),
indices,
)
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:
Inputs: (tensor([[-0.4567, -0.3723, -0.1551, -0.7132, -0.5437],
[ 1.5363, 0.7774, 1.8513, 1.4016, 0.6614],
[ 0.2748, -0.6432, -0.8875, -1.6339, -0.4679],
[-1.1551, 0.0595, 0.4082, -1.3087, -0.7413],
[-0.1365, 0.1206, 0.6683, 1.3647, -0.3534]]), tensor([0, 1]))
Eager: tensor([[-0.4567, -0.3723, -0.1551, -0.7132, -0.5437],
[ 1.5363, 0.7774, 1.8513, 1.4016, 0.6614]])
ET: tensor([[-0.4567, -0.3723, -0.1551, -0.7132, -0.5437],
[-0.4567, -0.3723, -0.1551, -0.7132, -0.5437]])
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 by running the provided IndexSelectModel repro with VulkanPartitioner and compare its output with eager mode and ET portable. Read executorch.backends.vulkan.partitioner.vulkan_partitioner and trace the Vulkan index-select path; done means Vulkan produces the same selected rows as eager and portable execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100