Skip to content

DoRA RuntimeError: shape is invalid when Conv2d(groups=2) #2549

@victolee0

Description

@victolee0

System Info

peft==0.15.2
torch==2.2.2

Who can help?

@BenjaminBossan @sayakpaul

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder
  • My own task or dataset (give details below)

Reproduction

from peft import LoraConfig, get_peft_model
import torch

class MyModel(torch.nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.conv = torch.nn.Conv2d(96, 192, (3, 3), stride=(2, 2), padding=(1, 1), bias=False, groups=2)
        self.fc = torch.nn.Linear(192, 10)

    def forward(self, x):
        x = self.conv(x)
        x = self.fc(x)
        return x


model = MyModel()

lora_config = LoraConfig(
    r=16,
    target_modules=["conv"],
    use_dora=True
)

model = get_peft_model(model, lora_config)

Expected behavior

RuntimeError: shape '[192, 48, 3, 3]' is invalid for input of size 165888

165888 / (192 * 48 * 3 * 3) = 2

when groups=2 got an error
if groups=1 works fine

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions