transformers
617e752d - Fix GraniteMoeHybrid _update_mamba_mask crash on attention-only models (#45514)

Commit
222 days ago
Fix GraniteMoeHybrid _update_mamba_mask crash on attention-only models (#45514) * Fix GraniteMoeHybrid _update_mamba_mask crash on attention-only models When all layers are attention layers (no mamba layers), _update_mamba_mask calls past_key_values.has_previous_state() which tries to find a LinearAttentionCacheLayerMixin layer. Since none exist, it raises ValueError. Skip the has_previous_state check entirely when the model has no mamba layers, as the mamba mask optimization is irrelevant in that case. Fixes #45507 * Move mamba layer guard to forward() caller per review feedback Instead of guarding inside _update_mamba_mask, skip the call entirely in forward() when no mamba layers exist. This keeps _update_mamba_mask focused on its original responsibility and avoids calling it on attention-only models altogether. Signed-off-by: root <root@hk760245497450.local> * Add fast test for attention-only model forward pass Verifies that GraniteMoeHybrid models with all attention layers (no mamba layers) can run forward without crashing. Regression test for #45507. Signed-off-by: root <root@hk760245497450.local> * fixup closer to hybrid attentions --------- Signed-off-by: root <root@hk760245497450.local> Co-authored-by: root <root@hk760245497450.local> Co-authored-by: vasqu <antonprogamer@gmail.com>
Author
Parents
Loading