{"record":{"id":"6122ba639b3ec7f1","repo":"jax-ml/jax","slug":"other-cannot-be-a-block-if-pointer-is-not-a-block","errorCode":null,"errorMessage":"other cannot be a block if pointer is not a block","messagePattern":"other cannot be a block if pointer is not a block","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/triton/lowering.py","lineNumber":2048,"sourceCode":"    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)\n\n  result = tt_dialect.load(\n      ptr,","sourceCodeStart":2030,"sourceCodeEnd":2066,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/triton/lowering.py#L2030-L2066","documentation":"When the loaded pointer is NOT a block (not a RankedTensorType), the load is a scalar load; supplying an `other` value that IS a block (tensor) is then shape-inconsistent and rejected before emitting tt.load.","triggerScenarios":"Scalar pointer load combined with a tensor-typed other value, e.g. loading a single element with other=jnp.zeros(block_shape) inside a Triton Pallas kernel.","commonSituations":"Reusing a block-shaped default value from another load site in a scalar context; copy-paste of masked load scaffolding into scalar loads.","solutions":["Make other a scalar matching the pointee type when the pointer is scalar","Or make the load a proper block load (mask + block-shaped pointer) if you want vector semantics","Remove other for unmasked scalar loads"],"exampleFix":"// before\nv = pl.load(scalar_ref, mask=m, other=jnp.zeros((B,)))\n\n// after\nv = pl.load(scalar_ref, mask=m, other=0.0)","handlingStrategy":"validation","validationCode":"import numpy as np\ndef check_scalar_load(ptr_is_block, other):\n    if not ptr_is_block and other is not None:\n        assert not hasattr(other, 'shape') or np.ndim(other) == 0, 'other must be scalar for scalar loads'","typeGuard":"def other_matches_pointer(ptr_is_block: bool, other) -> bool:\n    if other is None:\n        return True\n    other_is_block = getattr(other, 'shape', ()) != ()\n    return ptr_is_block or not other_is_block","tryCatchPattern":"try:\n    v = pl.load(ref, mask=m, other=fill)\nexcept ValueError:\n    v = pl.load(ref, mask=m, other=float(fill))  # scalarize","preventionTips":["Match other's rank to the load's pointer rank","Use scalar fill values for scalar loads","Don't reuse block-shaped defaults across load sites"],"tags":["jax","triton","pallas","load","shape","validation"],"backgroundTag":"argument-shape-mismatch","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}