cccntu / minlora Goto Github PK
View Code? Open in Web Editor NEWminLoRA: a minimal PyTorch library that allows you to apply LoRA to any PyTorch model.
License: MIT License
minLoRA: a minimal PyTorch library that allows you to apply LoRA to any PyTorch model.
License: MIT License
Minimum example
import torch
import timm
from torch import nn
from minlora import add_lora, get_lora_params, get_lora_state_dict
model_timm = timm.create_model("vit_large_patch14_clip_336.openai", pretrained=True, num_classes=0, global_pool='avg')
add_lora(model_timm)
model_timm = nn.DataParallel(model_timm, device_ids=[0,1]).cuda()
with torch.no_grad():
asdf = model_timm(torch.randn(2, 3, 336, 336).cuda())
File "/home/anaconda3/envs/face/lib/python3.8/site-packages/minlora/model.py", line 39, in lora_forward
return X + torch.mm(*self.swap((self.lora_B, self.dropout_fn(self.lora_A)))).view(X.shape) * self.scaling
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0!
您好,请问您对blip2模型的加速研究有没有什么进展和思路,是否可以交流一下呢,万分感谢
Is it possible to specify layers in the lora_config by name rather than type?
For instance suppose I only wanted to apply lora to all layers with the name qkv
rather than all nn.Linear
layers, how would I do that?
Hey there,
This looks like a cool project! How do we use this for nanoGPT? :)
Can this be used with FSDP? I haven't seen any examples of using torch.nn.utils.parametrize
with FSDP.
Hi, thank you for your great work.
I want to use yours for my experiment.
I wonder get_lora_params() would load parameters to optimizer, but if the model itself can compute gradient, wouldn't the model still compute gradient?
Would be freezing the model enough for using minlora without the get_lora_params?
Also, when merging lora to the model to have another lora module, should I have to set lora_A and lora_B requires_grad=False before merging?
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.