Skip to content

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

Open
@GregoryComer

Description

@GregoryComer

🐛 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

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

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions