jax-ml/jax · error · ValueError
Can only concatenate 1D vectors
Error message
Can only concatenate 1D vectors
What it means
Beyond the first element, vector_concat also verifies each operand is itself rank-1; a later operand of rank>=2 raises this ValueError (note: a ValueError, unlike the NotImplementedError used for the first operand).
Source
Thrown at jax/experimental/mosaic/gpu/utils.py:2137
)
def vector_concat(
vectors: Sequence[ir.Value[ir.VectorType]],
) -> ir.Value[ir.VectorType]:
if not vectors:
raise ValueError("Cannot concatenate an empty list of vectors")
vty = vectors[0].type
if not isinstance(vty, ir.VectorType):
raise ValueError("Cannot concatenate non-vector values")
vty = ir.VectorType(vty)
if vty.rank != 1:
raise NotImplementedError("Only 1D vectors are supported")
for v in vectors:
if v.type.element_type != vty.element_type:
raise ValueError("Cannot concatenate vectors of different element types")
if v.type.rank != 1:
raise ValueError("Can only concatenate 1D vectors")
return _vector_concat_rec(vectors)
def _vector_concat_rec(
vectors: Sequence[ir.Value[ir.VectorType]],
) -> ir.Value[ir.VectorType]:
match vectors:
case [v]:
return v
case [v, w]:
[v_len] = ir.VectorType(v.type).shape
[w_len] = ir.VectorType(w.type).shape
mask = ir.DenseI64ArrayAttr.get(list(range(v_len + w_len)))
return vector.shuffle(*vectors, mask=mask)
case _:
assert vectors
l = _vector_concat_rec(vectors[: len(vectors) // 2])
r = _vector_concat_rec(vectors[len(vectors) // 2 :])View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Flatten every operand to rank-1 before concatenating (vector.shape_cast)
- Validate all operands in a loop: assert ir.VectorType(v.type).rank == 1
- Fix the producer emitting the multi-dimensional vector
Example fix
# before v = vector_concat([flat_a, tile_2d]) # after flat_tile = vector.shape_cast(ir.VectorType.get((tile_2d.type.num_elements,), tile_2d.type.element_type), tile_2d) v = vector_concat([flat_a, flat_tile])
Defensive patterns
Strategy: validation
Validate before calling
assert all(ir.VectorType(v.type).rank == 1 for v in vectors), 'all operands must be 1D'
Type guard
def all_rank1(vals) -> bool:
return all(isinstance(v.type, ir.VectorType) and ir.VectorType(v.type).rank == 1 for v in vals) Prevention
- Validate every operand, not just the first
- shape_cast any multi-dim fragment before appending
When it happens
Trigger: Calling vector_concat where vectors[0] is 1D but a subsequent element is e.g. vector<2x4xf32>.
Common situations: Heterogeneous fragment lists where one producer changed shape; appending a reshaped tile to a list of flat vectors.
Related errors
- Expected metadata to be 3-dimensional (M, K // 4, 2), but it
- Only 2D gathers/scatters for async load/store are supported.
- Only 1D vectors are supported {v_ty}
- Cannot concatenate an empty list of vectors
- Cannot concatenate non-vector values
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/45ab98e528423f68.
Report an issue: GitHub.