vllm.lora.lora_model
¶
Classes:
-
LoRAModel–A LoRA fine-tuned model.
-
MoEEPLoadSpec–Per-expert-parallel slicing metadata for one FusedMoEFactory LoRA module.
LoRAModel
¶
A LoRA fine-tuned model.
Methods:
-
__init__–Args:
-
clone–Return a copy of the object with different ids.
-
from_local_checkpoint–Create a LoRAModel from a local checkpoint.
-
from_lora_tensors–Create a LoRAModel from a dictionary of tensors.
-
get_lora–Get LoRA for a given module by name.
__init__(lora_model_id, rank, loras, is_3d_lora_weight=False, *, modules_to_save=None)
¶
Args: lora_model_id: The integer id for the lora model. rank: lora rank. loras: module name -> weights for lora-replaced layers. is_3d_lora_weight: Whether the on-disk MoE adapter is in the 3D fused (gate_up_proj / down_proj) layout. Propagated from the originating LoRARequest. Only consulted by the LoRA model manager when enable_mixed_moe_lora_format is on.
_should_skip_module(module_name, skip_prefixes)
staticmethod
¶
Check if a module should be skipped based on skip prefixes.
clone(lora_model_id)
¶
Return a copy of the object with different ids.
Will share the underlying tensors.
from_local_checkpoint(lora_dir, expected_lora_modules, peft_helper, *, lora_model_id=None, device='cuda', dtype=None, model_vocab_size=None, weights_mapper=None, skip_prefixes=None, moe_ep_spec=None, unsupported_lora_modules=None)
classmethod
¶
Create a LoRAModel from a local checkpoint.
Parameters:
-
(lora_dir¶str) –The local path that has lora data.
-
(expected_lora_modules¶set[str]) –Name of modules that are expected to be replaced by lora.
-
(peft_helper¶PEFTHelper) –Loaded lora configuration information.
-
(lora_model_id¶int | None, default:None) –LoRA model id. If not given, automatically set by a global counter.
-
(device¶str, default:'cuda') –Device where the lora model is loaded.
-
(dtype¶dtype | None, default:None) –dtype of the lora model weights.
-
(model_vocab_size¶int | None, default:None) –Vocab size of the base model, used to size the embedding deltas.
-
(weights_mapper¶WeightsMapper | None, default:None) –Optional mapper rewriting checkpoint weight names to vLLM names.
-
(skip_prefixes¶list[str] | None, default:None) –List of module name prefixes to skip during loading. Models can define this to skip modules not used in inference (e.g., MTP layers). Format: ["mtp."]
-
(moe_ep_spec¶MoEEPLoadSpec | None, default:None) –When 2D FusedMoEFactory LoRA modules are present with expert parallelism enabled, the (ep_rank, local, global) slicing metadata shared across all MoE layers. Non-local expert weights are skipped at read time instead of being loaded and discarded later.
-
(unsupported_lora_modules¶set[str] | None, default:None) –Full names of model layers that match expected_lora_modules but are not wrapped by LoRA, such as BERT's pooler.dense. LoRA weights on them are unexpected.
Returns:
-
LoRAModel–Loaded LoRA Model.
from_lora_tensors(lora_model_id, tensors, peft_helper, device='cuda', dtype=None, model_vocab_size=None, weights_mapper=None, skip_prefixes=None, *, expected_lora_modules=None, unsupported_lora_modules=None, moe_ep_spec=None)
classmethod
¶
Create a LoRAModel from a dictionary of tensors.
get_lora(module_name)
¶
Get LoRA for a given module by name.
MoEEPLoadSpec
dataclass
¶
Per-expert-parallel slicing metadata for one FusedMoEFactory LoRA module.
Threaded into the LoRA loader so per-expert weights from EP ranks other than this one can be skipped before they ever hit CPU memory.
_is_remote_expert_key(raw_name, spec)
¶
Decide whether a checkpoint key belongs to a non-local expert.