﻿# JAX NamedSharding: device count does not specify which array axis is partitioned

Describe JAX distributed array placement with a device mesh and PartitionSpec, distinguishing replicated dimensions from partitioned data before reviewing memory use.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-jax-named-sharding-axis-layout/
Language: en

## Begin with the logical array

A team adds GPUs to a feature calculation and expects every array to become smaller on each device. The [sharding guide](https://docs.jax.dev/en/latest/201/sharding.html) describes placement as a relationship between logical array dimensions and a device mesh. More available devices do not by themselves define that relationship. Name the dimensions first: examples, features and model parameters may need different layouts. Otherwise a capacity estimate can silently assume partitioning where the actual calculation keeps replicated values.

## Read mesh names and array axes separately

The [sharding API](https://docs.jax.dev/en/latest/jax.sharding.html) defines NamedSharding as a mesh paired with a PartitionSpec. The mesh describes a named arrangement of devices; the specification describes how array axes use mesh axes. They are not interchangeable shapes. A mesh axis named for data does not force the array's leading dimension to use it. Review the mapping explicitly whenever a transpose, reshape or new input convention changes the meaning of a logical array axis.

## Distinguish replication from unused capacity

The guide shows that omitting a mesh axis from a partition specification can replicate the data across that axis. Replication may be intentional for a shared parameter vector while the example axis is partitioned. It is not necessarily evidence of a failed sharding setup. Compute per-device storage from the actual mapping and inspect representative shards. Keep this storage explanation separate from a claim that the complete operation needs no communication; a consumer can require movement between otherwise valid layouts.

## Establish placement at the interface boundary

The [device_put reference](https://docs.jax.dev/en/latest/_autosummary/jax.device_put.html) accepts a sharding describing destination placement. Use an intentional transfer or resharding boundary instead of relying on assumptions about a previous array's layout. Validate compatibility with the actual global shape and installed API. A wrapper should explain the expected incoming layout and the layout produced for the next calculation, especially when the dataset and parameter collection follow different partitioning strategies.

## Verify meaning as well as device participation

Use recognizable input values to confirm which logical slices reside on each device and where copies repeat. Compare the reconstructed logical result with an unpartitioned reference. The guides on [tensor memory contracts](/journal/learn-tensor-memory-descriptor/) and [distributed loader ranks](/journal/data-guide-distributed-shard-worker-overlap/) provide related distinctions. Correct device participation is useful evidence, but it does not establish correct array-axis mapping or prove that the chosen placement is efficient for the downstream operation.
