Coder Social home page Coder Social logo

Conv2D and groups > 1 about lora HOT 4 CLOSED

microsoft avatar microsoft commented on May 12, 2024 2
Conv2D and groups > 1

from lora.

Comments (4)

edwardjhu avatar edwardjhu commented on May 12, 2024 4

Thanks everyone! This is indeed a bug.

Because the LoRA module in this case doesn't have a convolution structure, I don't see a reason to prefer one fix over another.

It's fixed now. 375704a

from lora.

ExponentialML avatar ExponentialML commented on May 12, 2024

Since it seems to be related, there's a possible issue when it comes to scaling Conv2d.
It seems that when creating new parameters, we have:

self.lora_A = nn.Parameter(
                self.weight.new_zeros((r*kernel_size, in_channels*kernel_size))
            )
self.lora_B = nn.Parameter(
    self.weight.new_zeros((out_channels*kernel_size, r*kernel_size))

The kernel size here is multiplied by the rank. We then scale this by self.scale = alpha / r.
I believe the appropriate solution should be something like:

scaled_rank = r * kernel_size
self.scale = alpha *  (r // scaled_rank)

Update:

This is no longer a problem for me, but could still be a viable option depending on the use case.

from lora.

yousuf907 avatar yousuf907 commented on May 12, 2024

I think the input_channels need to be divided by groups without modifying output channels since input channels are modified in nn.Conv2d weights of shape: [output_channels, input_channels / groups, kernel_size[0], kernel_size[1]].
Hence,
self.lora_A = nn.Parameter(self.weight.new_zeros((r*kernel_size, in_channels//self.groups*kernel_size))
self.lora_B = nn.Parameter(self.weight.new_zeros((out_channels*kernel_size, r*kernel_size))

from lora.

bbbxyz avatar bbbxyz commented on May 12, 2024

Thanks @edwardjhu !

from lora.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.