Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Add kv_scale input parameter to CPU backend #3840

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions vllm/attention/ops/paged_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,17 @@ def write_to_paged_cache(
value_cache: torch.Tensor,
slot_mapping: torch.Tensor,
kv_cache_dtype: str,
kv_scale: float,
kv_scale: Optional[float] = None,
) -> None:
optional_args = [x for x in (kv_scale, ) if x is not None]
cache_ops.reshape_and_cache(
key,
value,
key_cache,
value_cache,
slot_mapping.flatten(),
kv_cache_dtype,
kv_scale,
*optional_args,
)

@staticmethod
Expand All @@ -97,10 +98,11 @@ def forward_decode(
num_kv_heads: int,
scale: float,
alibi_slopes: Optional[torch.Tensor],
kv_scale,
kv_scale: Optional[float] = None,
) -> torch.Tensor:
output = torch.empty_like(query)
optional_args = [x for x in (kv_scale, ) if x is not None]

output = torch.empty_like(query)
block_size = value_cache.shape[3]
num_seqs, num_heads, head_size = query.shape
max_num_partitions = ((max_context_len + _PARTITION_SIZE - 1) //
Expand Down Expand Up @@ -129,7 +131,7 @@ def forward_decode(
max_context_len,
alibi_slopes,
kv_cache_dtype,
kv_scale,
*optional_args,
)
else:
# Run PagedAttention V2.
Expand Down Expand Up @@ -161,7 +163,7 @@ def forward_decode(
max_context_len,
alibi_slopes,
kv_cache_dtype,
kv_scale,
*optional_args,
)
return output

Expand Down
Loading