From 45bd30e29d1e2f642c4d5b60562fcb5531e8164e Mon Sep 17 00:00:00 2001 From: VDV1985 <149584656+VDV1985@users.noreply.github.com> Date: Sat, 7 Mar 2026 20:14:46 +0300 Subject: [PATCH] [NPU] make torch_native lora backend a little bit faster (#17228) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Egor Filimonov <44640852+ssshinigami@users.noreply.github.com> Co-authored-by: ronnie_zheng --- python/sglang/srt/lora/torch_ops/lora_ops.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/lora/torch_ops/lora_ops.py b/python/sglang/srt/lora/torch_ops/lora_ops.py index 7e72b9d4f..562956327 100644 --- a/python/sglang/srt/lora/torch_ops/lora_ops.py +++ b/python/sglang/srt/lora/torch_ops/lora_ops.py @@ -35,7 +35,7 @@ def sgemm_lora_a_fwd( x_seq = inputs[token_offset : token_offset + seq_len, :] w_seq = weights[lora_idx, : num_slices * rank, :] - result = torch.einsum("si, oi -> so", x_seq, w_seq) + result = torch.mm(x_seq, w_seq.T) output[token_offset : token_offset + seq_len, : num_slices * rank] = ( scaling_tensor[lora_idx] * result ) @@ -98,11 +98,10 @@ def sgemm_lora_b_fwd( lora_idx, slice_start_output:slice_end_output, :rank ] # (slice_dim, rank) - result = torch.einsum("si, oi -> so", x_slice, w_slice) output[ token_offset : token_offset + seq_len, slice_start_output:slice_end_output, - ] += result + ].add_(torch.mm(x_slice, w_slice.T)) token_offset += seq_len