{"record":{"id":"526ac2592301dfe4","repo":"jax-ml/jax","slug":"name-must-have-at-least-one-non-none-value-in-in","errorCode":null,"errorMessage":"{name} must have at least one non-None value in in_axes or axis_size must be specified","messagePattern":"(.+?) must have at least one non-None value in in_axes or axis_size must be specified","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/api.py","lineNumber":1341,"sourceCode":"      # TODO(mattjj): better error message here\n      raise ValueError(\n          f\"{name} was requested to map its argument along axis {axis}, \"\n          f\"which implies that its rank should be at least {min_rank}, \"\n          f\"but is only {len(shape)} (its shape is {shape})\") from e\n\n  all_mapped_sizes = [\n    None if d is None else _get_axis_size(name, x, d)\n    for x, d in zip(vals, dims)\n  ]\n  all_sizes = [s for s in all_mapped_sizes if s is not None]\n  if axis_size is not None:\n    all_sizes.append(axis_size)\n  sizes = core.dedup_referents(all_sizes)\n  if len(sizes) == 1:\n    sz, = sizes\n    return sz\n  if not sizes:\n    raise ValueError(f\"{name} must have at least one non-None value in in_axes \"\n                     \"or axis_size must be specified\")\n\n  def _get_argument_type(x):\n    try:\n      return shaped_abstractify(x).str_short()\n    except TypeError: # Catch all for user specified objects that can't be interpreted as a data type\n      return \"unknown\"\n  msg = [f\"{name} got inconsistent sizes for array axes to be mapped:\\n\"]\n  args, kwargs = tree_unflatten(tree, vals)\n  try:\n    ba = inspect.signature(fn).bind(*args, **kwargs)\n    signature_parameters: list[str] | None = list(ba.signature.parameters.keys())\n  except (TypeError, ValueError):\n    signature_parameters = None\n\n  def arg_name(key_path):\n    if signature_parameters is None:\n      return f\"args{keystr(key_path)}\"","sourceCodeStart":1323,"sourceCodeEnd":1359,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/api.py#L1323-L1359","documentation":"Raised when all in_axes entries are None (nothing is actually mapped) and no axis_size was provided, so vmap cannot determine the size of the mapped axis. vmap requires at least one mapped value or an explicit axis_size.","triggerScenarios":"jax.vmap(f, in_axes=None)(x); jax.vmap(f, in_axes=(None, None))(x, y) without axis_size.","commonSituations":"Dynamically computed in_axes that end up all None; migrating code where the batch axis was removed; wrapping functions that only return constants.","solutions":["Pass axis_size=N explicitly","Set at least one in_axes entry to an integer axis of a corresponding array argument","Double-check that you actually want vmap if nothing is mapped"],"exampleFix":"// before\njax.vmap(f, in_axes=None)(x)\n// after\njax.vmap(f, in_axes=None, axis_size=16)(x)\n# or\njax.vmap(f, in_axes=0)(x)","handlingStrategy":"validation","validationCode":"if all(a is None for a in tree_leaves(in_axes)):\n    assert axis_size is not None, 'vmap with all-None in_axes needs axis_size'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass axis_size whenever in_axes is computed dynamically","Default to in_axes=0 in wrappers that receive arrays","Unit-test wrapper in_axes configurations"],"tags":["jax","vmap","in-axes","axis-size"],"backgroundTag":"missing-required-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}