Repository navigation
Conversation
When attention_mask is missing, OPT used to replace it with an all-ones tensor before building the causal mask. Under torch.compile that explicit mask stops SDPA from using is_causal=True and falls back to slower kernels. Use the ones mask only for learned position ids, and pass the original attention_mask into create_causal_mask. Fixes huggingface#48924 Signed-off-by: GokayAI <60583610+gokay-ai@users.noreply.github.com>
|
[For maintainers] Suggested jobs to run (before merge) run-slow: opt |
CI recapDashboard: View test results in Grafana |
|
|
|
Good question — in eager mode you’re right that an all-ones 2D mask and The difference shows up under This PR only fabricates the all-ones tensor for OPT’s learned position ids; the causal-mask call keeps |
|
Correction on my earlier note: under Closing this — thanks for the catch. If #48924 still shows a real compile regression, the fix likely belongs in the shared mask/SDPA skip logic rather than OPT alone. |
Fixes #48924
OPT was filling an all-ones
attention_maskfor learned position ids, then passing that same tensor intocreate_causal_mask. Undertorch.compile, SDPA then gets an explicit mask instead ofis_causal=Trueand falls back to slower kernels.The ones mask is only used for position ids now.
create_causal_maskstill seesattention_mask is None.Before submitting
Who can review?
Text models / attention: @ArthurZucker @Cyrilvallez @vasqu