IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/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. /max/get-started.md).

Python function

mesh_context

mesh_context()

max.experimental.sharding.mesh_context(mesh)

source

Publishes mesh to spec-first NamedMapping constructions.

JAX-style: when a NamedMapping is created without an explicit mesh inside this block, it picks up mesh from this context and resolves the spec against it.

with mesh_context(mesh):
    model = Transformer(...)  # all weights resolve against ``mesh``

Parameters:

mesh (DeviceMesh)

Return type:

Iterator[DeviceMesh]