[Test] [AMD] diffusion: Avoid Python 3.11-only enterContext in test_usp_ring_replicated (#45409)

This commit is contained in:
Michael
2026-10-22 00:11:08 +08:00
committed by GitHub
parent 75878f27c8
commit 4b1a44bc77
@@ -50,12 +50,13 @@ class RingReplicatedBase(unittest.TestCase):
B, S_SHARD, REP, H, D = 1, 6, 3, 2, 8
def setUp(self):
self.enterContext(
patch(
f"{_LAYER}._usp_input_all_to_all_qkv",
side_effect=lambda q, k, v: (q, k, v),
)
# start() + addCleanup rather than enterContext, which is 3.11+.
patcher = patch(
f"{_LAYER}._usp_input_all_to_all_qkv",
side_effect=lambda q, k, v: (q, k, v),
)
patcher.start()
self.addCleanup(patcher.stop)
def _attn(self):
obj = USPAttention.__new__(USPAttention)