LyCORIS
raw JSON → 3.4.0 verified Mon Apr 27 auth: no python
LyCORIS is a PyTorch library implementing advanced LoRA variants (LoRA, LoHa, LoKr, (IA)^3, Diag-OFT, BOFT) for parameter-efficient fine-tuning, particularly for Stable Diffusion. Current version 3.4.0, requires Python >=3.10. Active development with monthly releases.
pip install lycoris-lora Common errors
error ModuleNotFoundError: No module named 'lycoris.network' ↓
cause Old import path from v2 or earlier.
fix
Replace
from lycoris.network import LycorisNetwork with from lycoris import LycorisNetwork. error AttributeError: 'LycorisNetwork' object has no attribute 'apply_to' ↓
cause API changed in v3. `apply_to` was removed.
fix
Use
from lycoris import create_lycoris; lycoris = create_lycoris(model, ...). error RuntimeError: DataLoader worker (pid(s) ...) exited unexpectedly ↓
cause PyTorch DataLoader multiprocessing conflict with LyCORIS internal state.
fix
Set
num_workers=0 in DataLoader or wrap LyCORIS module in a proper nn.Module. Warnings
breaking In v3.0.0, the import paths changed. `from lycoris.network import LycorisNetwork` is deprecated; use `from lycoris import LycorisNetwork`. ↓
fix Update imports to top-level `lycoris` module.
breaking The `LycorisNetwork` API changed: `create_lycoris` replaced the old `LycorisNetwork.apply_to` method. ↓
fix Use `create_lycoris(model, ...)` instead of `model.apply_to(...)`.
gotcha LyCORIS modules are not serializable by default. Use `lycoris.save_weights()` and `lycoris.load_weights()` for checkpointing. ↓
fix Always use provided save/load methods, not torch.save on the network directly.
deprecated The 'lora' algorithm is considered stable but 'lokr' may be deprecated in future releases. ↓
fix Prefer 'loha' or 'boft' for new projects.
Imports
- LycorisNetwork wrong
from lycoris.network import LycorisNetworkcorrectfrom lycoris import LycorisNetwork - create_lycoris_from_weights wrong
from lycoris import create_lycoris_from_weightscorrectfrom lycoris.utils import create_lycoris_from_weights
Quickstart
import torch
from lycoris import LycorisNetwork, create_lycoris
model = LycorisNetwork(
in_features=768,
out_features=768,
rank=4,
algo='lora' # 'lora', 'loha', 'lokr', 'ia3', 'diyag-oft', 'boft'
)
lycoris = create_lycoris(model, multiplier=1.0)
print('LyCORIS module created successfully.')