{"record":{"id":"78c1a6b6ccb8e331","repo":"jax-ml/jax","slug":"base-indices-of-array-slices-must-be-aligned-to-th","errorCode":null,"errorMessage":"Base indices of array slices must be aligned to the beginning of a tile. The array uses a tiling of {base_tile_shape}, but your base indices are {base_idx}. Consider using a different array layout.","messagePattern":"Base indices of array slices must be aligned to the beginning of a tile\\. The array uses a tiling of (.+?), but your base indices are (.+?)\\. Consider using a different array layout\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/fragmented_array.py","lineNumber":2076,"sourceCode":"    if isinstance(self.layout, WGSplatFragLayout):\n      shape = tuple(d for d, s in zip(slice_shape, is_squeezed) if not s)\n      return self.splat(self.registers.item(), shape, is_signed=self.is_signed)\n    if not isinstance(self.layout, TiledLayout):\n      raise NotImplementedError(\"Only arrays with tiled layouts can be sliced\")\n    if any(isinstance(idx, ir.Value) for idx in base_idx):\n      raise ValueError(\"Only slicing with static indices allowed\")\n    base_idx = cast(tuple[int, ...], base_idx)\n    base_tile_shape = self.layout.base_tile_shape\n    untiled_rank = len(self.shape) - len(base_tile_shape)\n    if any(is_squeezed[untiled_rank:]):\n      raise NotImplementedError(\n          \"Integer indexing not implemented for tiled dimensions (only slicing\"\n          \" allowed)\"\n      )\n    if untiled_rank:\n      base_tile_shape = (1,) * untiled_rank + base_tile_shape\n    if any(b % t for b, t in zip(base_idx, base_tile_shape, strict=True)):\n      raise ValueError(\n          \"Base indices of array slices must be aligned to the beginning of a\"\n          f\" tile. The array uses a tiling of {base_tile_shape}, but your base\"\n          f\" indices are {base_idx}. Consider using a different array layout.\"\n      )\n    if any(l % t for l, t in zip(slice_shape, base_tile_shape, strict=True)):\n      raise ValueError(\n          \"The slice shape must be a multiple of the tile shape. The array\"\n          f\" uses a tiling of {base_tile_shape}, but your slice shape is\"\n          f\" {slice_shape}. Consider using a different array layout.\"\n      )\n    register_slices = tuple(\n        b if sq else slice(b // t, (b + l) // t)\n        for b, l, t, sq in zip(\n            base_idx, slice_shape, base_tile_shape, is_squeezed, strict=True\n        )\n    )\n    new_regs = self.registers[register_slices]\n    return FragmentedArray(","sourceCodeStart":2058,"sourceCodeEnd":2094,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/fragmented_array.py#L2058-L2094","documentation":"When slicing a tiled FragmentedArray, every base index must be a multiple of the corresponding tile dimension, otherwise ValueError is raised telling you the tiling and your base indices. Register-level slicing can only select whole tiles.","triggerScenarios":"fa[4:68, :] where dim 0 has tile size 8: 4 % 8 != 0, so the slice start is mid-tile.","commonSituations":"Assuming numpy-style arbitrary-range slicing on tile-blocked fragments, e.g. chunked epilogues with offsets not aligned to the tile shape.","solutions":["Align slice start offsets to multiples of the tile shape (round the start down/up to a tile boundary)","Choose a base_tile_shape that divides your chunk size","Relayout to a tile shape compatible with your slicing pattern via to_layout"],"exampleFix":"# before\nsub = fa[20:52, :]  # tile size 8 -> 20 % 8 != 0\n# after\nsub = fa[24:56, :]  # aligned to tile boundaries of 8","handlingStrategy":"validation","validationCode":"tile = fa.layout.base_tile_shape\nassert all(b % t == 0 for b, t in zip(base_idx, tile)), 'start not tile-aligned'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Round chunk offsets to tile boundaries","Choose tile shapes that divide your iteration granularity"],"tags":["mosaic","gpu","slicing","tile-alignment"],"backgroundTag":"slice-not-tile-aligned","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}