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 class

NamedMapping

NamedMapping​

class max.tensor.sharding.NamedMapping(mesh=None, spec=(), *, unreduced=())

source

Bases: DeviceMapping

Builds a DeviceMapping from a JAX-style named spec.

Each spec entry corresponds to a tensor dim and names the mesh axis that shards it (or None for replicated). Mesh-axis names not present on the target mesh resolve to Replicated. unreduced names mesh axes carrying a pending reduction; each becomes a Partial placement.

The resolved placements are stored on the instance, so it behaves as a regular DeviceMapping. It also keeps the original spec, which _resolve uses to rebuild the mapping on another mesh.

Parameters:

  • mesh (DeviceMesh) – The target device mesh, or None to take the one set by default_device().
  • spec (tuple[SpecEntry, ...]) – One entry per tensor dimension.
  • unreduced (Iterable[str]) – Mesh axes carrying pending reductions.

Raises:

  • ValueError – If mesh is None and no default_device() is active, leaving the spec with nothing to resolve against.
  • ConversionError – If one mesh axis is named for more than one tensor dimension, or if an axis appears in both spec and unreduced.