[Model] PP support for Mamba-like models (#10992)
Signed-off-by: mzusman <mor.zusmann@gmail.com>
This commit is contained in:
@@ -363,6 +363,43 @@ def is_attention_free(
|
||||
return isinstance(model, IsAttentionFree)
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class IsHybrid(Protocol):
|
||||
"""The interface required for all models like Jamba that have both
|
||||
attention and mamba blocks, indicates that
|
||||
hf_config has 'layers_block_type'"""
|
||||
|
||||
is_hybrid: ClassVar[Literal[True]] = True
|
||||
"""
|
||||
A flag that indicates this model has both mamba and attention blocks
|
||||
, also indicates that the model's hf_config has
|
||||
'layers_block_type' """
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class _IsHybridType(Protocol):
|
||||
is_hybrid: ClassVar[Literal[True]]
|
||||
|
||||
|
||||
@overload
|
||||
def is_hybrid(model: object) -> TypeIs[IsHybrid]:
|
||||
...
|
||||
|
||||
|
||||
@overload
|
||||
def is_hybrid(model: Type[object]) -> TypeIs[Type[IsHybrid]]:
|
||||
...
|
||||
|
||||
|
||||
def is_hybrid(
|
||||
model: Union[Type[object], object]
|
||||
) -> Union[TypeIs[Type[IsHybrid]], TypeIs[IsHybrid]]:
|
||||
if isinstance(model, type):
|
||||
return isinstance(model, _IsHybridType)
|
||||
|
||||
return isinstance(model, IsHybrid)
|
||||
|
||||
|
||||
@runtime_checkable
|
||||
class SupportsCrossEncoding(Protocol):
|
||||
"""The interface required for all models that support cross encoding."""
|
||||
|
||||
Reference in New Issue
Block a user