Signed-off-by: zjy0516 <riverclouds.zhu@qq.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Thomas Parnell <tpa@zurich.ibm.com>
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
from vllm.v1.attention.backend import AttentionBackend, CommonAttentionMetadata
|
|
from vllm.v1.attention.backends.mamba_attn import (
|
|
BaseMambaAttentionMetadata,
|
|
BaseMambaAttentionMetadataBuilder,
|
|
)
|
|
|
|
|
|
class Mamba1AttentionBackend(AttentionBackend):
|
|
@staticmethod
|
|
def get_name() -> str:
|
|
return "MAMBA1_ATTN"
|
|
|
|
@staticmethod
|
|
def get_builder_cls() -> type["Mamba1AttentionMetadataBuilder"]:
|
|
return Mamba1AttentionMetadataBuilder
|
|
|
|
@classmethod
|
|
def is_ssm(cls) -> bool:
|
|
return True
|
|
|
|
|
|
@dataclass
|
|
class Mamba1AttentionMetadata(BaseMambaAttentionMetadata):
|
|
pass
|
|
|
|
|
|
class Mamba1AttentionMetadataBuilder(
|
|
BaseMambaAttentionMetadataBuilder[Mamba1AttentionMetadata]
|
|
):
|
|
metadata_cls = Mamba1AttentionMetadata
|
|
|
|
def build(
|
|
self,
|
|
common_prefix_len: int,
|
|
common_attn_metadata: CommonAttentionMetadata,
|
|
fast_build: bool = False,
|
|
**kwargs: Any,
|
|
) -> Mamba1AttentionMetadata:
|
|
return self._compute_common_metadata(common_attn_metadata)
|