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

Function replicate_to_local_data

axlearn/common/utils.py:658–667  ·  view source on GitHub ↗

Replicates and converts Tensors in `x` to local DeviceArrays. Args: x: The tensor to replicate. Returns: Replicated tensor.

(x: NestedTensor)

Source from the content-addressed store, hash-verified

656) -> NestedTensor:
657 """Best-effort activation sharding hint: shards `x` by `partition_spec` if non-None.
658
659 Manual axes (from an enclosing `shard_map`) in `partition_spec` are downgraded to
660 `PartitionSpec.UNCONSTRAINED`; still-Auto axes apply as usual. Activation sharding is a
661 hint XLA can override anyway, so silently dropping the Manual portion is safe. For
662 parameters / state where a wrong axis is a real bug, use `with_sharding_constraint`.
663 For `shard_map` `in_specs`/`out_specs` (which reject `UNCONSTRAINED`), use
664 `manual_axes_to_none`.
665
666 When all mesh axes are Manual (no Auto axes remain), `with_sharding_constraint` is
667 skipped entirely — there's nothing left for the compiler to constrain, and the call
668 would be a no-op wrapper at best (see `_manual_axes_to_unconstrained`).
669
670 `partition_spec` may be a `PartitionSpec` or a flat sequence of axis entries (wrapped

Callers 15

_update_coco_metricMethod · 0.90
forwardMethod · 0.90
test_dispatch_tpuMethod · 0.90
test_one_per_deviceMethod · 0.90
test_one_per_processMethod · 0.90
get_summariesMethod · 0.90

Calls

no outgoing calls