Fuse writing KV buffer into rope kernel (part 2: srt) (#9014)
Co-authored-by: fzyzcjy <5236035+fzyzcjy@users.noreply.github.com>
This commit is contained in:
@@ -222,6 +222,7 @@ class RotaryEmbedding(CustomOp):
|
||||
query: torch.Tensor,
|
||||
key: torch.Tensor,
|
||||
offsets: Optional[torch.Tensor] = None,
|
||||
fused_set_kv_buffer_arg=None, # Optional[FusedSetKVBufferArg]
|
||||
) -> Tuple[torch.Tensor, torch.Tensor]:
|
||||
if _is_cuda and (self.head_size in [64, 128, 256, 512]):
|
||||
apply_rope_with_cos_sin_cache_inplace(
|
||||
@@ -231,8 +232,17 @@ class RotaryEmbedding(CustomOp):
|
||||
head_size=self.head_size,
|
||||
cos_sin_cache=self.cos_sin_cache,
|
||||
is_neox=self.is_neox_style,
|
||||
# Compatible with old sgl-kernel
|
||||
**(
|
||||
dict(fused_set_kv_buffer_arg=fused_set_kv_buffer_arg)
|
||||
if fused_set_kv_buffer_arg is not None
|
||||
else {}
|
||||
),
|
||||
)
|
||||
else:
|
||||
assert (
|
||||
fused_set_kv_buffer_arg is None
|
||||
), "save kv cache is not supported for vllm_rotary_embedding."
|
||||
self.cos_sin_cache = self.cos_sin_cache.to(query.device, dtype=query.dtype)
|
||||
self.vllm_rotary_embedding(
|
||||
positions,
|
||||
|
||||
Reference in New Issue
Block a user