[Kernel][Model] logits_soft_cap for Gemma2 with flashinfer (#6051)
Co-authored-by: Simon Mo <simon.mo@hey.com>
This commit is contained in:
@@ -102,6 +102,8 @@ class FlashInferMetadata(AttentionMetadata):
|
||||
# The data type of the paged kv cache
|
||||
data_type: torch.dtype = None
|
||||
device: torch.device = torch.device("cuda")
|
||||
# Only used by gemma2 model
|
||||
logits_soft_cap: Optional[float] = None
|
||||
|
||||
def __post_init__(self):
|
||||
# Refer to
|
||||
@@ -271,9 +273,11 @@ class FlashInferImpl(AttentionImpl):
|
||||
else:
|
||||
assert prefill_meta is not None
|
||||
assert prefill_meta.prefill_wrapper is not None
|
||||
output = prefill_meta.prefill_wrapper.forward(query,
|
||||
kv_cache,
|
||||
causal=True)
|
||||
output = prefill_meta.prefill_wrapper.forward(
|
||||
query,
|
||||
kv_cache,
|
||||
logits_soft_cap=attn_metadata.logits_soft_cap,
|
||||
causal=True)
|
||||
else:
|
||||
assert attn_metadata.decode_metadata is not None
|
||||
assert attn_metadata.decode_metadata.decode_wrapper is not None
|
||||
@@ -281,5 +285,5 @@ class FlashInferImpl(AttentionImpl):
|
||||
query,
|
||||
kv_cache,
|
||||
sm_scale=self.scale,
|
||||
)
|
||||
logits_soft_cap=attn_metadata.logits_soft_cap)
|
||||
return output.view(num_tokens, hidden_size)
|
||||
|
||||
@@ -77,9 +77,9 @@ def get_attn_backend(
|
||||
return IpexAttnBackend
|
||||
elif backend == _Backend.FLASHINFER:
|
||||
logger.info("Using Flashinfer backend.")
|
||||
logger.warning(("Flashinfer will be stuck on llma-2-7b,"
|
||||
" please avoid using Flashinfer as the"
|
||||
"backend when running on llma-2-7b."))
|
||||
logger.warning(("Flashinfer will be stuck on llama-2-7b,"
|
||||
" please avoid using Flashinfer as the "
|
||||
"backend when running on llama-2-7b."))
|
||||
from vllm.attention.backends.flashinfer import FlashInferBackend
|
||||
return FlashInferBackend
|
||||
elif backend == _Backend.PALLAS:
|
||||
|
||||
Reference in New Issue
Block a user