jax-ml/jax · error · ValueError
Empty array
Error message
Empty array
What it means
Raised by pack_array, which packs a list of SSA values into a stack-allocated LLVM array (used e.g. to fill TMA descriptors). An empty list has no element type to allocate for, so it's rejected immediately rather than producing an ambiguous alloca.
Solutions
- Guard callers: skip pack_array/init_tma_desc when the values list is empty
- Ensure tensor shapes fed into TMA descriptor creation are non-empty
- Pass at least one value (e.g. a zero constant) if the API requires a placeholder
Example fix
# before vals = compute_dims(t) # t has 0-sized dim -> [] packed = utils.pack_array(vals) # after if not vals: return None # or raise a clearer upstream error packed = utils.pack_array(vals)
Defensive patterns
Strategy: validation
Validate before calling
if not values:
raise ValueError('cannot build TMA descriptor from empty dimensions')
packed = utils.pack_array(values) Type guard
def is_packable(values):
return len(values) > 0 Prevention
- Validate tensor shapes are non-empty before init_tma_desc
- Skip TMA descriptor creation for degenerate/empty tensors
When it happens
Trigger: Calling utils.pack_array([]) — in practice via init_tma_desc with an empty tensor of box dimensions, e.g. a TMA descriptor for a 0-rank/empty tensor shape.
Common situations: Building TMA descriptors from dynamically-sized tensors that can be empty at trace time (e.g. 0-sized dimension), or computing box dims that degenerate to an empty list.
Related errors
- Cannot specify scope to a non-uniform debug_print.
- Expected both or neither of scales to be specified.
- must be positive
- name must be non-empty
- Scope not supported
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/73b8eaab7983f649.
Report an issue: GitHub.
Appendix: source
Thrown at jax/experimental/mosaic/gpu/utils.py:130
desc, llvm.ConstantOp(i64, ir.IntegerAttr.get(i64, 0)).result, [2]
).result
if rank > 0:
for i, s in enumerate(memref_ty.shape):
desc = llvm.InsertValueOp(
desc, llvm.ConstantOp(i64, ir.IntegerAttr.get(i64, s)).result, [3, i]
).result
for i, s in enumerate(strides):
desc = llvm.InsertValueOp(
desc, llvm.ConstantOp(i64, ir.IntegerAttr.get(i64, s)).result, [4, i]
).result
result = builtin.unrealized_conversion_cast([memref_ty], [desc])
assert isinstance(result, ir.Value)
return result
def pack_array(values):
if not values:
raise ValueError("Empty array")
elem_ty = values[0].type
i64 = ir.IntegerType.get_signless(64)
ptr_ty = ir.Type.parse("!llvm.ptr")
arr_ptr = llvm.alloca(ptr_ty, c(len(values), i64), elem_ty)
for i, v in enumerate(values):
elem_ptr = getelementptr(arr_ptr, [i], elem_ty)
llvm.store(v, elem_ptr)
return arr_ptr
def get_contiguous_strides(xs):
strides_ret = []
stride = 1
for x in xs[::-1]:
strides_ret.append(stride)
stride *= x
return strides_ret[::-1]
View on GitHub (pinned to 1e1c6a8fc0)