transformers
2109f443 - Shape cross-attention keys and values by the states they come from

Commit
1 day ago
Shape cross-attention keys and values by the states they come from `hidden_shape` is built from the query's sequence length. Reusing it to `view` the key and value projections of `encoder_hidden_states` infers a head count from the wrong length, so cross-attention dies in the attention matmul as soon as the two lengths differ: q_len=4, kv_len=7 -> RuntimeError: The size of tensor a (4) must match the size of tensor b (7) at non-singleton dimension 1 esm, megatron_bert and tapas all reproduce it; lightglue matches keypoints between two images, so its cross-attention lengths differ by construction. Every suite stayed green because they only ever pass encoder states as long as the query. Each site now derives `kv_shape` from `current_states`, the spelling bigbird_pegasus, nllb_moe, marian and kosmos2_5 already use. When the lengths agree `kv_shape` is identical to `hidden_shape`, so the equal-length path is untouched. evolla is regenerated: its SaProt attention inherits `EsmSelfAttention`.
Author
Committer
Parents
Loading