class
QuantizedLinear
extends
LinearQuantizedLinear(base_layer: nn.Module, adapter_name: str, r: int = 0, lora_alpha: float = 1, lora_dropout: float = 0.0, fan_in_fan_out: bool = False, is_target_conv_1d_layer: bool = False, init_lora_weights: bool | str = True, use_rslora: bool = False, use_dora: bool = False, lora_bias: bool = False, arrow_config: ArrowConfig | None = None)A quantized linear module (QuantizedLinearMLX, nn.quantized.Linear, or dynamic.Linear) with a float LoRA update (QLoRA).
The base layer keeps its quantized integer buffers frozen and executes its
low-precision or dequantized forward pass; the low-rank factors lora_A
and lora_B are allocated in float32 on the base buffers' device so
gradients flow through both the parallel LoRA branch and the base layer's
activation backward pass.
merge dequantizes the base weight, adds , and re-quantizes
in place while snapshotting the pre-merge quantized buffers so unmerge
restores the exact original packed state without double-quantization drift.
Parameters
base_ layernn.LinearThe layer to adapt; kept as
base_layer, its parameters shared.adapter_ namestrName of the adapter, the key in
lora_A / lora_B.rint= 0Rank. The default is the reference's and is refused: pass a
positive rank.
lora_ alphafloat= 1Numerator of the scale.
lora_ dropoutfloat= 0.0Dropout on the update's input.
fan_ in_ fan_ outbool= FalseMust be
False: nn.Linear stores its weight (out, in).is_ target_ conv_ 1d_ layerbool= FalseMust be
False; kept so positional calls line up with the
reference, whose fused-QKV Conv1D base v1 does not have.init_ lora_ weightsbool or str= TrueSee
LoraConfig; "pissa" and "olora" also rewrite the
base weight (the residual).use_ rslorabool= FalseScale by .
use_ dorabool= FalseWeight-decomposed update (DoRA): a magnitude vector
(
lora_magnitude_vector) beside the factors, so the layer computes
row by row.lora_ biasbool= FalseGive
lora_B a bias (lora_B.<adapter>.bias); merging folds it,
scaled, into the base bias.Make the adapter an Arrow router over the plain LoRA adapters the layer already
holds (
lora_arrow): each token goes through the top_k of them its
prototype is nearest to, and the router cannot be merged. Its own lora_A /
lora_B exist, as in the reference, and are not used.