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 package

max.tensor

Distributed tensors and the eager runtime that realizes them.

Tensor is the user-facing value type. Ops on tensors live in max.functional; placements and the device mesh live in max.tensor.sharding; ahead-of-time compilation of tensor programs lives in max.tensor.compilation.

The following example calls Tensor.ones() to build a 4x8 tensor and passes it to F.matmul along with its transpose:

from max import functional as F
from max.tensor import Tensor

x = Tensor.ones((4, 8))
y = F.matmul(x, x.T)

Submodulesโ€‹

max.tensor.compilationTraces and compiles Python functions over tensors.
max.tensor.executorExecutor protocol and concrete implementations for eager graph execution.
max.tensor.realization_contextImplementations of various realization strategies.
max.tensor.shardingDefines how a tensor is laid out across a device mesh and how ops reshard it.
max.tensor.sharding.per_shard_dimWraps one Dim per device, so a dimension can vary by shard.
max.tensor.testingTesting utilities for the Tensor API.
max.tensor.validationGuard rails for running eager code in production.

Tensorโ€‹

TensorA multi-dimensional array of numeric values on a CPU or accelerator device.

Defaultsโ€‹

default_deviceContext manager for setting the default device for tensor creation.
default_dtypeContext manager for setting the default dtype for tensor creation.
defaultsGets the default dtype and device for tensor creation.
defaults_likeContext manager setting the default dtype and device for tensor creation.