#41104·jax

Error lowering pallas `fori_loop(unroll=True)` with `pltpu.ACC`

Author: skye-antCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

Description

Repro (runs on CPU):

python
import jax
import jax.numpy as jnp
from jax.experimental import pallas as pl
from jax.experimental.pallas import tpu as pltpu


def kernel(x_ref, o_ref):
  def scoped(acc):
    def body(i, _):
      pltpu.matmul_acc_lhs(acc, x_ref[...])

    jax.lax.fori_loop(0, 2, body, None, unroll=True)
    o_ref[...] = pltpu.matmul_pop(acc)

  pl.run_scoped(scoped, pltpu.ACC(0)((8, 256), jnp.float32))


x = jax.ShapeDtypeStruct((8, 256), jnp.float32)
f = pl.pallas_call(kernel, out_shape=x)
tpu7x = jax.sharding.AbstractDevice(device_kind="TPU7x", num_cores=1, platform="tpu")
with jax.sharding.use_abstract_mesh(jax.sharding.AbstractMesh((), (), abstract_device=tpu7x)):
  jax.jit(f).trace(x).lower(lowering_platforms=("tpu",))
print("lowered OK")

Produces:
AttributeError: 'AccRef' object has no attribute 'type'

Claude says this also fails similarly on PRNG keys.

Claude says: https://github.com/jax-ml/jax/commit/187eaa93f93a217b7162d77a763994b90fcd5ce6 ("[Pallas:TPU] Restore C++ inlined_func_call lowering for fully unrolled fori_loops", first in nightly 0.12.0.dev20260923) lowers the body of a fully unrolled static fori_loop once, as a detached function. That function's argument types come from each closed-over value's and carry's .type. Pallas TPU represents an accumulator ref as an AccRef and a PRNG key as a KeyScalarBundle. Neither has .type, so lowering fails with AttributeError: 'AccRef' object has no attribute 'type' at jax/_src/pallas/mosaic/lowering.py:4434. This is public-API code that lowered on 0920. It still fails on the 0928 nightly.

System info (python version, jaxlib version, accelerator, etc.)