jax-ml/jax · error · ValueError

other requires mask to be provided

Error message

other requires mask to be provided

What it means

In Triton masked-load semantics (tt.load with `other`), an `other` value (used for masked-out lanes) is only meaningful together with a mask. _load rejects other without mask with this ValueError.

Source

Thrown at jax/_src/pallas/triton/lowering.py:2045

  else:
    try:
      evict = _STR_TO_EVICTION_POLICY[eviction_policy]
    except KeyError:
      raise ValueError(
          f"unsupported eviction policy: {eviction_policy}"
      ) from None

  if _is_triton_pointer_type(ptr.type):
    ptr_type = tt_dialect.PointerType(ptr.type)
    if isinstance(ptr_type.pointee_type, ir.RankedTensorType):
      raise NotImplementedError("loading from a block pointer is not supported")

  ptr_type = _element_type(ptr.type)
  if not _is_triton_pointer_type(ptr_type):
    raise ValueError(f"unsupported pointer type: {ptr_type}")
  ptr_type = tt_dialect.PointerType(ptr_type)
  if other is not None and mask is None:
    raise ValueError("other requires mask to be provided")
  if not isinstance(ptr.type, ir.RankedTensorType):
    if other is not None and isinstance(other.type, ir.RankedTensorType):
      raise ValueError("other cannot be a block if pointer is not a block")
    if mask is not None and isinstance(mask.type, ir.RankedTensorType):
      raise ValueError("mask cannot be a block if pointer is not a block")

  pointee_type = ptr_type.pointee_type
  is_int1 = isinstance(pointee_type, ir.IntegerType) and pointee_type.width == 1
  if is_int1:
    pointee_type = ir.IntegerType.get_signless(8)
    ptr = _ir_cast(
        ptr,
        tt_dialect.PointerType.get(pointee_type, ptr_type.address_space),
        signed=False,
    )

  if other is not None:
    other = _ir_cast(other, pointee_type, signed=False)

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Provide a mask whenever supplying other: pl.load(ref, mask=m, other=0.0)
  2. Drop other if you do not need masked-lane defaults
  3. Compute an explicit boolean mask from the block indices (e.g. idx < n)

Example fix

// before
v = pl.load(ref, other=0.0)

// after
v = pl.load(ref, mask=idx < n, other=0.0)
Defensive patterns

Strategy: validation

Validate before calling

if other is not None:
    assert mask is not None, 'other requires mask: pass mask=idx < n'

Type guard

def masked_load_args_ok(mask, other) -> bool:
    return other is None or mask is not None

Try / catch

try:
    v = pl.load(ref, other=fill)
except ValueError:
    v = pl.load(ref, mask=idx < n, other=fill)

Prevention

When it happens

Trigger: Calling a load primitive with other=<value> but no mask argument, inside a Triton Pallas kernel (e.g. pl.load(ref, other=0.0) without a mask expression).

Common situations: Copying numpy-style 'fill value' calls; assuming other alone implies default masking; API misuse when hand-writing load calls.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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