OneTrainer icon indicating copy to clipboard operation
OneTrainer copied to clipboard

LoKr: Low-Rank Kronecker Product

Open Koratahiu opened this issue 1 year ago • 0 comments

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.py through the new LoKrModule class, 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.

TODO

  • [ ] To be tested
  • [ ] The LoRA tab is a mess, and it needs some cleaning and reworking.

Known Issues

Koratahiu avatar Oct 26 '25 18:10 Koratahiu