jax-ml/jax · error · NotImplementedError
Unsupported reduction kind: {op.kind}
Error message
Unsupported reduction kind: {op.kind} What it means
vector.reduction lowering supports only add/max/min combining kinds; anything else (e.g. AND, OR, XOR) falls through to NotImplementedError.
Source
Thrown at jax/experimental/mosaic/gpu/dialect_lowering.py:871
element_type = op.vector.type.element_type
scratch = _slice_smem(
ir.MemRefType.get([4], element_type, memory_space=utils.smem()),
ir.IntegerAttr(op.attributes["offset"]).value,
ctx.smem_requested_bytes,
)
axes = range(op.vector.type.rank)
op_kind = _combining_kind(op.kind)
is_signed = _is_reduction_signed(op_kind)
a = _fragmented_array_from_ir(op.vector, layout, is_signed)
match op_kind:
case vector.CombiningKind.ADD:
result = a.reduce("add", axes, scratch)
case vector.CombiningKind.MAXSI | vector.CombiningKind.MAXUI | vector.CombiningKind.MAXIMUMF:
result = a.reduce("max", axes, scratch)
case vector.CombiningKind.MINUI | vector.CombiningKind.MINSI | vector.CombiningKind.MINIMUMF:
result = a.reduce("min", axes, scratch)
case _:
raise NotImplementedError(f"Unsupported reduction kind: {op.kind}")
assert isinstance(result.layout, fa.WGSplatFragLayout)
return [result.registers.item()]
@_register_lowering(vector.MultiDimReductionOp)
def _vector_multi_dim_reduction_op_lowering_rule(
ctx: LoweringContext, op: vector.MultiDimReductionOp
) -> Sequence[ir.Value]:
[in_layout, acc_layout] = inference_utils.in_layouts(op)
[out_layout] = inference_utils.out_layouts(op)
if out_layout != acc_layout:
raise ValueError(
f"Output layout {out_layout} must match the accumulator layout"
f" {acc_layout}"
)
if len(op.reduction_dims) != 1:
raise NotImplementedError("Only 1 reduction dimension is supported.")View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Implement bitwise reduction manually via elementwise ops + add reduction on integer representation
- Restrict to add/max/min reductions
Defensive patterns
Strategy: fallback
Validate before calling
SUPPORTED = {'add', 'max', 'min'}
assert kind in SUPPORTED, f'reduction kind {kind} unsupported' Prevention
- Stick to add/min/max vector reductions; emulate bitwise ops manually
When it happens
Trigger: Emitting vector.reduction with kind like AND/OR/XOR in a Mosaic kernel.
Common situations: Porting code that uses bitwise vector reductions, which Mosaic GPU does not lower.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- `strides` must contain only 1s.
- Only slicing with static indices allowed.
- Output layout {out_layout} must match the accumulator layout
- Only 1 reduction dimension is supported.
- Unsupported layout: {src.layout}
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/957450bd7146ddd6.
Report an issue: GitHub.