Activated LoRA (aLoRA)

raw JSON →
0.3.0 verified Fri May 01 auth: no python

Activated LoRA (aLoRA) is a low rank adapter architecture that allows reusing existing base model KV cache, built on top of PEFT. Version 0.3.0 is current; pre-1.0 release cadence is intermittent.

pip install alora
error AttributeError: 'str' object has no attribute 'config'
cause Passing a model name string instead of a model object to AloraModel.
fix
Instantiate model first: model = AutoModelForCausalLM.from_pretrained('gpt2'), then wrap with AloraModel(model, config).
error ModuleNotFoundError: No module named 'bitsandbytes'
cause bitsandbytes is not installed but required by PEFT for certain features.
fix
Install bitsandbytes: pip install bitsandbytes, or use the CPU-only fallback by disabling quantization in model config.
error ValueError: AloraConfig requires use_activated_lora=True
cause Omitting use_activated_lora in AloraConfig leads to silent fallback to standard LoRA.
fix
Set use_activated_lora=True explicitly in AloraConfig to enable aLoRA behavior.
breaking v0.3.0 changed base class from PEFT's LoraModel to PeftModel. Custom subclasses of AloraModel may break if they rely on LoraModel internals.
fix Update any custom subclass to use PeftModel instead of LoraModel, or pin alora==0.2.0.
deprecated bitsandbytes import path changed in PEFT; direct bnb imports are deprecated. Alora uses peft.utils for bnb-related modules.
fix Ensure bitsandbytes is installed and use from peft.import_utils import is_bnb_available instead of direct bnb imports.
gotcha AloraModel expects a HuggingFace model as the first argument, not model id. Passing a string causes AttributeError.
fix Always call with an instantiated model object: AloraModel(model, config), not AloraModel('model_name', config).

Instantiate aLoraConfig, wrap a base model with AloraModel, and generate text.

from transformers import AutoModelForCausalLM, AutoTokenizer
from alora import AloraConfig, AloraModel

model_name = "gpt2"
model = AutoModelForCausalLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)

alora_config = AloraConfig(
    r=8,
    lora_alpha=16,
    target_modules=["q_proj", "v_proj"],
    use_activated_lora=True
)

model = AloraModel(model, alora_config)

inputs = tokenizer("Hello, I'm", return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=20)
print(tokenizer.decode(outputs[0]))