MCPcopy Create free account
hub / github.com/apple/axlearn / input_partition_spec

Function input_partition_spec

axlearn/common/utils.py:743–755  ·  view source on GitHub ↗

Returns partition spec for the input batch. We partition the inputs along all axes. For example, if the mesh has shape (64, 4) and axis names of ("data", "model"), the partition spec will be (("data", "model"), None...) so that the batch axis of every global tensor will be partitioned 2

()

Source from the content-addressed store, hash-verified

741 def _promote(orig, filtered):
742 # `orig` is the user's dim; `filtered` is `manual_axes_to_none`'s result. A `None`
743 # in `filtered` only becomes UNCONSTRAINED if it came from a Manual axis (or a
744 # tuple of Manual axes) in `orig` — explicit `None` (replicate) must pass through.
745 if filtered is not None:
746 return filtered
747 if isinstance(orig, str):
748 return PartitionSpec.UNCONSTRAINED if orig in manual_axes else None
749 if isinstance(orig, tuple):
750 return PartitionSpec.UNCONSTRAINED if all(a in manual_axes for a in orig) else None
751 return None
752
753 filtered = manual_axes_to_none(spec)
754 return PartitionSpec(*(_promote(o, f) for o, f in zip(spec, filtered)))
755
756
757def get_current_abstract_or_physical_mesh() -> jax.sharding.AbstractMesh | jax.sharding.Mesh:
758 """Returns the current abstract mesh if it's set, or the physical mesh otherwise."""

Callers 6

partition_specMethod · 0.90
__init__Method · 0.90
partition_specMethod · 0.90

Calls

no outgoing calls

Tested by 1