GPT-2 Large — ASVD rank=640 + LoRA (CF-init)
LoRA adapter for GPT-2 Large after ASVD (activation-aware SVD) weight compression at rank=640, with closed-form residual initialization (LoftQ-style). The compressed + recovered model surpasses the uncompressed baseline while retaining a 1.6× theoretical inference speedup.
Results
| Stage | WikiText-2 PPL | × baseline |
|---|---|---|
| GPT-2 Large baseline (dense) | 27.56 | 1.00× |
| ASVD rank=640 (compressed only) | 153.82 | 5.58× |
| + LoRA epoch 1 | 24.64 | 0.894× |
| + LoRA epoch 2 | 23.85 | 0.865× |
| + LoRA epoch 3 (this checkpoint) | 23.79 | 0.863× |
13.7% better perplexity than the dense baseline, with 1.6× faster inference.
Method
ASVD compression (arXiv:2312.05821): weight columns are scaled by input activation statistics before SVD, then de-scaled after. This minimizes output error ||WX - W_k X|| rather than weight error ||W - W_k||, giving 34× better perplexity than naive SVD at the same rank.
Closed-form LoRA initialization: the same SVD that computes the ASVD approximation (using singular vectors [0:640]) also gives the best rank-16 correction of the residual via the next 16 singular vectors [640:656]. These are used to initialize LoRA weights before fine-tuning — placing the optimizer directly in the right subspace. This gives ~3% better final perplexity vs zero-init LoRA at identical training cost (55 min on a T4 GPU).
Key insight: the factored ASVD weights (A·B, rank=640) are used for inference — LoRA is discarded after training. The 1.6× speedup is fully preserved.
How to use
This adapter requires the ASVD-compressed base weights (not the original dense GPT-2 Large). You need to apply ASVD compression first, then load this adapter on top.
import torch
from transformers import GPT2LMHeadModel, GPT2Tokenizer
from peft import PeftModel
# Step 1: load and compress base model with ASVD rank=640
# (see experiments/08_gpt2large_lora_cf_init/modal_experiment.py for the full compression code)
# Step 2: load the LoRA adapter on the compressed model
model = GPT2LMHeadModel.from_pretrained("gpt2-large")
# ... apply ASVD compression here ...
model = PeftModel.from_pretrained(model, "medelharchaoui/gpt2-large-asvd640-lora-cf-init")
tokenizer = GPT2Tokenizer.from_pretrained("gpt2-large")
inputs = tokenizer("The quick brown fox", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0]))
Training details
| Parameter | Value |
|---|---|
| Base model | gpt2-large (774M params, 36 layers) |
| Compression | ASVD rank=640 on c_fc, c_proj (72 layers) |
| LoRA rank / alpha | 16 / 32 |
| LoRA dropout | 0.05 |
| LoRA init | Closed-form residual SVD (LoftQ-style) |
| Dataset | WikiText-2, 3 epochs |
| Trainable params | 8.85M / 782.9M = 1.13% |
| Hardware | Modal T4 GPU (~55 min) |
Related experiments
This checkpoint is from Experiment 08 of the OptIAI research project, which investigates low-rank factorization of LLM weight matrices for inference speedup.
| Exp | Method | PPL | × baseline |
|---|---|---|---|
| 06 | ASVD + LoRA (zero-init) | 24.53 | 0.890× |
| 07 | Closed-form correction only (rank=16) | 124.20 | 4.539× |
| 08 | ASVD + LoRA (CF-init) ← this | 23.79 | 0.863× |
Framework versions
- PEFT 0.19.1
- Transformers 4.x