jax-ml/jax · error · ValueError
Unsupported block shape type: {type(dim)}
Error message
Unsupported block shape type: {type(dim)} What it means
Internal helper _get_block_dim_size extracts the size from a BlockDim via match: Squeezed/None -> 0, Blocked/Element/BoundedSlice/Indirect -> their block_size, plain int -> itself. Any other type falls to the wildcard case and raises this ValueError.
Source
Thrown at jax/_src/pallas/core.py:486
def _canonicalize_block_shape(block_shape: Sequence[BlockDim | int | None]
) -> tuple[BlockDim, ...]:
return tuple(_canonicalize_block_dim(dim) for dim in block_shape)
def _get_block_dim_size(dim: BlockDim) -> int:
match dim:
case Squeezed():
return 1
case (
Blocked(block_size)
| Element(block_size)
| BoundedSlice(block_size)
| Indirect(block_size)
):
return block_size
case _:
raise ValueError(f"Unsupported block shape type: {type(dim)}")
def get_block_size(dim: BlockDim | int | None) -> int:
match dim:
case int():
return dim
case Squeezed() | None:
return 1
case (
Blocked(block_size)
| Element(block_size)
| BoundedSlice(block_size)
| Indirect(block_size)
):
return block_size
case _:
raise ValueError(f"Unsupported block shape type: {type(dim)}")
View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Ensure every entry of block_shape is int, None, Blocked, Squeezed, Element, BoundedSlice, or Indirect from the same JAX version
- Don't create custom block-dim classes; express custom tiling with index_map instead
- Reinstall/align JAX versions if the values come from library internals
Defensive patterns
Strategy: validation
Validate before calling
from jax._src.pallas import core as pcore
allowed = (int, type(None), pcore.Blocked, pcore.Squeezed, pcore.Element,
pcore.BoundedSlice, pcore.Indirect)
assert all(isinstance(d, allowed) for d in block_shape) Type guard
def is_valid_block_shape(shape):
return all(d is None or isinstance(d, (int, Blocked, Squeezed, Element, BoundedSlice, Indirect)) for d in shape) Prevention
- Canonicalize block shapes via the public helpers before transforms
- Avoid custom block-dim classes
When it happens
Trigger: Passing a custom or malformed object inside a canonicalized block_shape — typically from constructing BlockSpec with non-standard dims or from internal code paths (_get_block_shape, has_trivial_window, triton lowering) receiving corrupted block specs.
Common situations: Subclassing or monkey-patching BlockDim types; JAX internal version mismatches; feeding block shapes built by older/newer pallas APIs.
Related errors
- Unsupported block dimension type: {type(dim)}. Allowed types
- Array type must have a `shape` attribute, but got {type(arra
- Block shape for {origin} (= {block_shape}) must have the sam
- Index map function {debug_info.func_src_info} for {origin} m
- index_map returned a value of type {type(idx_aval)} at posit
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/a84f9419c502aa4d.
Report an issue: GitHub.