@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 5ce2d10e4a
Fork 0

A high-throughput and memory-efficient inference and serving engine for LLMs

Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git

Synced Nov 6, 12:00 UTC

Fix models which use `layer_type_validation` for Transformers v5 (#37398)

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>

Harry Mellor committed Mar 18, 2026 at 18:41 UTC 5ce2d10e4a6954802f482add02b04e23e737ad27
4 files changed +45 -16
vllm/transformers_utils/configs/olmo_hybrid.py
+10 -2
@@ -2,7 +2,7 @@
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4
5 -from transformers.configuration_utils import PretrainedConfig, layer_type_validation
5 +from transformers.configuration_utils import PretrainedConfig
6
7
8 class OlmoHybridConfig(PretrainedConfig):
@@ -228,7 +228,15 @@ class OlmoHybridConfig(PretrainedConfig):
228 if "full_attention" not in layer_types:
229 layer_types[-1] = "full_attention"
230
231 - layer_type_validation(layer_types, num_hidden_layers)
231 + if hasattr(self, "validate_layer_type"):
232 + # Transformers v5
233 + self.layer_types = layer_types
234 + self.validate_layer_type()
235 + else:
236 + # Transformers v4
237 + from transformers.configuration_utils import layer_type_validation
238 +
239 + layer_type_validation(layer_types, num_hidden_layers)
240 if "linear_attention" not in layer_types:
241 raise ValueError(
242 "OLMoHybrid expects at least one 'linear_attention' layer."
vllm/transformers_utils/configs/qwen3_5.py
+13 -6
@@ -16,7 +16,7 @@
16 # limitations under the License.
17 """Qwen3.5 model configuration"""
18
19 -from transformers.configuration_utils import PretrainedConfig, layer_type_validation
19 +from transformers.configuration_utils import PretrainedConfig
20
21
22 class Qwen3_5TextConfig(PretrainedConfig):
@@ -68,10 +68,6 @@ class Qwen3_5TextConfig(PretrainedConfig):
68 eos_token_id=None,
69 **kwargs,
70 ):
71 - kwargs["ignore_keys_at_rope_validation"] = [
72 - "mrope_section",
73 - "mrope_interleaved",
74 - ]
71 self.vocab_size = vocab_size
72 self.max_position_embeddings = max_position_embeddings
73 self.hidden_size = hidden_size
@@ -98,7 +94,18 @@ class Qwen3_5TextConfig(PretrainedConfig):
94 else "full_attention"
95 for i in range(self.num_hidden_layers)
96 ]
101 - layer_type_validation(self.layer_types, self.num_hidden_layers)
97 + if hasattr(self, "validate_layer_type"):
98 + # Transformers v5
99 + kwargs["ignore_keys_at_rope_validation"] = {
100 + "mrope_section",
101 + "mrope_interleaved",
102 + }
103 + self.validate_layer_type()
104 + else:
105 + # Transformers v4
106 + from transformers.configuration_utils import layer_type_validation
107 +
108 + layer_type_validation(self.layer_types, self.num_hidden_layers)
109
110 # linear attention part
111 self.linear_conv_kernel_dim = linear_conv_kernel_dim
vllm/transformers_utils/configs/qwen3_5_moe.py
+13 -6
@@ -16,7 +16,7 @@
16 # limitations under the License.
17 """Qwen3.5-MoE model configuration"""
18
19 -from transformers.configuration_utils import PretrainedConfig, layer_type_validation
19 +from transformers.configuration_utils import PretrainedConfig
20
21
22 class Qwen3_5MoeTextConfig(PretrainedConfig):
@@ -75,10 +75,6 @@ class Qwen3_5MoeTextConfig(PretrainedConfig):
75 eos_token_id=None,
76 **kwargs,
77 ):
78 - kwargs["ignore_keys_at_rope_validation"] = [
79 - "mrope_section",
80 - "mrope_interleaved",
81 - ]
78 self.vocab_size = vocab_size
79 self.max_position_embeddings = max_position_embeddings
80 self.hidden_size = hidden_size
@@ -104,7 +100,18 @@ class Qwen3_5MoeTextConfig(PretrainedConfig):
100 else "full_attention"
101 for i in range(self.num_hidden_layers)
102 ]
107 - layer_type_validation(self.layer_types, self.num_hidden_layers)
103 + if hasattr(self, "validate_layer_type"):
104 + # Transformers v5
105 + kwargs["ignore_keys_at_rope_validation"] = {
106 + "mrope_section",
107 + "mrope_interleaved",
108 + }
109 + self.validate_layer_type()
110 + else:
111 + # Transformers v4
112 + from transformers.configuration_utils import layer_type_validation
113 +
114 + layer_type_validation(self.layer_types, self.num_hidden_layers)
115
116 # linear attention part
117 self.linear_conv_kernel_dim = linear_conv_kernel_dim
vllm/transformers_utils/configs/qwen3_next.py
+9 -2
@@ -16,7 +16,7 @@
16 # limitations under the License.
17 """Qwen3-Next model configuration"""
18
19 -from transformers.configuration_utils import PretrainedConfig, layer_type_validation
19 +from transformers.configuration_utils import PretrainedConfig
20 from transformers.utils import logging
21
22 logger = logging.get_logger(__name__)
@@ -253,7 +253,14 @@ class Qwen3NextConfig(PretrainedConfig):
253 "linear_attention" if bool((i + 1) % 4) else "full_attention"
254 for i in range(self.num_hidden_layers)
255 ]
256 - layer_type_validation(self.layer_types)
256 + if hasattr(self, "validate_layer_type"):
257 + # Transformers v5
258 + self.validate_layer_type()
259 + else:
260 + # Transformers v4
261 + from transformers.configuration_utils import layer_type_validation
262 +
263 + layer_type_validation(self.layer_types)
264
265 # linear attention part
266 self.linear_conv_kernel_dim = linear_conv_kernel_dim