transformers
f66c64ba - Keep the engine's masks as a dict on hybrid models

Commit
15 days ago
Keep the engine's masks as a dict on hybrid models A model with one attention type besides its linear attention layers has a single entry in cumulative_seqlens_k, so the masks were collapsed to the last entry of the dict, which is the linear layers' None. Under sdpa, the attention layers of Qwen3-Next and Qwen3.5 then built their own mask from the new tokens alone: none at all on a packed batch, so they attended across sequences and to later tokens. The tiny model's greedy parity did not see it. The masks are now collapsed only when the cache has a single allocator, and a test checks the attention layers get the engine's mask over all the keys they read; it fails without this change.
Author
Parents
Loading