vllm.lora.lora_model ¶
LoRAModel ¶
A LoRA fine-tuned model.
Source code in vllm/lora/lora_model.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
__init__ ¶
__init__(
lora_model_id: int,
rank: int,
loras: dict[str, LoRALayerWeights],
is_3d_lora_weight: bool = False,
) -> None
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lora_model_id | int | The integer id for the lora model. | required |
rank | int | lora rank. | required |
loras | dict[str, LoRALayerWeights] | module name -> weights for lora-replaced layers. | required |
is_3d_lora_weight | bool | 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. | False |
Source code in vllm/lora/lora_model.py
_should_skip_module staticmethod ¶
Check if a module should be skipped based on skip prefixes
Source code in vllm/lora/lora_model.py
clone ¶
Return a copy of the object with different ids.
Will share the underlying tensors.
Source code in vllm/lora/lora_model.py
from_local_checkpoint classmethod ¶
from_local_checkpoint(
lora_dir: str,
expected_lora_modules: set[str],
peft_helper: PEFTHelper,
*,
lora_model_id: int | None = None,
device: str = "cuda",
dtype: dtype | None = None,
model_vocab_size: int | None = None,
weights_mapper: WeightsMapper | None = None,
tensorizer_config_dict: dict | None = None,
skip_prefixes: list[str] | None = None,
moe_ep_spec: MoEEPLoadSpec | None = None,
) -> LoRAModel
Create a LoRAModel from a local checkpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lora_dir | str | The local path that has lora data. | required |
expected_lora_modules | set[str] | Name of modules that are expected to be replaced by lora. | required |
peft_helper | PEFTHelper | Loaded lora configuration information. | required |
lora_model_id | int | None | LoRA model id. If not given, automatically set by a global counter. | None |
device | str | Device where the lora model is loaded. | 'cuda' |
dtype | dtype | None | dtype of the lora model weights. | None |
skip_prefixes | list[str] | 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."] | None |
moe_ep_spec | MoEEPLoadSpec | None | When 2D FusedMoE 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. | None |
Returns:
| Type | Description |
|---|---|
LoRAModel | Loaded LoRA Model. |
Source code in vllm/lora/lora_model.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | |
from_lora_tensors classmethod ¶
from_lora_tensors(
lora_model_id: int,
tensors: dict[str, Tensor],
peft_helper: PEFTHelper,
device: str = "cuda",
dtype: dtype | None = None,
model_vocab_size: int | None = None,
weights_mapper: WeightsMapper | None = None,
skip_prefixes: list[str] | None = None,
) -> LoRAModel
Create a LoRAModel from a dictionary of tensors.
Source code in vllm/lora/lora_model.py
MoEEPLoadSpec dataclass ¶
Per-expert-parallel slicing metadata for one FusedMoE 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.
Source code in vllm/lora/lora_model.py
_is_remote_expert_key ¶
_is_remote_expert_key(
raw_name: str, spec: MoEEPLoadSpec
) -> bool
Decide whether a checkpoint key belongs to a non-local expert.