What are LoHa and LoKr?
LoHa
Low-rank Hadamard Product. Represents weight updates as the element-wise (Hadamard) product of two low-rank matrix pairs. Based on FedPara (arXiv:2108.06098). Can capture more complex weight structures than LoRA at the same rank, with roughly twice the trainable parameters.
LoKr
Low-rank Kronecker Product. Represents weight updates using a Kronecker product with optional low-rank decomposition. Based on LoKr (arXiv:2309.14859). Tends to produce smaller models than LoRA at the same rank by factorizing weight dimensions.
How they work
LoHa
LoHa decomposes the weight update into two pairs of low-rank matrices combined via element-wise multiplication:W1a, W1b, W2a, W2b are all low-rank matrices with rank network_dim. The Hadamard (element-wise) product allows LoHa to represent more complex weight patterns than LoRA, but at the cost of approximately twice the parameters for the same rank.
For Conv2d 3×3+ layers with Tucker decomposition enabled, each matrix pair additionally uses a Tucker tensor T, giving:
LoKr
LoKr decomposes the weight update using a Kronecker product:Comparison table
Supported architectures
Both LoHa and LoKr automatically detect the model architecture and apply appropriate defaults.Training
To use LoHa or LoKr, change--network_module in your training command. All other options (dataset config, optimizer, scheduler, etc.) work the same as standard LoRA.
- LoHa (SDXL)
- LoKr (SDXL)
- Anima
network_args options
Pass these via--network_args "key=value" on the command line.
Common options (both LoHa and LoKr)
Conv2d support
By default, both methods target Linear and Conv2d 1×1 layers. To also train Conv2d 3×3+ layers (e.g., ResNet blocks in SDXL):- Without
use_tucker: Kernel dimensions are flattened into the input dimension (flat mode). - With
use_tucker=True: A separate Tucker tensor handles kernel dimensions — more parameter-efficient in some cases.
LoKr-specific: factor
LoKr factorizes weight dimensions. The factor option controls how the split is done:
When
network_dim is large enough relative to the factorized dimensions, LoKr uses a full matrix instead of low-rank decomposition for the second factor. A warning is logged in this case.Anima-specific: train_llm_adapter
For Anima models, you can also train the LLM adapter modules:
LLMAdapterTransformerBlock modules as training targets.
Inference
Trained LoHa and LoKr weights are saved in safetensors format, just like standard LoRA weights.- SDXL
- Anima
networks.loha with networks.lokr for LoKr weights.