Comments (6)
I wrote a script for that, but the resulting model won't fit in VRAM. (30b anyway)
import sys
sys.path.insert(0, './repository/transformers/src')
sys.path.insert(0, './repository/GPTQ-for-LLaMa')
sys.path.insert(0, './repository/peft/src')
import peft
import peft.tuners.lora
assert peft.tuners.lora.is_gptq_available()
import torch
import transformers
from autograd_4bit import load_llama_model_4bit_low_ram
from peft import LoraConfig, get_peft_model, get_peft_model_state_dict, PeftModel
print('PyTorch version:', torch.__version__)
print('Transformers version:', transformers.__version__)
print('PEFT version:', peft.__version__)
print('cuda:', torch.cuda.is_available())
# ! Config
from arg_parser import get_config
import train_data
ft_config = get_config()
# * Show loaded parameters
if ft_config.local_rank == 0:
print(f"{ft_config}\n")
if ft_config.gradient_checkpointing:
print('Disable Dropout.')
# Load Basic Model
model, tokenizer = load_llama_model_4bit_low_ram(ft_config.llama_q4_config_dir, ft_config.llama_q4_model, device_map=ft_config.device_map)
# Load base model and adapter
adapter_path = './alpaca_lora/adapter_model.bin'
adapter_weights = torch.load(adapter_path)
# Merge the adapter weights into the base model
for name, param in model.named_parameters():
if name in adapter_weights:
param.data = adapter_weights[name]
# Save the merged model
output_path = './merged_model'
model.save_pretrained(output_path)
from alpaca_lora_4bit.
I think it is hard to do because the 4-bit model is already quantized once and if you reconstruct it and add lora-weight to the weight and quantize it again the loss may be out of control. But technically feasible, if ignore the quality of the merged model.
But I have a plan to make a LoRA adapter that multiple LoRA can be used together just like that in stable diffusion.
from alpaca_lora_4bit.
How about applying it to the HF and then re-quantizing it? The new GPTQ requires doing that anyway. Ideally in FP16.
from alpaca_lora_4bit.
Yes then I think it's feasible.
And also, are those 4-bit checkpoints released?
from alpaca_lora_4bit.
For the other model types? I have the one for the GPTX-20 that someone uploaded. Otherwise they can just be slowly requantized.
from alpaca_lora_4bit.
The above script doesn't seem to work after the v2 GPTQ changes -- it produces a model file that is exactly the same as the original.
Anyone know how to fix (it looks like the layer names don't match for that for name,param
loop)?
from alpaca_lora_4bit.
Related Issues (20)
- How to use inference.py after finetune.py? HOT 2
- LoRA Output Identical to Base Model HOT 4
- Flash Attention 2 HOT 1
- Error attempting to finetune llama2-70b HOT 5
- High perplexity while lower loss after LoRA finetuning (how?) HOT 5
- Targeting all layers and biases HOT 2
- Feature request: Stop when loss reaches X HOT 1
- Is alpaca_lora_4bit@winglian-setup_pip missing finetune.py? HOT 1
- Unable to Build Wheels HOT 8
- Merging LoRA after finetune HOT 1
- OOM on inference while i can finetune with more tokens HOT 2
- module 'alpaca_lora_4bit.quant_cuda' has no attribute 'vecquant4recons_v2' HOT 4
- ValueError: Target module Autograd4bitQuantLinear() is not supported. HOT 7
- 3 errors detected in the compilation of "src/alpaca_lora_4bit/quant_cuda/quant_cuda_kernel.cu" HOT 2
- docker.io/nvidia/cuda:11.7.0-devel-ubuntu22.04 not available anymore HOT 1
- Finetuning CodeLLaMA34B - RuntimeError: The size of tensor a (1024) must match the size of tensor b (8192) HOT 3
- AttributeError: 'dict' object has no attribute 'to_dict' HOT 1
- trying to get this working with text-generation-webui HOT 9
- Why lora support is only for simple lora with only q_proj and v_proj ? HOT 1
- Support for moe model? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alpaca_lora_4bit.