jax-ml/jax · error · TypeError

static_slice: unrecognized index {pidx.index} at position {p

Error message

static_slice: unrecognized index {pidx.index} at position {position}.

What it means

Defensive fallback in to_static_slice's index-type dispatch: a ParsedIndex whose IndexType is not one of the recognized kinds triggers TypeError. Should be unreachable via public APIs because from_index only produces known types; like error 1425 it signals an internal/version inconsistency.

Source

Thrown at jax/_src/numpy/indexing.py:406

    # Validation of the unmodified user indices.
    if parsed_mode == slicing.GatherScatterMode.PROMISE_IN_BOUNDS:
      self.validate_static_indices(normalize_indices=normalize_indices)
    self.validate_slices()

    # For sharded inputs, indexing (like x[0]) and partial slices (like x[:2] as
    # opposed to x[:]) lead to incorrect sharding semantics when computed via slice.
    # TODO(yashkatariya): fix slice with sharding
    if arr_is_sharded and self.has_partial_slices():
      raise ValueError("static_slice with partial slices does not support nontrivial array sharding.")

    for position, pidx in enumerate(self.indices):
      if pidx.typ in [IndexType.INTEGER, IndexType.ELLIPSIS, IndexType.SLICE, IndexType.NONE]:
        pass
      elif pidx.typ in [IndexType.ARRAY, IndexType.BOOLEAN, IndexType.DYNAMIC_SLICE]:
        raise TypeError("static_slice: indices must be static scalars or slices."
                        f" Got index of type {type(pidx.index)} at position {position}")
      else:
        raise TypeError(f"static_slice: unrecognized index {pidx.index} at position {position}.")

    # Now re-iterate to generate static slices.
    start_indices: list[int] = []
    limit_indices: list[int] = []
    strides: list[int] = []
    rev_axes: list[int] = []
    squeeze_axes: list[int] = []
    newaxis_dims: list[int] = []

    expanded = self.expand_ellipses()
    for pidx in expanded.indices:
      if pidx.typ in [IndexType.ARRAY, IndexType.BOOLEAN, IndexType.ELLIPSIS]:
        raise RuntimeError(f"Internal: unexpected index encountered: {pidx}")
      elif pidx.typ == IndexType.NONE:
        # Expanded axes indices are based on the rank of the array after slicing
        # (tracked by start_indices) and squeezing (tracked by squeeze_axes), and
        # expand_dims inserts dimensions in order, so we must also account for
        # previous expanded dimensions.

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Reinstall/align jax and jaxlib to one version
  2. Avoid constructing ParsedIndex manually; use public indexing
  3. Report upstream with a repro if triggered by plain indexing
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: Manually constructed NDIndexer/ParsedIndex with an exotic typ, or a JAX internal version mismatch between modules.

Common situations: Monkey-patching, vendored/partial JAX installs, or mixed jax/jaxlib versions.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/d31ce7ab1fd7a9c6. Report an issue: GitHub.