OneTrainer
OneTrainer copied to clipboard
LoKr: Low-Rank Kronecker Product
This PR introduces LoKr (Low-Rank Kronecker Product), a new parameter-efficient training method available alongside LoRA, and LoHa. LoKr constructs the update matrix from the Kronecker product of two smaller, more compact matrices. This provides a different and often more efficient way to parameterize the model's weight updates.
LoKr can be selected from the 'Type' dropdown in the training tab, which reveals LoKr-specific configuration options (it also supports DoRA for LoKr).
Key Benefits & Features
- Increased Parameter Efficiency: The Kronecker product can represent large, complex update matrices with significantly fewer parameters than a standard low-rank decomposition of a similar effective rank, leading to smaller adapter files.
- Enhanced Expressiveness: The structured nature of the Kronecker product allows the model to learn more intricate weight updates, which can improve performance and finetuning quality on a variety of tasks.
Implementation Details
- The core logic is implemented in
modules/util/LoRAModule.pythrough the newLoKrModuleclass, which handles the Kronecker product-based weight construction. - A new utility file,
modules/util/lokr_utils.py, contains helper functions (factorization,make_kron, etc.) adapted from the LyCORIS implementation to keep the main module clean and organized.
References
The implementation is based on LyCORIS & PEFT library.
- Code: https://github.com/KohakuBlueleaf/LyCORIS https://github.com/huggingface/peft/tree/main/src/peft/tuners/lokr
TODO
- [ ] To be tested
- [ ] The LoRA tab is a mess, and it needs some cleaning and reworking.