[Model] Allow the use of sliding window in Qwen2 (#17772)

Signed-off-by: inkcherry <mingzhi.liu@intel.com>
This commit is contained in:
inkcherry 2025-05-15 13:29:38 +08:00 committed by GitHub
parent 420caf7557
commit dd2a94596a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -291,14 +291,14 @@ class Qwen2Model(nn.Module):
# TODO (@robertgshaw2): see if this can be moved out # TODO (@robertgshaw2): see if this can be moved out
if (cache_config.sliding_window is not None if (cache_config.sliding_window is not None
and hasattr(config, "max_window_layers")): and hasattr(config, "max_window_layers")):
raise ValueError("Sliding window for some but all layers is not " assert config.max_window_layers == config.num_hidden_layers, (
"supported. This model uses sliding window " "Sliding window for some but all layers is not supported. "
"but `max_window_layers` = {} is less than " "This model uses sliding window but `max_window_layers` = {} "
"`num_hidden_layers` = {}. Please open an issue " "is less than `num_hidden_layers` = {}. Please open an issue "
"to discuss this feature.".format( "to discuss this feature.".format(
config.max_window_layers, config.max_window_layers,
config.num_hidden_layers, config.num_hidden_layers,
)) ))
self.config = config self.config = config
self.quant_config = quant_config self.quant_config = quant_config