pytorch / pytorch/executorch

Vulkan missing partition constraints for unsupported dtypes

Open
#11,766 1 comment 0 reactions 0 assignees View on GitHub

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 passing a model containing tensors with an unsupported type, the Vulkan lowering code currently errors out. It should ideally include a partitioner constraint to allow these ops to fall back to CPU.

Affected dtypes:

  • float64
  • int16
  • uint16
  • uint32
  • uint64

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

class Model(torch.nn.Module):
    def __init__(self):
        super().__init__()
        
    def forward(self, x, y):
        return x + y

model = Model()
inputs = (
    torch.randn(5, 5).to(torch.float64),
    torch.randn(5, 5).to(torch.float64),
)

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(et_outputs)

et_outputs - eager_outputs

Output:

File [~/src/executorch/src/executorch/backends/vulkan/serialization/vulkan_graph_builder.py:82](http://localhost:8888/~/src/executorch/src/executorch/backends/vulkan/serialization/vulkan_graph_builder.py#line=81), in VkGraphBuilder.get_vk_datatype(torch_dtype)
     80     return vk_graph_schema.VkDataType.INT32
     81 else:
---> 82     raise AssertionError(f"Invalid dtype for vulkan_preprocess ({torch_dtype})")

AssertionError: Invalid dtype for vulkan_preprocess (torch.float64)
Versions

executorch commit https://github.com/pytorch/executorch/commit/67b6009d6b3b67eee775c8ed2fe30eae6e0bb65c (Jun 14)

cc @SS-JIA @manuelcandales @cbilgin

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with executorch/backends/vulkan/partitioner/vulkan_partitioner.py and the reported failure in src/executorch/backends/vulkan/serialization/vulkan_graph_builder.py, then run the provided float64 reproduction. Check how Vulkan partition constraints are defined for supported dtypes; done means float64, int16, uint16, uint32, and uint64 operations fall back to CPU instead of triggering the invalid-dtype assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.