Skip to content

vllm.lora.ops.triton_ops.lora_expand_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_expand(inputs, lora_b_weights, output_tensor, token_lora_mapping, token_indices_sorted_by_lora_ids, num_tokens_per_lora, lora_token_start_loc, lora_ids, no_lora_flag_cpu, num_active_loras, offset_start=0, add_inputs=False)

Args: inputs (torch.Tensor): input tensor lora_b_weights (list[torch.Tensor]): lora'b weight output_tensor (torch.Tensor): output tensor token_lora_mapping (torch.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. token_indices_sorted_by_lora_ids (torch.Tensor): Row/Token indices from the A matrix grouped by LoRA IDs. num_tokens_per_lora (torch.Tensor): num_tokens_per_lora[i] is the number of tokens that are to be processed by LoRA ID lora_ids[i] lora_token_start_loc (torch.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. lora_ids (torch.Tensor): LoRA ids to process. no_lora_flag_cpu (torch.Tensor): A CPU tensor of size 1, that indicates if there are any requests that require LoRA. offset_start (int, optional): Offset start for output_tensor. Defaults to 0. add_inputs (bool, optional): Whether to add the input tensor to the output tensor. Defaults to False.