Skip to content

Commit ce970ba

Browse files
committed
Optimized the test cases
1 parent 2acf0cd commit ce970ba

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

python/test/tle/unit/test_tle_distributed.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,12 @@ def __init__(self):
228228

229229
class TestShardId:
230230

231-
def test_node_axis_requires_device_dptr(self):
231+
@pytest.mark.parametrize("axis", ("device", "node"))
232+
def test_rank_axis_requires_device_dptr(self, axis):
232233
mesh = tle.device_mesh({"node": 2, "device": 4})
233234
semantic = _FakeSemantic()
234-
with pytest.raises(ValueError, match="device_dptr is required for axis 'node'"):
235-
tle.shard_id(mesh, "node", _semantic=semantic)
235+
with pytest.raises(ValueError, match=rf"device_dptr is required for axis '{axis}'"):
236+
tle.shard_id(mesh, axis, _semantic=semantic)
236237

237238

238239
class TestDistributedBarrierScope:

python/triton/experimental/tle/language/distributed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def shard_id(
656656
mesh = tl._unwrap_if_constexpr(mesh)
657657
axis = tl._unwrap_if_constexpr(axis)
658658

659-
if axis == "node" and device_dptr is None:
659+
if axis in ("device", "node") and device_dptr is None:
660660
raise ValueError(f"device_dptr is required for axis {axis!r}")
661661

662662
if axis == "device":

0 commit comments

Comments
 (0)