From dd2a94596abe43eb0e556cde306fc80d442183c0 Mon Sep 17 00:00:00 2001 From: inkcherry Date: Thu, 15 May 2025 13:29:38 +0800 Subject: [PATCH] [Model] Allow the use of sliding window in Qwen2 (#17772) Signed-off-by: inkcherry --- vllm/model_executor/models/qwen2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/vllm/model_executor/models/qwen2.py b/vllm/model_executor/models/qwen2.py index 108d002e601b9..0d0d98c59dbc7 100644 --- a/vllm/model_executor/models/qwen2.py +++ b/vllm/model_executor/models/qwen2.py @@ -291,14 +291,14 @@ class Qwen2Model(nn.Module): # TODO (@robertgshaw2): see if this can be moved out if (cache_config.sliding_window is not None and hasattr(config, "max_window_layers")): - raise ValueError("Sliding window for some but all layers is not " - "supported. This model uses sliding window " - "but `max_window_layers` = {} is less than " - "`num_hidden_layers` = {}. Please open an issue " - "to discuss this feature.".format( - config.max_window_layers, - config.num_hidden_layers, - )) + assert config.max_window_layers == config.num_hidden_layers, ( + "Sliding window for some but all layers is not supported. " + "This model uses sliding window but `max_window_layers` = {} " + "is less than `num_hidden_layers` = {}. Please open an issue " + "to discuss this feature.".format( + config.max_window_layers, + config.num_hidden_layers, + )) self.config = config self.quant_config = quant_config