{"record":{"id":"4fe07b158795c5b6","repo":"jax-ml/jax","slug":"offsets-offsets-have-lower-rank-than-tiling-til","errorCode":null,"errorMessage":"Offsets {offsets} have lower rank than tiling {tiling}","messagePattern":"Offsets (.+?) have lower rank than tiling (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/dialect_lowering.py","lineNumber":999,"sourceCode":"  gmem_transforms: list[lc.MemRefTransform] = []\n  for transform in attr:\n    if isinstance(transform, mgpu.TileTransformAttr):\n      tile_transform = lc.TileTransform(tuple(transform.tiling))\n      gmem_transforms.append(tile_transform)\n    elif not isinstance(transform, mgpu.SwizzleTransformAttr):\n      raise NotImplementedError(f\"Unsupported transform: {transform}\")\n  return tuple(gmem_transforms)\n\n\ndef tile_offset(\n    offsets: tuple[int, ...], tiling: tuple[int, ...]\n) -> tuple[int, ...]:\n  \"\"\"Tiles the trailing offsets in `offsets` according to `tiling`.\n\n  Raises if the offsets are not aligned with the start of a tile.\n  \"\"\"\n  if len(offsets) < len(tiling):\n    raise ValueError(f\"Offsets {offsets} have lower rank than tiling {tiling}\")\n  untiled_offsets, tiled_offsets = (\n      offsets[: -len(tiling)],\n      offsets[-len(tiling) :],\n  )\n  for i, t in zip(tiled_offsets, tiling, strict=True):\n    if i % t != 0:\n      raise ValueError(f\"Offset {i} is not divisible by tile size {t}\")\n  return (\n      *untiled_offsets,\n      *[i // t for i, t in zip(tiled_offsets, tiling, strict=True)],\n      *[0] * len(tiling),\n  )\n\n\ndef tile_strides(\n    strides: tuple[int, ...], tiling: tuple[int, ...]\n) -> tuple[int, ...]:\n  \"\"\"Tiles the trailing strides in `strides` according to `tiling`.","sourceCodeStart":981,"sourceCodeEnd":1017,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/dialect_lowering.py#L981-L1017","documentation":"tile_offset applies a tiling to the trailing dimensions of an offsets tuple; the offsets rank must be >= the tiling rank or tiling is undefined.","triggerScenarios":"Computing tile_offset(offsets, tiling) with fewer offsets than tiling dims (e.g. offsets=(4,) with tiling=(8,4)) via transform_type on a mis-shaped layout.","commonSituations":"Constructing tiled memref transforms where the tiling rank exceeds the memref rank, or passing a scalar offset for a 2D tile.","solutions":["Make len(offsets) >= len(tiling); give a full-rank offset tuple","Reduce the tiling rank to match the memref rank"],"exampleFix":"// before\ntile_offset((4,), (8, 4))\n// after\ntile_offset((0, 4), (8, 4))","handlingStrategy":"validation","validationCode":"assert len(offsets) >= len(tiling), 'offsets rank must cover tiling rank'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass full-rank offset/tiling tuples matching the memref rank"],"tags":["jax","mosaic","gpu","tiling","offsets","rank-mismatch"],"backgroundTag":"shape-rank-mismatch","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}