Skip to main content
In addition to standard LoRA, sd-scripts supports LoHa and LoKr as alternative parameter-efficient fine-tuning methods. Both are based on techniques from the LyCORIS project by KohakuBlueleaf and offer different mathematical structures for representing weight updates.
LoHa and LoKr are experimental features. They are confirmed to work in basic testing but may have edge cases or behavior changes in future releases. Report any issues you encounter.

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:
Where 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:
The original weight dimensions are factorized — for example, a 512×512 weight might split into W1 (16×16) and W2 (32×32). W1 is always a full matrix (small), while W2 can be either low-rank decomposed or a full matrix depending on the rank setting. This factorization tends to produce smaller output files compared to LoRA at the same rank.

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.

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):
To enable Tucker decomposition for those Conv2d 3×3+ layers:
  • 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:
This includes LLMAdapterTransformerBlock modules as training targets.

Inference

Trained LoHa and LoKr weights are saved in safetensors format, just like standard LoRA weights.
Replace networks.loha with networks.lokr for LoKr weights.