{"record":{"id":"d1d388d1b7f1c03a","repo":"jax-ml/jax","slug":"reduced-in-prefix-specs-s-can-only-be-used-whe","errorCode":null,"errorMessage":"reduced in {prefix}_specs {s} can only be used when the mesh passed to shard_map contains axis names all of type `Explicit`. Got mesh {mesh}","messagePattern":"reduced in (.+?)_specs (.+?) can only be used when the mesh passed to shard_map contains axis names all of type `Explicit`\\. Got mesh (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/shard_map.py","lineNumber":467,"sourceCode":"  specs_flat, _ = tree_flatten(specs)\n  for s in specs_flat:\n    if isinstance(s, HiPspec):\n      continue  # TODO(mattjj,yashkatariya): add user validation method\n    if not s.unreduced and not s.reduced:\n      continue\n    if not full_manual:\n      raise NotImplementedError(\n          f\"unreduced/reduced can only be passed to {prefix}_specs when\"\n          \" shard_map is in full manual mode. Got mesh axis names\"\n          f\" {mesh.axis_names}, manual_axes: {manual_axes}, specs: {s}. Please\"\n          \" file a bug at https://github.com/jax-ml/jax/issues.\")\n    if not all(mesh._name_to_type[u] == AxisType.Explicit for u in s.unreduced):\n      raise ValueError(\n          f\"unreduced in {prefix}_specs {s} can only be used when the mesh\"\n          \" passed to shard_map contains axis names all of type `Explicit`.\"\n          f\" Got mesh {mesh}\")\n    if not all(mesh._name_to_type[u] == AxisType.Explicit for u in s.reduced):\n      raise ValueError(\n          f\"reduced in {prefix}_specs {s} can only be used when the mesh\"\n          \" passed to shard_map contains axis names all of type `Explicit`.\"\n          f\" Got mesh {mesh}\")\n\n\ndef _check_specs(error_type: SpecErrorType, specs: Any, manual_axes) -> None:\n  from jax._src.hijax import HiPspec\n  if error_type == SpecErrorType.input and specs is None:\n    raise TypeError(\n        \"shard_map in_specs argument must be a pytree of \"\n        \"`jax.sharding.PartitionSpec` instances, but it was None.\\n\"\n        \"Instead of `in_specs=None`, did you mean `in_specs=P()`, \"\n        \"where `P = jax.sharding.PartitionSpec`?\")\n\n  def check_spec(p):\n    if isinstance(p, HiPspec):\n      return True  # TODO(mattjj,yashkatariya): add user validation method\n    if not isinstance(p, PartitionSpec):","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/shard_map.py#L449-L485","documentation":"Raised when an in_specs/out_specs PartitionSpec uses the `reduced` field while the mesh passed to shard_map contains axis names that are not all of type `Explicit`. Reduced (collectively-summed) axes only have well-defined semantics on explicit mesh axes.","triggerScenarios":"Calling shard_map with a spec like P('x', reduced=('y',)) where mesh axis 'y' is implicit/non-explicit (abstract mesh or non-explicit axis type).","commonSituations":"Combining the reduced/unreduced spec extension with abstract meshes or partially non-explicit axis types introduced in newer JAX versions.","solutions":["Make all axes referenced in `reduced` Explicit on the mesh","Use a concrete jax.sharding.Mesh with explicit axis types","Drop `reduced` from the spec and handle reduction manually inside the function"],"exampleFix":"// before\nshard_map(f, mesh=amesh, in_specs=P(reduced=('y',)))\n// after\nmesh = jax.make_mesh((4,), ('y',), axis_types=(AxisType.Explicit,))\nshard_map(f, mesh=mesh, in_specs=P(reduced=('y',)))","handlingStrategy":"validation","validationCode":"def axes_explicit(mesh, spec):\n    return all(mesh._name_to_type.get(r) == AxisType.Explicit for r in (spec.reduced or ()))","typeGuard":"def has_only_explicit_reduced(mesh, s) -> bool:\n    return all(r in mesh._name_to_type and mesh._name_to_type[r] == AxisType.Explicit for r in s.reduced)","tryCatchPattern":"try: shard_map(...) except ValueError as e: if 'reduced in' in str(e): make axes explicit; else: raise","preventionTips":["Prefer concrete Mesh objects when using reduced semantics","Document which mesh axes are explicit at API boundaries"],"tags":["shard-map","partition-spec","mesh","jax","reduced"],"backgroundTag":"invalid-sharding-spec","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}