Skip to content

[Bug] groups parameter is ignored in Model due to positional argument misalignment #157

Description

@diyarora

Description

When initializing Model, the groups parameter is silently ignored and falls back to its default value of 1 in KernelBench/level1/73_conv_transposed_3D_asymmetric_input_square_kernel__strided_padded__grouped.py

This happens because output_padding is included in the class __init__ signature but is missing from the get_init_inputs() list. When the arguments are unpacked positionally, the groups value is accidentally assigned to output_padding. Additionally, output_padding is completely missing from the inner nn.ConvTranspose3d instantiation.

Expected behavior

The groups argument should be correctly passed down to the nn.ConvTranspose3d layer, and output_padding should be properly handled.

Actual behavior

  1. get_init_inputs() returns a list of 6 items, missing output_padding.
  2. The 6th item (groups=4) is passed to the 6th parameter in __init__ (output_padding).
  3. groups in __init__ receives nothing and defaults to 1.
  4. output_padding is never passed to nn.ConvTranspose3d.

Steps to reproduce

import torch
import torch.nn as nn

class Model(nn.Module):
    def __init__(self, in_channels: int, out_channels: int, kernel_size: int, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, bias: bool = False):
        super(Model, self).__init__()
        # BUG: output_padding is missing here
        self.conv_transpose3d = nn.ConvTranspose3d(in_channels, out_channels, kernel_size=(kernel_size, kernel_size, kernel_size), stride=stride, padding=padding, output_padding=output_padding, groups=groups, bias=bias)

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        return self.conv_transpose3d(x)

# Test code
batch_size = 4
in_channels = 32
out_channels = 32
kernel_size = 3
depth = 32
height = 64
width = 128
stride = 2
padding = 1
groups = 4

def get_init_inputs():
    # BUG: output_padding is missing from this positional list
    return [in_channels, out_channels, kernel_size, stride, padding, groups]

# If we run: model = Model(*get_init_inputs())
# output_padding becomes 4, and groups defaults to 1.

### Proposed Fix
Update the test code to include output_padding and add output_padding to the nn.ConvTranspose3d call to resolve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions