{"record":{"id":"49beda68a94bb87c","repo":"jax-ml/jax","slug":"tile-shape-must-only-have-positive-sizes-got-se","errorCode":null,"errorMessage":"Tile shape must only have positive sizes, got: {self.tiles}","messagePattern":"Tile shape must only have positive sizes, got: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/fragmented_array.py","lineNumber":83,"sourceCode":"\n  This expression describes multi-level tiling, by applying each element of\n  `tiles` in sequence to the array.\n\n  See https://openxla.org/xla/tiled_layout for a more detailed explanation.\n  \"\"\"\n  tiles: tuple[tuple[int, ...], ...]\n\n  def __post_init__(self):\n    if not self.tiles:\n      return\n    last_tile_rank = len(self.tiles[0])\n    for tile in self.tiles:\n      if len(tile) > last_tile_rank:\n        raise ValueError(\"Tiles must have a decreasing rank\")\n      if not tile:\n        raise ValueError(\"Tiles must not be empty\")\n      if any(d <= 0 for d in tile):\n        raise ValueError(f\"Tile shape must only have positive sizes, got: {self.tiles}\")\n      last_tile_rank = len(tile)\n\n  def __str__(self):\n    return f\"Tiling({''.join(map(str, self.tiles))})\"\n\n  def tile_shape(self, shape: tuple[int, ...]) -> tuple[int, ...]:\n    \"\"\"Computes the shape of an array after tiling.\"\"\"\n    orig_shape = shape\n    def fail():\n      raise ValueError(f\"Tiling {self.tiles} does not apply to shape {orig_shape}\")\n    for tile in self.tiles:\n      if len(tile) > len(shape):\n        fail()\n      untiled_dims, tiled_dims = shape[:-len(tile)], shape[-len(tile):]\n      if any(s % t != 0 for s, t in zip(tiled_dims, tile)):\n        fail()\n      shape = (*untiled_dims, *(d // t for d, t in zip(tiled_dims, tile)), *tile)\n    return shape","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/fragmented_array.py#L65-L101","documentation":"Every dimension size in every tile of a Tiling must be a positive integer; a 0 or negative size makes the tiling meaningless and is rejected.","triggerScenarios":"Tiling with a tile like (0, 8) or (-1, 64) — usually from arithmetic that computed a zero/negative tile dim (e.g. shape // something == 0).","commonSituations":"Deriving tile sizes from runtime parameters where a dimension is smaller than expected, producing 0; bad defaults in layout helpers.","solutions":["Check the computed tile dims for <=0 before building the Tiling","Ensure the tile divides the array dims and the base shape is large enough","Use validated constructors from fa.TiledLayout which clamp/validate"],"exampleFix":"// before\nTiling([(shape[0] // k, shape[1])])  # shape[0]//k == 0\n// after\nassert shape[0] // k > 0, 'tile dim must be positive'\nTiling([(shape[0] // k, shape[1])])","handlingStrategy":"validation","validationCode":"assert all(d > 0 for t in tiles for d in t), 'tile dims must be positive'","typeGuard":"def all_tile_dims_positive(tiles) -> bool:\n    return all(d > 0 for t in tiles for d in t)","tryCatchPattern":null,"preventionTips":["Validate computed tile dims against the source shape before building layouts"],"tags":["mosaic","fragmented-array","tiling","validation"],"backgroundTag":"invalid-layout-spec","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}