pytorch / pytorch/executorch

Vulkan transposed conv 1d with padding outputs don't match eager

Open
#12,223 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

When running transposed 1d convolutions with non-zero padding, outputs appear to differ on Vulkan from eager/portable. 2d convs match eager, so it appears to be specific to 1d.

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,
        in_channels=3,
        out_channels=6,
        kernel_size=3,
        stride=1,
        padding=0,
        output_padding=0,
        dilation=1,
        groups=1,
        bias=True,
    ):
        super().__init__()
        self.conv_transpose = torch.nn.ConvTranspose1d(
            in_channels=in_channels,
            out_channels=out_channels,
            kernel_size=kernel_size,
            stride=stride,
            padding=padding,
            output_padding=output_padding,
            dilation=dilation,
            groups=groups,
            bias=bias,
        )
        
    def forward(self, x):
        return self.conv_transpose(x)
        
model = Model(padding=1)
inputs = (
    torch.randn(1, 3, 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}")

Outputs:

Eager: tensor([[[ 3.6827e-04,  8.7176e-02,  1.5530e-01,  1.4441e-02, -2.2248e-01,
           4.1725e-01,  3.9777e-01,  1.7344e-01,  3.2919e-01, -1.5062e-01],
         [ 3.7562e-01,  8.7056e-02, -6.4384e-02, -5.4967e-01, -3.3847e-01,
           9.1174e-02,  5.2505e-01,  2.4900e-02,  1.4130e-01, -2.7217e-01],
         [ 5.1456e-01, -5.1405e-01,  8.2588e-01,  3.1776e-01,  4.0517e-01,
           7.8431e-01,  5.5378e-01, -8.4821e-01,  2.9022e-01, -6.3156e-01],
         [-6.2516e-01, -2.7257e-01,  1.0314e-01, -4.9474e-01, -4.3499e-01,
           5.7006e-01,  1.5520e-01,  4.6114e-01,  2.1581e-02, -1.8103e-01],
         [-9.4353e-01, -6.9181e-01,  2.5498e-01,  4.7335e-01, -4.8148e-01,
          -7.0684e-01, -3.1567e-01,  2.9551e-01,  6.2566e-01,  4.6096e-01],
         [ 2.8539e-01, -5.2123e-01,  6.2500e-01, -6.2770e-02, -1.0032e-01,
          -9.5903e-03, -4.0735e-01, -3.3835e-01, -2.4980e-01, -2.4714e-01]]],
       grad_fn=<ConvolutionBackward0>)
ET:    tensor([[[ 0.2213,  0.1807, -0.2964,  0.6540,  0.0079,  0.1220, -0.0071,
          -0.2754,  0.4156, -0.0076],
         [-0.1886, -0.3058,  0.4922,  0.0562, -0.2637, -0.3762,  0.5868,
          -0.4053,  0.7218, -0.2779],
         [ 0.3281, -0.2045,  0.1255,  0.2463, -0.1629, -0.5110,  0.4856,
          -0.5372,  0.4979, -0.2450],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,
           0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,
           0.0000,  0.0000,  0.0000],
         [ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,
           0.0000,  0.0000,  0.0000]]])
Versions

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

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 by reproducing the provided example through executorch.backends.vulkan.partitioner.vulkan_partitioner.VulkanPartitioner and compare the eager and Executorch outputs. Trace the Vulkan handling of ConvTranspose1d with non-zero padding, then add or update coverage for this case. Done means the Vulkan output matches eager/portable for the reproduced configuration.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.