pytorch / pytorch/executorch

Swin_v2_t fails at runtime on Vulkan

Open
#14,054 0 comments 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

The swin_v2_t model from torchvision fails at runtime on the Vulkan backend with "RuntimeError: Exception raised from get_uniform_data at /Users/gjcomer/src/executorch/../executorch/backends/vulkan/runtime/api/containers/Tensor.h:679: (sizes_.size() <= 4) is false!".

This can be reproduced with the following test case command or standalone script.

python -m executorch.backends.test.suite.runner models --flow vulkan --filter "test_swin_v2_t_vulkan_float32$"

Standalone repro:

import torch
import torchvision
from executorch.exir import to_edge_transform_and_lower

from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner

inputs = (torch.randn(1, 3, 224, 224),)
model = torchvision.models.swin_v2_t().eval()

ep = torch.export.export(model, inputs)

model = to_edge_transform_and_lower(
    torch.export.export(model, inputs),
    partitioner=[VulkanPartitioner()],
).to_executorch()

print("Running model...")
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
loaded_model = _load_for_executorch_from_buffer(model.buffer)
loaded_model([*inputs])

Note that running the backend test case requires executorch's python bindings to be built with the Vulkan backend. An example build command is below.

CMAKE_ARGS="-DEXECUTORCH_BUILD_VULKAN=ON" ./install_executorch.sh --editable
Versions

Commit fbda3a9545de747329577bd910086072ec5c7ad1, M1 Mac, using MoltenVK

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

Build the Python bindings with Vulkan enabled, then run the listed test command or standalone Swin v2_t reproduction. Start at the reported Vulkan runtime location, executorch/backends/vulkan/runtime/api/containers/Tensor.h:679, and trace the failing tensor shape. Done means the test model loads and runs on Vulkan without the runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.