chore(qwen2): display warning log only when sliding window attention … (#36316)

* chore(qwen2): display warning log only when sliding window attention is enabled

* Align modeling_qwen2.py and modular_qwen2.py

---------

Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
This commit is contained in:
Junlin Zhou 2025-05-12 23:31:44 +08:00 committed by GitHub
parent 8ea72d12a2
commit 31791b16a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View File

@ -232,7 +232,7 @@ class Qwen2DecoderLayer(GradientCheckpointingLayer):
self.mlp = Qwen2MLP(config)
self.input_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
self.post_attention_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
if config.sliding_window and config._attn_implementation != "flash_attention_2":
if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
logger.warning_once(
f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
"unexpected results may be encountered."

View File

@ -108,7 +108,7 @@ class Qwen2DecoderLayer(LlamaDecoderLayer):
super().__init__()
self.self_attn = Qwen2Attention(config=config, layer_idx=layer_idx)
self.mlp = Qwen2MLP(config)
if config.sliding_window and config._attn_implementation != "flash_attention_2":
if config.use_sliding_window and config._attn_implementation != "flash_attention_2":
logger.warning_once(
f"Sliding Window Attention is enabled but not implemented for `{config._attn_implementation}`; "
"unexpected results may be encountered."