jax-ml/jax · error · NotImplementedError

reshape not supported yet

Error message

reshape not supported yet: {aval_in}, {aval_out}

What it means

Raised by the Pallas fuser's block-spec propagation when a reshape between two shapes cannot be expressed with the current block-shape machinery: the input/output avals (aval_in, aval_out) do not admit a supported reshape of the tiled block shape (e.g. non-matching block sizes on lanes), which the fuser does not implement yet.

Solutions

  1. Restructure the kernel so the reshape matches the supported fused block patterns (avoid reshaping across tiled/lane dimensions)
  2. Select the entire block on the last dimension so the reshape can legally collapse it
  3. Move the reshape out of the Pallas kernel and perform it in the surrounding JAX code
  4. Update JAX; this 'not supported yet' limitation may be lifted in newer releases
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at jax/_src/pallas/fuser/block_spec.py:2467 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at jax/_src/pallas/fuser/block_spec.py:2467

          'reshape with non-matching block size on lanes not supported yet:'
          f' {block_shape}'
      )
    new_block_shape = (*block_shape[:-2], total_block_size)

    def new_block_index_transform(*idxs):
      *idx, second_to_last, last = block_transform.block_index_transform(*idxs)
      # last should always be 0
      if not isinstance(last, int) and last != 0:
        raise NotImplementedError(
            'Must select entire block on last dimension for reshape'
        )
      return *idx, second_to_last

    return [block_transform.replace(
                block_shape=new_block_shape,
                block_index_transform=new_block_index_transform,)]

  raise NotImplementedError(f'reshape not supported yet: {aval_in}, {aval_out}')


@register_eval_rule(lax.reshape_p)
def _reshape_eval_rule(
    eval_ctx: KernelEvalContext, x, *, dimensions, new_sizes, sharding
):
  del sharding, dimensions, new_sizes
  out_shape_nones = tuple(
      _block_size(s) for s in eval_ctx.out_block_specs[0].block_shape
  )
  out_shape = tuple(s for s in out_shape_nones if s is not None)
  # Because we have restricted the pull block spec rule, we can just apply a
  # basic reshape here.
  x = x.reshape(out_shape)
  return x


@register_pull_block_spec_rule(lax.reduce_sum_p)

View on GitHub (pinned to 1e1c6a8fc0)