{"record":{"id":"3f2c387225f82b54","repo":"jax-ml/jax","slug":"accumulator-must-be-a-tmem-ref","errorCode":null,"errorMessage":"Accumulator must be a TMEM Ref.","messagePattern":"Accumulator must be a TMEM Ref\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic_gpu/primitives.py","lineNumber":2568,"sourceCode":"\n\n@tcgen05_mma_p.def_effectful_abstract_eval\ndef _tcgen05_mma_abstract_eval(acc, a, b, accumulate,\n                               *barrier_scales_and_transforms_leaves,\n                               acc_transforms_tree, a_transforms_tree,\n                               b_transforms_tree,\n                               barrier_transforms_tree,\n                               a_scale_transforms_tree,\n                               b_scale_transforms_tree,\n                               a_sparse_metadata_transforms_tree,\n                               collective_axis,\n                               arrive,\n                               scaled,\n                               sparse):\n  del accumulate, acc_transforms_tree, a_transforms_tree, b_transforms_tree, barrier_transforms_tree\n\n  if acc.memory_space != gpu_core.TMEM:\n    raise ValueError(\"Accumulator must be a TMEM Ref.\")\n  if a.memory_space not in (gpu_core.SMEM, gpu_core.TMEM):\n    raise ValueError(\"LHS must be a TMEM/SMEM Ref.\")\n  if b.memory_space != gpu_core.SMEM:\n    raise ValueError(\"RHS must be an SMEM Ref.\")\n\n  if collective_axis is not None:\n    # TODO(justinfu): If under a core_map, the avals for acc/a\n    # become normal MemRefs so we cannot check if they are collective.\n    # Figure out a way to fix this.\n    if isinstance(acc, gpu_core.AbstractTMEMRef) and not acc.collective:\n      raise ValueError(\n          \"Accumulator Ref must be collective if collective_axis is set.\")\n    if isinstance(a, gpu_core.AbstractTMEMRef) and not a.collective:\n      raise ValueError(\n          \"LHS Ref must be collective if collective_axis is set.\")\n\n  scales_and_transforms_leaves = barrier_scales_and_transforms_leaves\n  if arrive:","sourceCodeStart":2550,"sourceCodeEnd":2586,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic_gpu/primitives.py#L2550-L2586","documentation":"The tcgen05.mma abstract eval requires the accumulator to live in Tensor Memory (TMEM). Passing an accumulator ref in SMEM or GMEM raises this error.","triggerScenarios":"Allocating the accumulator with pallas.memory_space=SMEM (or plain allocate without memory_space) and passing it as acc to tcgen05.mma.","commonSituations":"Copying an SMEM allocation pattern from dot-operand buffers to the accumulator; forgetting that Blackwell tensor-core accumulators must be TMEM refs.","solutions":["Allocate the accumulator in TMEM: allocate(TMEM, shape, dtype) or mosaic_gpu.TMEM memory space","Keep SMEM only for the A/B operands","Check that the accumulator came from a TMEM scratch specification"],"exampleFix":"# before\nacc = allocate(SMEM, (m, n), jnp.float32)\ntcgen05.mma(a, b, acc, k_dim=k)\n# after\nacc = allocate(TMEM, (m, n), jnp.float32)\ntcgen05.mma(a, b, acc, k_dim=k)","handlingStrategy":"type-guard","validationCode":"from jax._src.pallas.mosaic_gpu import core as gpu_core\nassert acc.memory_space == gpu_core.TMEM","typeGuard":"def is_tmem(ref):\n    return getattr(ref, 'memory_space', None).__class__.__name__ == 'TMEM' or str(getattr(ref, 'memory_space', '')) == 'TMEM'","tryCatchPattern":null,"preventionTips":["Use TMEM allocation only for accumulators","Follow reference kernel allocation patterns"],"tags":["jax","pallas","tcgen05","tmem","memory-space"],"backgroundTag":"gpu-memory-space-validation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}