vllm.lora.ops.triton_ops.lora_shrink_op
Based on: Chen, L., Ye, Z., Wu, Y., Zhuo, D., Ceze, L., & Krishnamurthy, A. (2023). Punica: Multi-Tenant LoRA Serving. https://arxiv.org/abs/2310.18547
_lora_shrink
¶
_lora_shrink(
inputs: Tensor,
lora_a_weights: list[Tensor],
output_tensor: Tensor,
token_lora_mapping: Tensor,
token_indices_sorted_by_lora_ids: Tensor,
num_tokens_per_lora: Tensor,
lora_token_start_loc: Tensor,
lora_ids: Tensor,
no_lora_flag_cpu: Tensor,
scaling: float,
) -> None
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inputs
|
Tensor
|
Input tensor |
required |
lora_a_weights
|
list[Tensor]
|
LoRA weights |
required |
output_tensor
|
Tensor
|
output tensor |
required |
token_lora_mapping
|
Tensor
|
A tensor mapping each input token to the lora-id related to that token. A value of -1 indicates that LoRA doesn't apply to that token. |
required |
token_indices_sorted_by_lora_ids
|
Tensor
|
Row/Token indices from the A matrix grouped by LoRA IDs. |
required |
num_tokens_per_lora
|
Tensor
|
num_tokens_per_lora[i] is the number of tokens that are to be processed by LoRA ID lora_ids[i] |
required |
lora_token_start_loc
|
Tensor
|
A cumulative sum of num_tokens_per_lora. lora_token_start_loc[0] is always 0 so that lora_token_start_loc[i], along with num_tokens_per_lora[i] identifies the region in token_indices_sorted_by_lora_ids that LoRA lora_ids[i] should process. |
required |
lora_ids
|
Tensor
|
LoRA ids to process. |
required |
no_lora_flag_cpu
|
Tensor
|
A CPU tensor of size 1, that indicates if there are any requests that require LoRA. |
required |
scaling
|
float
|
Scaling factor. |
required |
Source code in vllm/lora/ops/triton_ops/lora_shrink_op.py
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 |
|
_lora_shrink_fake
¶
_lora_shrink_fake(
inputs: Tensor,
lora_a_weights: list[Tensor],
output_tensor: Tensor,
token_lora_mapping: Tensor,
token_indices_sorted_by_lora_ids: Tensor,
num_tokens_per_lora: Tensor,
lora_token_start_loc: Tensor,
lora_ids: Tensor,
no_lora_flag_cpu: Tensor,
scaling: float,
) -> None
Source code in vllm/lora/ops/triton_ops/lora_shrink_op.py
_lora_shrink_kernel
¶
_lora_shrink_kernel(
input_ptr,
lora_ptr,
out_ptr,
M,
N,
K,
token_indices_sorted_by_lora_ids,
num_tokens_per_lora,
lora_token_start_loc,
lora_ids,
scaling,
input_d0_stride,
input_d1_stride,
lora_d0_stride,
lora_d1_stride,
lora_d2_stride,
output_d0_stride,
output_d1_stride,
output_d2_stride,
BLOCK_M: constexpr,
BLOCK_N: constexpr,
BLOCK_K: constexpr,
EVEN_K: constexpr,
SPLIT_K: constexpr,
SLICE_NUM: constexpr,
)