[Ascend] LoRA: adding Ascend LoRA backend with using kernels from sgl_kernel_npu (#12288)
Co-authored-by: ronnie_zheng <zl19940307@163.com> Co-authored-by: ssshinigami <44640852+ssshinigami@users.noreply.github.com>
This commit is contained in:
co-authored by
ronnie_zheng
ssshinigami
parent
7aa443903d
commit
c4b74c1db2
@@ -27,6 +27,8 @@ class BaseLayerWithLoRA(nn.Module):
|
||||
self.base_layer: nn.Module = base_layer
|
||||
self.set_lora: bool = False
|
||||
self.lora_backend: BaseLoRABackend = lora_backend
|
||||
if hasattr(self.base_layer, "weight"):
|
||||
self.weight = self.base_layer.weight
|
||||
|
||||
def forward(self, x: torch.Tensor):
|
||||
return self.base_layer.forward(x)
|
||||
@@ -198,6 +200,7 @@ class QKVParallelLinearWithLoRA(ColumnParallelLinearWithLoRA):
|
||||
dtype=torch.int32,
|
||||
device=next(self.base_layer.parameters()).device,
|
||||
)
|
||||
self.output_offset_cpu = self.output_offset.cpu()
|
||||
|
||||
# For computing number of launched blocks
|
||||
self.max_qkv_out_dim = max(q_proj_shard_size, kv_proj_shard_size)
|
||||
@@ -218,6 +221,7 @@ class QKVParallelLinearWithLoRA(ColumnParallelLinearWithLoRA):
|
||||
qkv_lora_b=self.B_buffer_qkv,
|
||||
base_output=base_output,
|
||||
output_offset=self.output_offset,
|
||||
output_offset_cpu=self.output_offset_cpu,
|
||||
max_qkv_out_dim=self.max_qkv_out_dim,
|
||||
)
|
||||
return lora_output
|
||||
|
||||
Reference in New Issue
Block a user