Skip to content

vllm.lora.lora_weights

Classes:

LoRAFullModuleWeights dataclass

LoRA weights for classification layers.

LoRALayerWeights

LoRA weights for a layer composed of two low rank matrixes.

Methods:

  • from_config –

    peft_module_name is the module name in the adapter checkpoint, used

  • optimize –

    Optimize the LoRA by merging the scaling into lora_b.

from_config(module_name, peft_helper, peft_module_name=None) classmethod

peft_module_name is the module name in the adapter checkpoint, used to resolve rank_pattern / alpha_pattern. Defaults to module_name.

optimize()

Optimize the LoRA by merging the scaling into lora_b.

PackedLoRALayerWeights

Bases: LoRALayerWeights

LoRA used for packed layers (eg. qkv_proj).

Methods:

  • optimize –

    Optimize the LoRA by merging the scaling into lora_b.

  • pack –

    Pack a list of LoRAs into a single LoRA.

  • pack_moe –

    Pack a list of LoRAs into a single LoRA.

  • pack_moe_stacked –

    Pack pre-stacked (3D) w1/w2/w3 expert LoRAs into a single LoRA.

optimize()

Optimize the LoRA by merging the scaling into lora_b.

pack(loras) classmethod

Pack a list of LoRAs into a single LoRA.

If LoRA is None, it signifies that the submodule does not have a LoRA.

pack_moe(loras, module_name, is_non_gated_moe=False) classmethod

Pack a list of LoRAs into a single LoRA.

If LoRA is None, it signifies that the submodule does not have a LoRA.

pack_moe_stacked(loras, module_name) classmethod

Pack pre-stacked (3D) w1/w2/w3 expert LoRAs into a single LoRA.

Unlike pack_moe, which stacks one 2D tensor per expert, this expects each of the three input LoRAs to already carry the expert dimension (experts.w{1,2,3}). It is used for "shared-outer" adapters where some factors are shared across experts (expert-dim 1) and cannot be reconstructed by stacking per-expert tensors. The produced lora_a/lora_b are the [w1, w2, w3] lists that FusedMoEWithLoRA.set_lora consumes directly.