Skip to content

Commit dd1957f

Browse files
judyzhaoxinwucamiloCienet
authored andcommitted
Add the axis_types as Auto for the test_qkvo_partition_spec unit test
1 parent f7bbf14 commit dd1957f

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

axlearn/common/attention_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2651,7 +2651,15 @@ def test_qkvo_partition_spec(self, kv_part):
26512651
self.skipTest(f"Unsupported mesh shape {mesh_shape}")
26522652
model_dim = 16
26532653
num_heads = 4
2654-
mesh = jax.make_mesh(mesh_shape, axis_names=("fsdp", "seq", "model"))
2654+
mesh = jax.make_mesh(
2655+
mesh_shape,
2656+
axis_names=("fsdp", "seq", "model"),
2657+
axis_types=(
2658+
jax.sharding.AxisType.Auto,
2659+
jax.sharding.AxisType.Auto,
2660+
jax.sharding.AxisType.Auto,
2661+
),
2662+
)
26552663
q_part = ("fsdp", "seq", "model", None)
26562664
o_part = ("fsdp", "seq", None)
26572665

axlearn/common/utils.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,14 +637,7 @@ def with_sharding_constraint(x: Tensor, shardings):
637637
mesh = thread_resources.env.physical_mesh
638638
if mesh.empty or mesh.size == 1:
639639
return x
640-
try:
641-
return jax.lax.with_sharding_constraint(x, shardings)
642-
except ValueError as e:
643-
logging.warning("with_sharding_constraint failed: %s. Try to re-shard.", e)
644-
if "reshard" in str(e) or "Explicit" in str(e):
645-
named_sharding = jax.sharding.NamedSharding(mesh, shardings)
646-
return jax.lax.reshard(x, named_sharding)
647-
raise e
640+
return jax.lax.with_sharding_constraint(x, shardings)
648641

649642

650643
def maybe_shard(x: NestedTensor, partition_spec: Optional[PartitionSpec]) -> NestedTensor:

0 commit comments

Comments
 (0)