Fix Plamo 2/3 & LFM2 for Transformers v5 (#38090)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
from collections.abc import Iterable
|
||||
from itertools import islice
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import torch
|
||||
from torch import nn
|
||||
@@ -71,30 +72,31 @@ from vllm.utils.torch_utils import direct_register_custom_op
|
||||
from vllm.v1.attention.backend import AttentionMetadata
|
||||
from vllm.v1.attention.backends.mamba2_attn import Mamba2AttentionMetadata
|
||||
|
||||
|
||||
# Only used for type hinting.
|
||||
class Plamo2Config(PretrainedConfig): # type: ignore
|
||||
model_type: str = "plamo2"
|
||||
if TYPE_CHECKING:
|
||||
|
||||
hidden_size: int
|
||||
num_hidden_layers: int
|
||||
rms_norm_eps: float
|
||||
# Attention
|
||||
num_attention_heads: int
|
||||
hidden_size_per_head: int
|
||||
num_key_value_heads: int
|
||||
# Mamba
|
||||
mamba_d_state: int
|
||||
mamba_d_conv: int
|
||||
mamba_num_heads: int
|
||||
mamba_step: int
|
||||
# MLP
|
||||
intermediate_size: int
|
||||
# Tokenizer
|
||||
vocab_size: int
|
||||
class Plamo2Config(PretrainedConfig): # type: ignore
|
||||
model_type: str = "plamo2"
|
||||
|
||||
hidden_size: int
|
||||
num_hidden_layers: int
|
||||
rms_norm_eps: float
|
||||
# Attention
|
||||
num_attention_heads: int
|
||||
hidden_size_per_head: int
|
||||
num_key_value_heads: int
|
||||
# Mamba
|
||||
mamba_d_state: int
|
||||
mamba_d_conv: int
|
||||
mamba_num_heads: int
|
||||
mamba_step: int
|
||||
# MLP
|
||||
intermediate_size: int
|
||||
# Tokenizer
|
||||
vocab_size: int
|
||||
|
||||
|
||||
def is_mamba(config: Plamo2Config, i: int) -> bool:
|
||||
def is_mamba(config: "Plamo2Config", i: int) -> bool:
|
||||
assert config.mamba_step > 1
|
||||
|
||||
if config.num_hidden_layers <= (config.mamba_step // 2):
|
||||
@@ -502,7 +504,7 @@ direct_register_custom_op(
|
||||
class DenseMLP(nn.Module):
|
||||
def __init__(
|
||||
self,
|
||||
config: Plamo2Config,
|
||||
config: "Plamo2Config",
|
||||
quant_config: QuantizationConfig | None = None,
|
||||
prefix: str = "",
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user