jax-ml/jax · error · ValueError

Unsupported range type: {type(r)}.

Error message

Unsupported range type: {type(r)}.

What it means

is_range_out_of_bounds_for_shape encountered an index element that is neither an int nor a slice (e.g. None, ellipsis, or array). The bounds checker only supports int/slice ranges.

Source

Thrown at jax/_src/pallas/mosaic/interpret/utils.py:362

      assert 0 <= r
      if r >= d:
        return True
    elif isinstance(r, slice):
      assert r.start is not None and 0 <= r.start
      assert r.stop is not None and 0 <= r.stop

      if r.step is None:
        if r.stop > d:
          return True
      else:
        assert 0 <= r.step
        num_elements_in_slice = (r.stop - r.start + r.step - 1) // r.step
        if num_elements_in_slice > 0:
          last_index = r.start + (num_elements_in_slice - 1) * r.step
          if last_index >= d:
            return True
    else:
      raise ValueError(f"Unsupported range type: {type(r)}.")
  return False


def clip_range_to_shape(
    rnge: tuple[slice | int, ...], shape: tuple[int, ...]
) -> tuple[slice | int, ...] | None:
  """Clips `slice`s in `rnge` to the `shape`. Returns None if `rnge` is entirely out of bounds."""
  result: list[slice | int] = []
  for r, l in zip(rnge, shape, strict=True):
    if isinstance(r, int):
      if r >= l:
        return None
      result.append(r)
    elif isinstance(r, slice):
      if r.start >= l:
        return None
      result.append(slice(r.start, min(r.stop, l), r.step))
    else:

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Normalize the index: expand ellipsis/None and convert to int/slice tuples before writing
  2. Use _normalize_range-style helpers on the range before indexing
  3. Convert numpy scalars to Python ints

Example fix

// before
smem[None, 0:16] = v
// after
smem[0:1, 0:16] = v
Defensive patterns

Strategy: type-guard

Type guard

def is_supported_range(rnge):
    return all(isinstance(r, (int, slice)) for r in rnge)

Prevention

When it happens

Trigger: Calling Buffer.__setitem__ (or the util directly) with a range tuple containing None/ellipsis/numpy arrays instead of ints or slices.

Common situations: Passing raw numpy-style indexing (e.g. [None, :] or [...]) into interpret-mode shared memory writes; converting slices lazily so None sneaks through.

Related errors


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