IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python module

max.experimental.sharding.per_shard_dim

Per-shard Dim wrapper carrying one value per device.

A PerShardDim bundles one Dim per mesh shard (device index along a Sharded mesh axis). Arithmetic distributes element-wise. make_per_shard_dim() collapses to a plain Dim when every cell is equal. Wrappers must never reach MLIR; they are projected per shard by shape rules before any Dim.to_mlir() call.

Per-shard dimensions​

PerShardDimA Dim whose per_shard tuple lists one cell per mesh shard.
global_dimFolds a PerShardDim into a single global Dim.
global_shapeReturns the global shape by summing every PerShardDim axis.
is_per_shard_dimTrue if d is a PerShardDim.
is_staticTrue if d's global extent is a static (compile-time) size.
is_symbolicTrue if d's global extent is a symbolic (named) dim.
local_dim_atReturns the dimension value at shard.
local_shape_atProjects every axis of shape onto a single shard index.
make_per_shard_dimWraps per_shard in a PerShardDim, or collapses to a plain Dim.