{"record":{"id":"ec2488b4a20dd9d5","repo":"jax-ml/jax","slug":"the-slice-shape-must-be-a-multiple-of-the-tile-sha","errorCode":null,"errorMessage":"The slice shape must be a multiple of the tile shape. The array uses a tiling of {base_tile_shape}, but your slice shape is {slice_shape}. Consider using a different array layout.","messagePattern":"The slice shape must be a multiple of the tile shape\\. The array uses a tiling of (.+?), but your slice shape is (.+?)\\. Consider using a different array layout\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/fragmented_array.py","lineNumber":2082,"sourceCode":"      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(\n        _registers=new_regs, _layout=self.layout, _is_signed=self.is_signed\n    )\n\n  def __setitem__(self, idx: object, value: FragmentedArray) -> None:\n    if not isinstance(value, FragmentedArray):\n      raise ValueError(f\"Expected a FragmentedArray, got: {value}\")","sourceCodeStart":2064,"sourceCodeEnd":2100,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/fragmented_array.py#L2064-L2100","documentation":"Slicing a tiled FragmentedArray requires the slice length in each dimension to be a multiple of that dimension's tile size; otherwise ValueError reports the tiling vs your slice shape. Partial tiles cannot be represented in the register layout.","triggerScenarios":"fa[0:100, :] where dim 0 tile size is 8: 100 % 8 != 0, so the slice shape is not tile-aligned.","commonSituations":"Splitting work into chunk sizes (e.g. 100) that don't divide evenly by the tile shape chosen for the layout (e.g. 8).","solutions":["Round the slice extent to a multiple of the tile shape (pad if needed and mask overflow)","Pick a tile shape that divides your chunk/problem sizes","Slice at whole-tile granularity: shape divisible by base_tile_shape in every dim"],"exampleFix":"# before\nsub = fa[0:100, :]  # tile 8 -> 100 % 8 != 0\n# after\nsub = fa[0:104, :]  # 104 = 13*8, mask/pad the extra 4 rows downstream","handlingStrategy":"validation","validationCode":"tile = fa.layout.base_tile_shape\nassert all(l % t == 0 for l, t in zip(slice_shape, tile)), 'extent not tile-aligned'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make chunk sizes multiples of tile shapes (pad and mask)","Pick tile shapes dividing the problem size"],"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"}