Repository navigation
[Triton/Gluon] [Test] Stop test_extend_attention from changing the default dtype of later tests - #6747
Conversation
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: |
There was a problem hiding this comment.
🟢 Approval recommended
The scoped fixture restores test state, and no blocking issues were found.
No open issues 🎉
What changed in this PR
This PR prevents extend-attention tests from leaking PyTorch defaults into later tests.
Changes:
- Add an automatic fixture to save and restore the default dtype and device after each test, including failures.
- Leave kernel behavior unchanged.
| File | Description |
|---|---|
op_tests/triton_tests/attention/test_extend_attention.py |
Add cleanup for PyTorch default state. |
Review effort: Balanced

Motivation
op_tests/triton_tests/fusions/test_mhc_fused_post_pre_delayed_rmsnorm.pyfails (13 tests) when it runs afterop_tests/triton_tests/attention/test_extend_attention.pyin the same pytest process. This happened in Triton Tests (MI35X) shard 4 of #6679.test_op_fwdcallstorch.set_default_dtype(dtype)andtorch.set_default_device(device), and it does not restore them. After a bfloat16 case,make_inputsof the mHC test createsfnin bfloat16, and the wrapper assertfn.dtype == torch.float32fails (mhc_fused_post_pre_delayed_rmsnorm.py:69).Technical details
test_extend_attention.py:test_op_fwdresets the default dtype totorch.float32and the default device toNoneat its end, before its finalassert_close, so the tests after it get the torch defaults.Test plan
On a gfx1250 GPU:
test_extend_attention.py::test_op_fwd, thentest_mhc_fused_post_pre_delayed_rmsnorm.py, in one pytest process, on main and on this branch.Test results
AssertionErroratmhc_fused_post_pre_delayed_rmsnorm.py:69, the same as in CI.