{"record":{"id":"f6b0183c2a5ffe10","repo":"jax-ml/jax","slug":"unreduced-kind-should-be-none-when-unreduced-f6b018","errorCode":null,"errorMessage":"`unreduced_kind` should be `None` when `unreduced` is an empty set. Got {unreduced_kind=} and {unreduced=}","messagePattern":"`unreduced_kind` should be `None` when `unreduced` is an empty set\\. Got (.+?) and (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/partition_spec.py","lineNumber":42,"sourceCode":"def _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:\"\n            f\" {unreduced}\")\n      if p in reduced:\n        raise ValueError(\n            \"partitions cannot overlap with reduced axes passed to\"\n            f\" PartitionSpec. Got partitions: {partitions} and reduced axes:\"\n            f\" {reduced}\")\n\ndef _get_ur_str(unreduced, reduced):","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/partition_spec.py#L24-L60","documentation":"unreduced_kind is only meaningful when the unreduced set is non-empty. Passing a non-None unreduced_kind together with an empty unreduced set is contradictory and raises ValueError.","triggerScenarios":"PartitionSpec(ps, unreduced=(), unreduced_kind=UnreducedKind.PARTIAL); often happens when the unreduced set is computed dynamically and ends up empty while kind is hard-coded.","commonSituations":"Config-driven code that always sets a kind but sometimes has no unreduced axes.","solutions":["Set unreduced_kind=None when unreduced is empty: kind = kind if unreduced else None","Default the kind argument to None and only set it when axes exist"],"exampleFix":"# before\nPartitionSpec(ps, unreduced=(), unreduced_kind=kind)\n# after\nPartitionSpec(ps, unreduced=(), unreduced_kind=kind if axes else None)","handlingStrategy":"validation","validationCode":"unreduced_kind = unreduced_kind if unreduced else None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only set a kind when the unreduced set is non-empty"],"tags":["jax","sharding","partition-spec","validation"],"backgroundTag":"conflicting-configuration","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}