{"record":{"id":"15f813a79bd14a5b","repo":"jax-ml/jax","slug":"unreduced-cannot-contain-none-all-elements-in-unr","errorCode":null,"errorMessage":"unreduced cannot contain None. All elements in unreduced should refer to the mesh axes.","messagePattern":"unreduced cannot contain None\\. All elements in unreduced should refer to the mesh axes\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/partition_spec.py","lineNumber":26,"sourceCode":"#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# 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=}\")","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/partition_spec.py#L8-L44","documentation":"When constructing a PartitionSpec with unreduced axes (new-style sharding specs), every element of the unreduced set must be a real mesh axis name. None is not allowed because unreduced axes denote named mesh axes that remain un-reduced, unlike classic ParsedPartitionSpecs where None means 'not partitioned'.","triggerScenarios":"Creating a PartitionSpec with unreduced=(None, 'data') or reusing an old spec with None placeholders in the new unreduced API.","commonSituations":"Mixing classic NamedSharding-style specs (where None is idiomatic) with the newer unreduced/reduced PartitionSpec constructor; copy-pasting specs across APIs.","solutions":["Remove None entries from unreduced; only include actual mesh axis names","Use None only in the positional partitions part, not in unreduced/reduced"],"exampleFix":"# before\nPartitionSpec(('data',), unreduced=(None, 'model'))\n# after\nPartitionSpec(('data',), unreduced=('model',))","handlingStrategy":"validation","validationCode":"assert None not in unreduced, 'unreduced takes mesh axis names only'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["None belongs only in positional partitions, never unreduced/reduced"],"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"}