{"record":{"id":"dae10c4390591a17","repo":"jax-ml/jax","slug":"shape-orig-shape-is-not-a-valid-result-of-applyi","errorCode":null,"errorMessage":"shape {orig_shape} is not a valid result of applying tiling {self}.","messagePattern":"shape (.+?) is not a valid result of applying tiling (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/fragmented_array.py","lineNumber":107,"sourceCode":"  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\n\n  def untile_shape(self, shape: tuple[int, ...]) -> tuple[int, ...]:\n    \"\"\"Computes the shape of an array before tiling from its tiled shape.\"\"\"\n    orig_shape = shape\n    def fail():\n      raise ValueError(\n          f\"shape {orig_shape} is not a valid result of applying tiling {self}.\"\n      )\n    for tile in reversed(self.tiles):\n      if len(tile) > len(shape):\n        fail()\n      untiled_dims = shape[:-2 * len(tile)]\n      tiled_dims = shape[-2 * len(tile):-len(tile)]\n      tiling_dims = shape[-len(tile):]\n      if tiling_dims != tile:\n        fail()\n      shape = (*untiled_dims, *(d * t for d, t in zip(tiled_dims, tile)))\n    return shape\n\n  def canonicalize(self) -> Tiling:\n    \"\"\"Returns a canonicalized version of the tiling.\n\n    We define a tiling to be canonical if, at each step (except the first one,\n    which defines the base tile shape):","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/fragmented_array.py#L89-L125","documentation":"untile_shape inverts tiling: a tiled shape has extra tiled dims inserted; this error fires when the given shape doesn't have room for the tile's dims (len mismatch) or the tiled-dim structure doesn't match the tiling.","triggerScenarios":"Calling untile_shape with a shape that wasn't produced by tile_shape for this tiling — e.g. wrong number of dims for reversed tiles or non-matching dim pairs.","commonSituations":"Round-tripping shapes through layout transformations where an intermediate op changed the shape; mixing layouts between tensors of different shapes.","solutions":["Only call untile_shape with shapes produced by tile_shape under the same Tiling","Verify the tiling instance matches the one used to tile originally","Reconstruct via the layout object rather than manual shape math"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"tiled = tiling.tile_shape(orig_shape)\n# only untile shapes equal to `tiled` for the same tiling","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Round-trip shapes through the same Tiling instance","Avoid manual tiled-shape arithmetic"],"tags":["mosaic","fragmented-array","tiling","shape-mismatch"],"backgroundTag":"shape-not-divisible-by-tile","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}