{"record":{"id":"0a4973b4fcb251e0","repo":"jax-ml/jax","slug":"other-requires-mask-to-be-provided","errorCode":null,"errorMessage":"other requires mask to be provided","messagePattern":"other requires mask to be provided","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/triton/lowering.py","lineNumber":2045,"sourceCode":"  else:\n    try:\n      evict = _STR_TO_EVICTION_POLICY[eviction_policy]\n    except KeyError:\n      raise ValueError(\n          f\"unsupported eviction policy: {eviction_policy}\"\n      ) from None\n\n  if _is_triton_pointer_type(ptr.type):\n    ptr_type = tt_dialect.PointerType(ptr.type)\n    if isinstance(ptr_type.pointee_type, ir.RankedTensorType):\n      raise NotImplementedError(\"loading from a block pointer is not supported\")\n\n  ptr_type = _element_type(ptr.type)\n  if not _is_triton_pointer_type(ptr_type):\n    raise ValueError(f\"unsupported pointer type: {ptr_type}\")\n  ptr_type = tt_dialect.PointerType(ptr_type)\n  if other is not None and mask is None:\n    raise ValueError(\"other requires mask to be provided\")\n  if not isinstance(ptr.type, ir.RankedTensorType):\n    if other is not None and isinstance(other.type, ir.RankedTensorType):\n      raise ValueError(\"other cannot be a block if pointer is not a block\")\n    if mask is not None and isinstance(mask.type, ir.RankedTensorType):\n      raise ValueError(\"mask cannot be a block if pointer is not a block\")\n\n  pointee_type = ptr_type.pointee_type\n  is_int1 = isinstance(pointee_type, ir.IntegerType) and pointee_type.width == 1\n  if is_int1:\n    pointee_type = ir.IntegerType.get_signless(8)\n    ptr = _ir_cast(\n        ptr,\n        tt_dialect.PointerType.get(pointee_type, ptr_type.address_space),\n        signed=False,\n    )\n\n  if other is not None:\n    other = _ir_cast(other, pointee_type, signed=False)","sourceCodeStart":2027,"sourceCodeEnd":2063,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/triton/lowering.py#L2027-L2063","documentation":"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.","triggerScenarios":"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).","commonSituations":"Copying numpy-style 'fill value' calls; assuming other alone implies default masking; API misuse when hand-writing load calls.","solutions":["Provide a mask whenever supplying other: pl.load(ref, mask=m, other=0.0)","Drop other if you do not need masked-lane defaults","Compute an explicit boolean mask from the block indices (e.g. idx < n)"],"exampleFix":"// before\nv = pl.load(ref, other=0.0)\n\n// after\nv = pl.load(ref, mask=idx < n, other=0.0)","handlingStrategy":"validation","validationCode":"if other is not None:\n    assert mask is not None, 'other requires mask: pass mask=idx < n'","typeGuard":"def masked_load_args_ok(mask, other) -> bool:\n    return other is None or mask is not None","tryCatchPattern":"try:\n    v = pl.load(ref, other=fill)\nexcept ValueError:\n    v = pl.load(ref, mask=idx < n, other=fill)","preventionTips":["Always pair other with an explicit boundary mask","Derive masks from block indices (idx < n) at load sites","Write a helper masked_load(ref, idx, n, fill) that enforces the pairing"],"tags":["jax","triton","pallas","load","mask","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}