vllm.lora.layers.base
¶
Classes:
BaseLayerWithLoRA
¶
Bases: Module
Methods:
-
can_replace_layer–Returns True if the layer can be replaced by this LoRA layer.
-
create_lora_weights–Initializes lora matrices.
-
load_weights–Load checkpoint weights into the wrapped base layer.
-
reset_lora–Resets the lora weights at index back to 0.
-
set_lora–Overwrites lora tensors at index.
-
slice_lora_a–Slice lora a if splitting for tensor parallelism.
-
slice_lora_b–Slice lora b if splitting with tensor parallelism.
Source code in vllm/lora/layers/base.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 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 | |
_slot_weights(index)
¶
Views of the LoRA A and B buffers of GPU slot index, per slice.
A is (max_lora_rank, input_size) and B is
(output_size, max_lora_rank), the orientation set_lora takes, but
local to this rank (sharded the way set_lora shards) and padded to
max_lora_rank. The views alias the buffers the forward reads, so an
in-place write takes effect on the next forward without a copy.
MoE factors additionally carry the local expert axis (one for shared
factors); see FusedMoEWithLoRA._slot_weights for their slice order.
Source code in vllm/lora/layers/base.py
can_replace_layer(source_layer, lora_config, packed_modules_list, model_config=None)
classmethod
¶
Returns True if the layer can be replaced by this LoRA layer.
Source code in vllm/lora/layers/base.py
create_lora_weights(max_loras, lora_config, model_config=None)
¶
load_weights(weights)
¶
Load checkpoint weights into the wrapped base layer.