Transformers bug let UMT5's decoder see future tokens; fix is in v5.18.0
A Transformers regression in v5.15.0 to v5.17.0, per the bug report, could skew UMT5 training loss and evaluation scores. Generation was unaffected, the fix's author says.

Hugging Face's Transformers library shipped a regression in which UMT5's decoder could see tokens it was meant to predict, according to a Hugging Face blog post published on 3 November 2026 and the GitHub issue and pull request behind the fix. The bug report lists v5.15.0, v5.16.0 and v5.17.0 as affected; the fix was merged on 28 September and appears in the v5.18.0 release notes.
What went wrong
The blog post says that on 30 July 2026 Transformers enabled PyTorch's scaled dot-product attention (SDPA) for T5, and "As a side effect, UMT5's decoder could attend to future tokens." It adds: "During training, it could peek at the answer it was supposed to predict." and "Nothing crashed, and the bug stayed in main for almost two months."
The fix pull request (#49135) gives the mechanics. UMT5's decoder self-attention was built without its causal flag, and under SDPA the causal mask is skipped when there is no padding, so nothing stopped each position attending to later ones. The PR says T5 and MT5 pass the flag and "UMT5 is the only member of the family missing it".
Who is affected
According to the PR, generation is not: "generate() is unaffected". It says "Only full-sequence teacher forcing is affected, i.e. training loss, evaluation perplexity and offline scoring." The bug report (#49134) puts it more strongly, saying those numbers "are silently wrong".
Two conditions narrow it, per the issue and PR:
- Attention path. The PR says
v5.14.1"is correct (eager, mask materialised)". The blog notes its test "used SDPA, the default attention path" and that "Running only the eager attention variant missed the bug." - Padding. The issue says "A ragged batch is computed correctly and a uniform-length batch is not." The PR adds that
DataCollatorForSeq2Seqemits no decoder attention mask, so "the defaultSeq2SeqTrainerpath was in the leaking case."
Which versions
- Introduced: PR #47014, merged on 30 July 2026, first shipped in v5.15.0 (released 10 August), whose notes say T5 and its family "now support SDPA".
- Affected, per the issue: v5.15.0, v5.16.0, v5.17.0 and
main. The PR says "v5.15.0onward is not" correct. - Patch releases: on our check of GitHub's commit comparison, v5.15.1 and v5.16.1 also contain the introducing commit and not the fix. The issue does not list them.
- Fixed: PR #49135, merged on 28 September 2026, listed in the v5.18.0 release notes (released 30 September). The PR says the patched values match
v5.14.1, "so this restores previous behaviour rather than changing it."
What to do
Neither the blog, the issue nor the release notes give upgrade or re-evaluation advice. On our reading, anyone who trained, fine-tuned, evaluated or scored UMT5 models with Transformers v5.15.0 to v5.17.0 (or a main build from that window) using SDPA should move to v5.18.0 or later and treat loss, perplexity and scoring numbers from that period as suspect, especially for batches without padding. The issue's reproducer checks whether the decoder's position-0 output changes as tokens are appended after it.
Model Integration Contracts
A Model Integration Contract (MIC), it says, "has three parts": a fixture (a shrunk model built from a real checkpoint's configuration), a usage path (a runnable example such as generating text or a training step) and baselines reviewed by a human. "The contract holds if running the usage path on the fixture still produces the baselines."
Replaying commits, Hugging Face says its small UMT5 fixture flagged the regression from introduction to fix: "Label log-probabilities differed from the reviewed baseline by 1.22 and training loss by about 0.20." For new models an LLM drafts the usage code, but in the post's words "The LLM drafts; it doesn't approve." As of 1 November 2026 the MIC job "reports failures without blocking PRs".
Why it matters
The issue describes the bug as invisible to generation-based tests, because generated output looked correct. On our reading, results from teacher-forced UMT5 training and evaluation on the affected versions may need re-running, and the case shows why Hugging Face is proposing checks that go beyond a forward pass.
- Hugging Face blog: Transformers Model Integration Contracts
- GitHub issue #49134: UMT5 decoder self-attention is not causal
- GitHub PR #49135: Fix UMT5 decoder self-attention not being causal
- GitHub PR #47014: Enable SDPA for T5 and the T5 family
- Transformers v5.18.0 release notes
- Transformers v5.15.0 release notes
Ask Relay — he reads every question himself and replies personally by email.
