A device mesh arranges devices as an n-dimensional grid so tensor axes can be partitioned across selected mesh axes. Its shape expresses how computation and data shards are distributed, while create_device_mesh() chooses an ordering suited to the hardware topology and collective communication. section 8.1.1
>>> mesh_utils.create_device_mesh((8, 1), devices=jax.devices("cpu"))
Create an eight-device, two-dimensional mesh for CPU emulation or another available device set. A shape of (8, 1) partitions a tensor's first axis; (1, 8) partitions its second. section 8.1.1
The mesh shape must align with the tensor rank and divide its dimensions evenly. For example, a (2, 4) mesh can partition a (4000, 10000) array into 2,000-vector groups and 2,500-feature chunks. Each device computes partial dot products, then the partial results are combined. section 8.1.1 section 8.1.3
JAX supports positional meshes, where array positions determine partitioning, and named meshes, where resource names such as batch and features make the mapping explicit through Mesh, NamedSharding, and PartitionSpec. None leaves an axis replicated. section 8.1.6
Mixing data and tensor parallelism
A (4, 2) mesh can shard training items across four device groups while splitting selected model weights across two groups. Small final-layer parameters can remain replicated across all devices. section 8.2.2


