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.tensor.sharding.per_shard_dim

Wraps one Dim per device, so a dimension can vary by shard.

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 its first cell when every cell is equal, no global_dim is attached, and force_wrap is false. Shape rules project each wrapper per shard before any Dim.to_mlir() call, so a wrapper never reaches the MLIR graph.

Per-shard dimensions​

PerShardDimA Dim listing 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.