{"record":{"id":"88c38b9acb2fb224","repo":"jax-ml/jax","slug":"unreduced-and-reduced-argument-to-partitionspe","errorCode":null,"errorMessage":"`unreduced` and `reduced` argument to PartitionSpec cannot overlap. Got unreduced: {unreduced} and reduced: {reduced}","messagePattern":"`unreduced` and `reduced` argument to PartitionSpec cannot overlap\\. Got unreduced: (.+?) and reduced: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/partition_spec.py","lineNumber":34,"sourceCode":"import 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:\n      if p in unreduced:\n        raise ValueError(\n            \"partitions cannot overlap with unreduced axes passed to\"\n            f\" PartitionSpec. Got partitions: {partitions} and unreduced axes:\"","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/partition_spec.py#L16-L52","documentation":"A PartitionSpec axis cannot be simultaneously unreduced and reduced — the two sets are semantically exclusive (an axis either keeps its data un-reduced or gets reduced). Passing an axis in both sets raises this ValueError.","triggerScenarios":"PartitionSpec(partitions, unreduced={'data'}, reduced=('data',)) — typically from building both sets from the same list of mesh axes.","commonSituations":"Generated/config-driven sharding specs where the same axis name is included in both lists; merging specs programmatically.","solutions":["Decide per axis whether it should be reduced or unreduced and remove it from the other set","Sanitize inputs: reduced = set(reduced) - set(unreduced) if unreduced takes precedence"],"exampleFix":"# before\nPartitionSpec(('rep',), unreduced=('data',), reduced=('data', 'rep'))\n# after\nPartitionSpec(('rep',), unreduced=('data',), reduced=('rep',))","handlingStrategy":"validation","validationCode":"assert set(unreduced).isdisjoint(reduced), 'axis cannot be both unreduced and reduced'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep axis role assignments in one config source"],"tags":["jax","sharding","partition-spec","mesh"],"backgroundTag":"conflicting-configuration","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}