transformers
7cabd3e8 - [tests] Build output equivalence diagnostics only on failure (optimization) (#51174)

Commit
1 day ago
[tests] Build output equivalence diagnostics only on failure (optimization) (#51174) * test: build output equivalence diagnostics only on failure Avoid running tensor operations and formatting full outputs when the comparison passes, in the common test and in model overrides. Use a message callable for DAB-DETR and remove its debug print. On one v6e chip with torch-tpu 0.2.0 and RUN_SLOW=1, the ViT folder went from 1123 s to 52 s, BERT from 166 s to 91 s, and GPT-2 from 275 s to 141 s. The DAB-DETR equivalence test went from 330 s to 10 s after removing the debug print. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> * test: use assert_close in the output equivalence tests Replace `if not torch.allclose(...): self.fail(...)` with `torch.testing.assert_close`, keeping rtol=1e-5 and atol=1e-5. Its default message (mismatch count, max abs/rel diff and index) is built only on failure; a callable msg adds context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Mythos 5.2 <noreply@anthropic.com>
Author
Parents
Loading