[CI] Bump Transformers version to 5.17.0 (#56108)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Claude Opus 5
parent
f8b5c11468
commit
ec4a3a5370
@@ -1174,7 +1174,7 @@ tqdm==4.67.3
|
||||
# segmentation-models-pytorch
|
||||
# sentence-transformers
|
||||
# transformers
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
# via
|
||||
# -r requirements/test/../common.txt
|
||||
# -r requirements/test/cuda.in
|
||||
|
||||
@@ -39,7 +39,7 @@ open_clip_torch==2.32.0 # Required for nemotron_vl test, Nemotron Parse in test_
|
||||
datamodel_code_generator # required for minicpm3 test
|
||||
lm-eval[api]>=0.4.12 # required for model evaluation test
|
||||
mteb[bm25s]>=2, <3 # required for mteb test
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
schemathesis>=4.0.0 # Required for openai schema test.
|
||||
# quantization
|
||||
buildkite-test-collector==0.1.9
|
||||
|
||||
@@ -1281,7 +1281,7 @@ tqdm==4.67.3
|
||||
# segmentation-models-pytorch
|
||||
# sentence-transformers
|
||||
# transformers
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
# via
|
||||
# -c requirements/common.txt
|
||||
# -r requirements/test/../common.txt
|
||||
|
||||
@@ -29,7 +29,7 @@ opencv-python-headless >= 4.13.0 # required for video test
|
||||
datamodel_code_generator # required for minicpm3 test
|
||||
lm-eval[api]>=0.4.12 # required for model evaluation test
|
||||
mteb[bm25s]>=2, <3 # required for mteb test
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
schemathesis>=4.0.0 # Required for openai schema test.
|
||||
# quantization
|
||||
buildkite-test-collector==0.1.9
|
||||
|
||||
@@ -35,7 +35,7 @@ open_clip_torch==2.32.0 # Required for nemotron_vl test, Nemotron Parse in test_
|
||||
datamodel_code_generator # required for minicpm3 test
|
||||
lm-eval[api]>=0.4.12 # required for model evaluation test
|
||||
mteb[bm25s]>=2, <3 # required for mteb test
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
schemathesis>=4.0.0 # Required for openai schema test
|
||||
# quantization
|
||||
bitsandbytes==0.50.0
|
||||
|
||||
@@ -1233,7 +1233,7 @@ tqdm==4.67.3
|
||||
# sentence-transformers
|
||||
# tilelang
|
||||
# transformers
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
# via
|
||||
# -c requirements/common.txt
|
||||
# -r requirements/test/../common.txt
|
||||
|
||||
@@ -19,7 +19,7 @@ lm_eval[api]>=0.4.12
|
||||
modelscope<1.38
|
||||
runai-model-streamer[s3,gcs,azure]>=0.15.7
|
||||
tensorizer==2.10.1
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
|
||||
# --- Audio Processing ---
|
||||
av
|
||||
|
||||
@@ -1081,7 +1081,7 @@ tqdm==4.70.0
|
||||
# pqdm
|
||||
# sentence-transformers
|
||||
# transformers
|
||||
transformers==5.16.1
|
||||
transformers==5.17.0
|
||||
# via
|
||||
# -c requirements/common.txt
|
||||
# -r requirements/test/../common.txt
|
||||
|
||||
@@ -54,8 +54,19 @@ from vllm.sequence import IntermediateTensors
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
def get_mlp_layer_types(config) -> list[str]:
|
||||
"""Return which layers are MoE, rejecting configs predating Transformers support."""
|
||||
mlp_layer_types = getattr(config, "mlp_layer_types", None)
|
||||
if mlp_layer_types is None:
|
||||
raise ValueError(
|
||||
"Laguna requires the `LagunaConfig` from Transformers, which is "
|
||||
"available from v5.17.0. Please update Transformers to run this model."
|
||||
)
|
||||
return mlp_layer_types
|
||||
|
||||
|
||||
class LagunaMLP(nn.Module):
|
||||
"""Dense MLP for Laguna (used in mlp_only_layers)."""
|
||||
"""Dense MLP for Laguna."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -206,7 +217,7 @@ class LagunaMoE(nn.Module):
|
||||
top_k=config.num_experts_per_tok,
|
||||
hidden_size=config.hidden_size,
|
||||
intermediate_size=config.moe_intermediate_size,
|
||||
renormalize=config.norm_topk_prob,
|
||||
renormalize=True,
|
||||
quant_config=quant_config,
|
||||
prefix=f"{prefix}.experts",
|
||||
scoring_func="sigmoid",
|
||||
@@ -293,13 +304,12 @@ class LagunaAttention(nn.Module):
|
||||
else:
|
||||
self.sliding_window = None
|
||||
|
||||
# QKV projection (no bias for Laguna)
|
||||
self.qkv_proj = QKVParallelLinear(
|
||||
self.hidden_size,
|
||||
self.head_dim,
|
||||
self.total_num_heads,
|
||||
self.total_num_kv_heads,
|
||||
bias=config.qkv_bias,
|
||||
bias=config.attention_bias,
|
||||
quant_config=quant_config,
|
||||
prefix=f"{prefix}.qkv_proj",
|
||||
)
|
||||
@@ -506,14 +516,9 @@ class LagunaDecoderLayer(nn.Module):
|
||||
),
|
||||
)
|
||||
|
||||
# Check if this layer uses MoE or dense MLP (matches Qwen2/Qwen3 convention)
|
||||
mlp_only_layers = (
|
||||
[] if not hasattr(config, "mlp_only_layers") else config.mlp_only_layers
|
||||
)
|
||||
self.is_moe_layer = (
|
||||
(layer_idx not in mlp_only_layers)
|
||||
and (config.num_experts > 0)
|
||||
and ((layer_idx + 1) % config.decoder_sparse_step == 0)
|
||||
get_mlp_layer_types(config)[layer_idx] == "sparse"
|
||||
and config.num_experts > 0
|
||||
)
|
||||
|
||||
if self.is_moe_layer:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
import importlib.metadata
|
||||
import math
|
||||
from collections.abc import Iterable, Mapping, Sequence
|
||||
from dataclasses import dataclass, fields
|
||||
@@ -12,15 +13,12 @@ import torch.nn as nn
|
||||
from mistral_common.protocol.instruct.chunk import ImageChunk, TextChunk
|
||||
from mistral_common.protocol.instruct.messages import UserMessage
|
||||
from mistral_common.protocol.instruct.request import ChatCompletionRequest
|
||||
from packaging.version import Version
|
||||
from transformers import BatchFeature, PixtralVisionConfig
|
||||
from transformers.models.pixtral.image_processing_pixtral import (
|
||||
_num_image_tokens as _get_pixtral_hf_num_image_tokens,
|
||||
)
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
PixtralRotaryEmbedding,
|
||||
apply_rotary_pos_emb,
|
||||
position_ids_in_meshgrid,
|
||||
)
|
||||
from transformers.models.pixtral.modeling_pixtral import apply_rotary_pos_emb
|
||||
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.config.multimodal import BaseDummyOptions
|
||||
@@ -92,6 +90,39 @@ from .vision import (
|
||||
|
||||
PATCH_MERGE = "patch_merge"
|
||||
|
||||
# Transformers 5.17 renamed Pixtral's rotary embedding and switched it to axial
|
||||
# RoPE, which takes 2D (height, width) positions instead of flattened grid ids.
|
||||
TRANSFORMERS_VERSION = importlib.metadata.version("transformers")
|
||||
TRANSFORMERS_WITH_AXIAL_ROPE = Version(TRANSFORMERS_VERSION) >= Version("5.17.0.dev0")
|
||||
|
||||
if TRANSFORMERS_WITH_AXIAL_ROPE:
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
PixtralVisionRotaryEmbedding,
|
||||
)
|
||||
else:
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
PixtralRotaryEmbedding as PixtralVisionRotaryEmbedding,
|
||||
)
|
||||
from transformers.models.pixtral.modeling_pixtral import (
|
||||
position_ids_in_meshgrid as flat_position_ids_in_meshgrid,
|
||||
)
|
||||
|
||||
|
||||
def position_ids_in_meshgrid(
|
||||
patch_embeds_list: list[torch.Tensor],
|
||||
max_width: int,
|
||||
) -> torch.Tensor:
|
||||
if not TRANSFORMERS_WITH_AXIAL_ROPE:
|
||||
return flat_position_ids_in_meshgrid(patch_embeds_list, max_width)
|
||||
positions = []
|
||||
for patch in patch_embeds_list:
|
||||
height, width = patch.shape[-2:]
|
||||
h_ids, w_ids = torch.meshgrid(
|
||||
torch.arange(height), torch.arange(width), indexing="ij"
|
||||
)
|
||||
positions.append(torch.stack([h_ids.flatten(), w_ids.flatten()], dim=-1))
|
||||
return torch.cat(positions, dim=0)
|
||||
|
||||
|
||||
def _make_packed_sequence_metadata(
|
||||
sequence_lengths: list[int],
|
||||
@@ -1467,7 +1498,9 @@ class PixtralHFVisionModel(nn.Module):
|
||||
|
||||
self.dtype = next(self.parameters()).dtype
|
||||
self.device = next(self.parameters()).device
|
||||
self.patch_positional_embedding = PixtralRotaryEmbedding(config, self.device)
|
||||
self.patch_positional_embedding = PixtralVisionRotaryEmbedding(config).to(
|
||||
self.device
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
|
||||
@@ -76,7 +76,7 @@ from vllm.transformers_utils.configs.qwen4_exp import (
|
||||
from vllm.v1.attention.backends.registry import MambaAttentionBackendEnum
|
||||
from vllm.v1.kv_cache_interface import MambaSpec
|
||||
|
||||
from ..config import Qwen4ExpConfig
|
||||
from ..config import ATTENTION_LAYER_TYPES, QSA_LAYER_TYPE, Qwen4ExpConfig
|
||||
from .hyperconnection import GatedResidual, HyperConnectionConfig
|
||||
from .low_latency_gemm import enable_qwen4_exp_low_latency_gemm
|
||||
from .ple_layer import Qwen4ExpPLELayer
|
||||
@@ -214,8 +214,11 @@ class Qwen4ExpDecoderLayer(nn.Module):
|
||||
prefix=f"{prefix}.linear_attn",
|
||||
gqa_interleaved_layout=False,
|
||||
)
|
||||
elif layer_type == "full_attention":
|
||||
use_qsa = getattr(config, "indexer_n_heads", None) is not None
|
||||
elif layer_type in ATTENTION_LAYER_TYPES:
|
||||
use_qsa = (
|
||||
layer_type == QSA_LAYER_TYPE
|
||||
or getattr(config, "indexer_n_heads", None) is not None
|
||||
)
|
||||
if not use_qsa:
|
||||
self.self_attn = Qwen3NextAttention(
|
||||
config,
|
||||
@@ -311,7 +314,7 @@ class Qwen4ExpDecoderLayer(nn.Module):
|
||||
|
||||
if self.layer_type == "linear_attention":
|
||||
attn_out = self.linear_attn(hidden_states=block_input)
|
||||
elif self.layer_type == "full_attention":
|
||||
elif self.layer_type in ATTENTION_LAYER_TYPES:
|
||||
attn_out = self.self_attn(
|
||||
hidden_states=block_input,
|
||||
positions=positions,
|
||||
@@ -402,8 +405,11 @@ class Qwen4ExpModel(nn.Module):
|
||||
self._qsa_layer_ids = frozenset(
|
||||
layer_idx
|
||||
for layer_idx, layer_type in enumerate(config.layer_types)
|
||||
if layer_type == "full_attention"
|
||||
and getattr(config, "indexer_n_heads", None) is not None
|
||||
if layer_type == QSA_LAYER_TYPE
|
||||
or (
|
||||
layer_type == "full_attention"
|
||||
and getattr(config, "indexer_n_heads", None) is not None
|
||||
)
|
||||
)
|
||||
self.embed_tokens = VocabParallelEmbedding(self.vocab_size, config.hidden_size)
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ _QSA_CONFIG_FIELDS = (
|
||||
"indexer_compress_ratio",
|
||||
)
|
||||
|
||||
# Transformers labels Qwen4Exp's sparse-attention layers `qwen_sparse_attention`.
|
||||
# Older checkpoints label them `full_attention` and mark QSA by setting the
|
||||
# indexer fields for the whole model.
|
||||
QSA_LAYER_TYPE = "qwen_sparse_attention"
|
||||
ATTENTION_LAYER_TYPES = ("full_attention", QSA_LAYER_TYPE)
|
||||
|
||||
|
||||
class Qwen4ExpVisionConfig(Qwen3VLVisionConfig):
|
||||
model_type = "qwen4_exp"
|
||||
@@ -134,6 +140,11 @@ class Qwen4ExpTextConfig(Qwen3NextConfig):
|
||||
def _validate_qsa_config(self) -> None:
|
||||
configured = {name: getattr(self, name, None) for name in _QSA_CONFIG_FIELDS}
|
||||
if all(value is None for value in configured.values()):
|
||||
if QSA_LAYER_TYPE in (self.layer_types or ()):
|
||||
raise ValueError(
|
||||
f"{QSA_LAYER_TYPE} layers require the QSA config fields: "
|
||||
f"{list(_QSA_CONFIG_FIELDS)}"
|
||||
)
|
||||
return
|
||||
|
||||
missing = [name for name, value in configured.items() if value is None]
|
||||
@@ -165,7 +176,7 @@ class Qwen4ExpTextConfig(Qwen3NextConfig):
|
||||
@property
|
||||
def layers_block_type(self) -> list[str]:
|
||||
return [
|
||||
"attention" if layer_type == "full_attention" else layer_type
|
||||
"attention" if layer_type in ATTENTION_LAYER_TYPES else layer_type
|
||||
for layer_type in self.layer_types
|
||||
]
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ from vllm.transformers_utils.configs.qwen4_exp import (
|
||||
from vllm.v1.attention.backends.registry import MambaAttentionBackendEnum
|
||||
from vllm.v1.kv_cache_interface import MambaSpec
|
||||
|
||||
from ..config import Qwen4ExpConfig
|
||||
from ..config import ATTENTION_LAYER_TYPES, QSA_LAYER_TYPE, Qwen4ExpConfig
|
||||
from .hyperconnection import GatedResidual, HyperConnectionConfig
|
||||
from .low_latency_gemm import enable_qwen4_exp_low_latency_gemm
|
||||
from .ple_layer import Qwen4ExpPLELayer
|
||||
@@ -215,8 +215,11 @@ class Qwen4ExpDecoderLayer(nn.Module):
|
||||
prefix=f"{prefix}.linear_attn",
|
||||
gqa_interleaved_layout=False,
|
||||
)
|
||||
elif layer_type == "full_attention":
|
||||
use_qsa = getattr(config, "indexer_n_heads", None) is not None
|
||||
elif layer_type in ATTENTION_LAYER_TYPES:
|
||||
use_qsa = (
|
||||
layer_type == QSA_LAYER_TYPE
|
||||
or getattr(config, "indexer_n_heads", None) is not None
|
||||
)
|
||||
if not use_qsa:
|
||||
self.self_attn = Qwen3NextAttention(
|
||||
config,
|
||||
@@ -314,7 +317,7 @@ class Qwen4ExpDecoderLayer(nn.Module):
|
||||
|
||||
if self.layer_type == "linear_attention":
|
||||
attn_out = self.linear_attn(hidden_states=block_input)
|
||||
elif self.layer_type == "full_attention":
|
||||
elif self.layer_type in ATTENTION_LAYER_TYPES:
|
||||
attn_out = self.self_attn(
|
||||
hidden_states=block_input,
|
||||
positions=positions,
|
||||
@@ -394,8 +397,11 @@ class Qwen4ExpModel(nn.Module):
|
||||
self._qsa_layer_ids = frozenset(
|
||||
layer_idx
|
||||
for layer_idx, layer_type in enumerate(config.layer_types)
|
||||
if layer_type == "full_attention"
|
||||
and getattr(config, "indexer_n_heads", None) is not None
|
||||
if layer_type == QSA_LAYER_TYPE
|
||||
or (
|
||||
layer_type == "full_attention"
|
||||
and getattr(config, "indexer_n_heads", None) is not None
|
||||
)
|
||||
)
|
||||
self.embed_tokens = VocabParallelEmbedding(self.vocab_size, config.hidden_size)
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from typing import Any, Literal, TypeAlias
|
||||
|
||||
import huggingface_hub
|
||||
import torch
|
||||
import transformers.configuration_utils as hf_configuration_utils
|
||||
from huggingface_hub import constants
|
||||
from packaging.version import Version
|
||||
from safetensors.torch import _TYPES as _SAFETENSORS_TO_TORCH_DTYPE
|
||||
@@ -126,7 +127,6 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
|
||||
RefinedWebModel="RWConfig", # For tiiuae/falcon-7b(-instruct)
|
||||
mlp_speculator="MLPSpeculatorConfig",
|
||||
medusa="MedusaConfig",
|
||||
mellum="MellumConfig",
|
||||
midashenglm="MiDashengLMConfig",
|
||||
minimax_m3_vl="MiniMaxM3Config",
|
||||
minimax_m3_mtp="MiniMaxM3MTPConfig",
|
||||
@@ -151,7 +151,6 @@ _CONFIG_REGISTRY: dict[str, type[PretrainedConfig]] = LazyConfigDict(
|
||||
qwen3_5_text="Qwen3_5TextConfig",
|
||||
qwen3_5_moe="Qwen3_5MoeConfig",
|
||||
qwen3_5_moe_text="Qwen3_5MoeTextConfig",
|
||||
laguna="LagunaConfig",
|
||||
lfm2_moe="Lfm2MoeConfig",
|
||||
**{"unlimited-ocr": "UnlimitedOCRConfig"},
|
||||
**{"deepseek_v41": "DeepseekV41Config"},
|
||||
@@ -163,6 +162,12 @@ _SPECULATIVE_DECODING_CONFIGS: set[str] = {"eagle", "speculators", "medusa"}
|
||||
|
||||
_PATCH_HF_VALIDATE_ROPE: set[str] = {"sarvam_mla"}
|
||||
|
||||
# Model types whose checkpoints store shared RoPE parameters alongside the
|
||||
# per-layer-type dicts (e.g. Laguna's `original_max_position_embeddings`).
|
||||
# Since transformers 5.17, `validate_rope` treats every top-level value of such
|
||||
# a dict as a layer's parameters and raises on the shared ones.
|
||||
_PATCH_HF_NESTED_ROPE_VALIDATION: set[str] = {"laguna"}
|
||||
|
||||
# Model types whose checkpoints declare `layer_types` entries that upstream
|
||||
# transformers has not added to `ALLOWED_LAYER_TYPES` yet, so its strict config
|
||||
# validation rejects them (e.g. GLM-5.2 `glm_moe_dsa` use
|
||||
@@ -236,6 +241,11 @@ def _patch_hf_transformers_validate_rope():
|
||||
def patched_validate_rope(self, *args, **kwargs):
|
||||
ignore_keys_param = kwargs.pop("ignore_keys", None)
|
||||
original_ignore_keys = self.ignore_keys_at_rope_validation
|
||||
if ignore_keys_param is not None:
|
||||
logger.warning(
|
||||
"validate_rope() was called with the legacy 'ignore_keys' "
|
||||
"argument; use 'ignore_keys_at_rope_validation' instead"
|
||||
)
|
||||
self.ignore_keys_at_rope_validation = original_ignore_keys or ignore_keys_param
|
||||
result = _original_validate_rope(self, *args, **kwargs)
|
||||
return result
|
||||
@@ -244,6 +254,40 @@ def _patch_hf_transformers_validate_rope():
|
||||
PretrainedConfig.validate_rope = patched_validate_rope
|
||||
|
||||
|
||||
def _patch_hf_transformers_nested_rope_validation() -> None:
|
||||
"""Drop shared entries sitting alongside a nested ``rope_parameters`` dict.
|
||||
|
||||
Transformers validates a dict with any layer-type key by iterating all of
|
||||
its values, so a shared entry next to the per-layer dicts raises an
|
||||
``AttributeError``. The per-layer dicts already carry their own defaults by
|
||||
the time validation runs, so the shared entries can be dropped.
|
||||
"""
|
||||
if hasattr(PretrainedConfig.validate_rope, "__vllm_nested_rope_patched__"):
|
||||
return
|
||||
|
||||
_original_validate_rope = PretrainedConfig.validate_rope
|
||||
|
||||
@wraps(_original_validate_rope)
|
||||
def patched_validate_rope(self, *args, **kwargs):
|
||||
rope_parameters = getattr(self, "rope_parameters", None)
|
||||
if isinstance(rope_parameters, dict):
|
||||
layer_types = set(rope_parameters) & set(
|
||||
hf_configuration_utils.ALLOWED_LAYER_TYPES
|
||||
)
|
||||
if shared_keys := set(rope_parameters) - layer_types:
|
||||
for key in shared_keys:
|
||||
del rope_parameters[key]
|
||||
logger.warning(
|
||||
"Dropping %s from rope_parameters; entries shared across "
|
||||
"layer types are not supported",
|
||||
sorted(shared_keys),
|
||||
)
|
||||
return _original_validate_rope(self, *args, **kwargs)
|
||||
|
||||
patched_validate_rope.__vllm_nested_rope_patched__ = True # type: ignore[attr-defined]
|
||||
PretrainedConfig.validate_rope = patched_validate_rope
|
||||
|
||||
|
||||
def _patch_hf_transformers_allowed_layer_types(
|
||||
extra_layer_types: tuple[str, ...],
|
||||
) -> None:
|
||||
@@ -304,6 +348,9 @@ class HFConfigParser(ConfigParserBase):
|
||||
if model_type in _PATCH_HF_VALIDATE_ROPE:
|
||||
_patch_hf_transformers_validate_rope()
|
||||
|
||||
if model_type in _PATCH_HF_NESTED_ROPE_VALIDATION:
|
||||
_patch_hf_transformers_nested_rope_validation()
|
||||
|
||||
if extra_layer_types := _PATCH_HF_ALLOWED_LAYER_TYPES.get(model_type):
|
||||
_patch_hf_transformers_allowed_layer_types(extra_layer_types)
|
||||
|
||||
|
||||
@@ -55,10 +55,8 @@ _CLASS_TO_MODULE: dict[str, str] = {
|
||||
# tiiuae/falcon-7b(-instruct) models. Newer Falcon models will use the
|
||||
# `FalconConfig` class from the official HuggingFace transformers library.
|
||||
"RWConfig": "vllm.transformers_utils.configs.falcon",
|
||||
"LagunaConfig": "vllm.transformers_utils.configs.laguna",
|
||||
"Lfm2MoeConfig": "vllm.transformers_utils.configs.lfm2_moe",
|
||||
"MedusaConfig": "vllm.transformers_utils.configs.medusa",
|
||||
"MellumConfig": "vllm.transformers_utils.configs.mellum",
|
||||
"MiDashengLMConfig": "vllm.transformers_utils.configs.midashenglm",
|
||||
"MiniMaxM3Config": "vllm.transformers_utils.configs.minimax_m3",
|
||||
"MiniMaxM3MTPConfig": "vllm.transformers_utils.configs.minimax_m3",
|
||||
@@ -151,10 +149,8 @@ __all__ = [
|
||||
"HyperCLOVAXConfig",
|
||||
"IsaacConfig",
|
||||
"RWConfig",
|
||||
"LagunaConfig",
|
||||
"Lfm2MoeConfig",
|
||||
"MedusaConfig",
|
||||
"MellumConfig",
|
||||
"MiDashengLMConfig",
|
||||
"MiniMaxM3Config",
|
||||
"MiniMaxM3MTPConfig",
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
|
||||
from transformers.configuration_utils import PretrainedConfig
|
||||
|
||||
|
||||
class LagunaConfig(PretrainedConfig):
|
||||
model_type = "laguna"
|
||||
keys_to_ignore_at_inference = ["past_key_values"]
|
||||
base_model_tp_plan = {
|
||||
"layers.*.self_attn.q_proj": "colwise",
|
||||
"layers.*.self_attn.k_proj": "colwise",
|
||||
"layers.*.self_attn.v_proj": "colwise",
|
||||
"layers.*.self_attn.g_proj": "colwise",
|
||||
"layers.*.self_attn.o_proj": "rowwise",
|
||||
"layers.*.mlp.gate_proj": "colwise",
|
||||
"layers.*.mlp.up_proj": "colwise",
|
||||
"layers.*.mlp.down_proj": "rowwise",
|
||||
}
|
||||
base_model_pp_plan = {
|
||||
"embed_tokens": (["input_ids"], ["inputs_embeds"]),
|
||||
"layers": (["hidden_states", "attention_mask"], ["hidden_states"]),
|
||||
"norm": (["hidden_states"], ["hidden_states"]),
|
||||
}
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
vocab_size: int = 100352,
|
||||
hidden_size: int = 2048,
|
||||
intermediate_size: int = 8192,
|
||||
num_hidden_layers: int = 40,
|
||||
num_attention_heads: int = 48,
|
||||
num_key_value_heads: int = 8,
|
||||
head_dim: int = 128,
|
||||
qkv_bias: bool = False,
|
||||
attention_bias: bool = False,
|
||||
gating: bool | str = True,
|
||||
hidden_act: str = "silu",
|
||||
max_position_embeddings: int = 131072,
|
||||
initializer_range: float = 0.02,
|
||||
rms_norm_eps: float = 1e-6,
|
||||
use_cache: bool = True,
|
||||
tie_word_embeddings: bool = False,
|
||||
rope_theta: float = 500000.0,
|
||||
rope_scaling: dict | None = None,
|
||||
rope_parameters: dict | None = None,
|
||||
partial_rotary_factor: float = 1.0,
|
||||
attention_dropout: float = 0.0,
|
||||
sliding_window: int | None = None,
|
||||
layer_types: list[str] | None = None,
|
||||
swa_attention_sink_enabled: bool = False,
|
||||
swa_rope_parameters: dict | None = None,
|
||||
num_attention_heads_per_layer: list[int] | None = None,
|
||||
num_experts: int = 256,
|
||||
num_experts_per_tok: int = 8,
|
||||
moe_intermediate_size: int = 512,
|
||||
shared_expert_intermediate_size: int = 512,
|
||||
norm_topk_prob: bool = True,
|
||||
decoder_sparse_step: int = 1,
|
||||
mlp_only_layers: list[int] | None = None,
|
||||
router_aux_loss_coef: float = 0.001,
|
||||
output_router_logits: bool = False,
|
||||
moe_routed_scaling_factor: float = 1.0,
|
||||
moe_apply_router_weight_on_input: bool = False,
|
||||
**kwargs,
|
||||
):
|
||||
if mlp_only_layers is None:
|
||||
mlp_only_layers = [0]
|
||||
|
||||
# Accept either v4-style (rope_theta + rope_scaling) or v5-style
|
||||
# (rope_parameters). Translate v5 → v4 so downstream code has one path.
|
||||
if rope_parameters is not None:
|
||||
rp = dict(rope_parameters)
|
||||
rope_theta = float(rp.pop("rope_theta", rope_theta))
|
||||
rt = rp.pop("rope_type", None)
|
||||
if rt is not None and rt != "default":
|
||||
rope_scaling = {"rope_type": rt, **rp}
|
||||
elif rp and rope_scaling is None:
|
||||
rope_scaling = {"rope_type": "default", **rp}
|
||||
|
||||
self.vocab_size = vocab_size
|
||||
self.hidden_size = hidden_size
|
||||
self.intermediate_size = intermediate_size
|
||||
self.num_hidden_layers = num_hidden_layers
|
||||
self.num_attention_heads = num_attention_heads
|
||||
self.num_key_value_heads = num_key_value_heads
|
||||
self.head_dim = head_dim
|
||||
self.qkv_bias = qkv_bias
|
||||
self.attention_bias = attention_bias
|
||||
self.gating = gating
|
||||
self.hidden_act = hidden_act
|
||||
self.max_position_embeddings = max_position_embeddings
|
||||
self.initializer_range = initializer_range
|
||||
self.rms_norm_eps = rms_norm_eps
|
||||
self.use_cache = use_cache
|
||||
self.rope_theta = rope_theta
|
||||
self.rope_scaling = rope_scaling
|
||||
self.partial_rotary_factor = partial_rotary_factor
|
||||
self.attention_dropout = attention_dropout
|
||||
self.sliding_window = sliding_window
|
||||
self.layer_types = layer_types
|
||||
self.swa_attention_sink_enabled = swa_attention_sink_enabled
|
||||
self.swa_rope_parameters = swa_rope_parameters
|
||||
self.num_attention_heads_per_layer = num_attention_heads_per_layer
|
||||
self.num_experts = num_experts
|
||||
self.num_experts_per_tok = num_experts_per_tok
|
||||
self.moe_intermediate_size = moe_intermediate_size
|
||||
self.shared_expert_intermediate_size = shared_expert_intermediate_size
|
||||
self.norm_topk_prob = norm_topk_prob
|
||||
self.decoder_sparse_step = decoder_sparse_step
|
||||
self.mlp_only_layers = mlp_only_layers
|
||||
self.router_aux_loss_coef = router_aux_loss_coef
|
||||
self.output_router_logits = output_router_logits
|
||||
self.moe_routed_scaling_factor = moe_routed_scaling_factor
|
||||
self.moe_apply_router_weight_on_input = moe_apply_router_weight_on_input
|
||||
|
||||
super().__init__(tie_word_embeddings=tie_word_embeddings, **kwargs)
|
||||
|
||||
|
||||
__all__ = ["LagunaConfig"]
|
||||
@@ -1,7 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
from transformers import Qwen3MoeConfig
|
||||
|
||||
|
||||
class MellumConfig(Qwen3MoeConfig):
|
||||
model_type = "mellum"
|
||||
Reference in New Issue
Block a user