Skip to content
fn

convert_to_lora

→tuple of (LoraConfig, dict of str to Tensor)
convert_to_lora(model: nn.Module, rank: int | float, adapter_name: str = 'default', progressbar: bool = False, compile_kwargs: dict[str, object] | None = None)

Convert an additive PEFT adapter on model into a LoRA config and state dictionary.

Parameters

A PEFT model (or module containing PEFT tuner layers) whose additive delta weights can be decomposed into rank-r LoRA factors.
rankint or float
Target LoRA rank (positive integer) or cumulative squared singular-value threshold in [0.0, 1.0] used to pick each layer's rank dynamically.
adapter_namestr= "default"
Name of the adapter to convert.
progressbarbool= False
Accepted for signature parity with the reference adapter library.
compile_kwargsdict= None
Optional keyword arguments forwarded to lucid.compile around the per-layer SVD conversion helper.

Returns

tuple of (LoraConfig, dict of str to Tensor)

The converted LoraConfig and a LoRA state dict ready to save or load.

Used by 1