Don't use default attn if pre-set in sub-config (#38526)

* don't use default attn if pre-set in sib-config

* style

* add a test maybe
This commit is contained in:
Raushan Turganbay
2025-06-03 09:53:07 +02:00
committed by GitHub
parent bf68dd9e6e
commit 55ec319de6
2 changed files with 14 additions and 2 deletions

View File

@@ -3425,6 +3425,13 @@ class ModelTesterMixin:
f"The eager model should not have SDPA/FA2 attention layers but got `{class_name}.config._attn_implementation={submodule.config._attn_implementation}`"
)
# Set the attention to default `None` but the text config to `eager`
# The model should load encoders in SDPA but not the text attention
config._attn_implementation = None
config.get_text_config(decoder=True)._attn_implementation = "eager"
model = model_class(config)
self.assertTrue(model.config.get_text_config(decoder=True)._attn_implementation == "eager")
@require_torch_sdpa
def test_sdpa_can_dispatch_non_composite_models(self):
"""