{"record":{"id":"6d104e92d9b3814d","repo":"jax-ml/jax","slug":"reduced-cannot-contain-none-all-elements-in-reduc","errorCode":null,"errorMessage":"reduced cannot contain None. All elements in reduced should refer to the mesh axes.","messagePattern":"reduced cannot contain None\\. All elements in reduced should refer to the mesh axes\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/partition_spec.py","lineNumber":30,"sourceCode":"# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import annotations\nimport enum\nfrom typing import Any\n\nfrom jax._src.util import weak_value_interner, immutable\nfrom jax._src.lib import _jax\n\nAxisName = Any\n\ndef _check(partitions, unreduced, reduced, unreduced_kind):\n  if None in unreduced:\n    raise ValueError(\n        \"unreduced cannot contain None. All elements in unreduced should refer\"\n        \" to the mesh axes.\")\n  if None in reduced:\n    raise ValueError(\n        \"reduced cannot contain None. All elements in reduced should refer\"\n        \" to the mesh axes.\")\n  if unreduced & reduced:\n    raise ValueError(\n        \"`unreduced` and `reduced` argument to PartitionSpec cannot overlap. \"\n        f\"Got unreduced: {unreduced} and reduced: {reduced}\")\n  if unreduced_kind is not None and not isinstance(unreduced_kind, UnreducedKind):\n      raise TypeError(\n          \"Expected unreduced_kind to be of type `jax.sharding.UnreducedKind`\"\n          f\" but got {type(unreduced_kind)}\")\n  if not unreduced and unreduced_kind is not None:\n    raise ValueError(\n        \"`unreduced_kind` should be `None` when `unreduced` is an empty set.\"\n        f\" Got {unreduced_kind=} and {unreduced=}\")\n\n  for partition in partitions:\n    partition = partition if isinstance(partition, tuple) else (partition,)\n    for p in partition:","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/partition_spec.py#L12-L48","documentation":"In the unreduced/reduced PartitionSpec API, the reduced set must contain only mesh axis names; None is rejected because a reduced axis always refers to a concrete mesh dimension that collectives will reduce over.","triggerScenarios":"PartitionSpec(..., reduced=(None,)) or passing a spec built for classic sharding (with None) into the reduced argument.","commonSituations":"Migrating old PartitionSpec tuples containing None to the new API without filtering; programmatically building reduced sets from user input that includes None.","solutions":["Filter None out: reduced = tuple(a for a in reduced if a is not None)","Only pass mesh axis names registered on your Mesh"],"exampleFix":"# before\nreduced = (None, 'data')\n# after\nreduced = ('data',)","handlingStrategy":"validation","validationCode":"reduced = tuple(a for a in reduced if a is not None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter None from axis lists when migrating old specs"],"tags":["jax","sharding","partition-spec","mesh"],"backgroundTag":"invalid-argument-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}