Skip to content

Vulkan amax/amin fail to lower with index out of range #12227

Open
@GregoryComer

Description

@GregoryComer

🐛 Describe the bug

Models containing amax or amin error out in partitioning when using Vulkan.

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 AmaxModel(torch.nn.Module):
    def forward(self, x):
        return torch.amax(x)
        
model = AmaxModel()
inputs = (
    torch.randn(10, 10),
)
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}")

Output:

Cell In[21], line 19
     17 ep = torch.export.export(model.eval(), inputs)
     18 print(ep)
---> 19 lowered = to_edge_transform_and_lower(
     20     ep,
     21     partitioner=[VulkanPartitioner()],
     22     compile_config=EdgeCompileConfig(_check_ir_validity=False)
     23 ).to_executorch()
     24 print(lowered.exported_program())
     26 et_model = _load_for_executorch_from_buffer(lowered.buffer)

...

File /data/users/gjcomer/fbsource/buck-out/v2/gen/fbcode/fdcb6705e87e1def/bento_kernels/cria/__bento_kernel_cria_binary__/bento_kernel_cria_binary#link-tree/executorch/backends/vulkan/op_registry.py:453, in register_reduce_op.<locals>.check_reduce_node(node)
    452 def check_reduce_node(node: torch.fx.Node) -> bool:
--> 453     dim_list = node.args[1]
    454     if isinstance(dim_list, list) and len(dim_list) != 1:
    455         return False
IndexError: tuple index out of range

Versions

Run on Meta internal master, Jul 3, fbcode/SwiftShader

cc @SS-JIA @manuelcandales @cbilgin

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend testerThis bug was found by the backend test suite.module: vulkanIssues related to the Vulkan delegate and code under backends/vulkan/

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions