{"record":{"id":"5f235310a2ce1fb9","repo":"jax-ml/jax","slug":"strides-strides-have-lower-rank-than-tiling-til","errorCode":null,"errorMessage":"Strides {strides} have lower rank than tiling {tiling}","messagePattern":"Strides (.+?) have lower rank than tiling (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/experimental/mosaic/gpu/dialect_lowering.py","lineNumber":1028,"sourceCode":"      *[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`.\n\n  The `len(tiling)` trailing strides in `strides` must be the `len(tiling)`\n  smallest strides in `strides`. The same property holds in the result, i.e.,\n  given two tiles with indices i and j (i < j) with strides tiled according to\n  this function, then all the elements in tile i are physically ordered before\n  all the elements in tile j.\n\n  E.g., tile_strides((2048, 32, 1), (8, 4)) = (2048, 256, 32, 4, 1)\n  \"\"\"\n  if len(strides) < len(tiling):\n    raise ValueError(f\"Strides {strides} have lower rank than tiling {tiling}\")\n  ordered_strides = sorted(strides, reverse=True)\n  if set(ordered_strides[-len(tiling):]) != set(strides[-len(tiling):]):\n    raise ValueError(\n        \"Can not tile strides when tiled dimensions have been transposed with \"\n        f\"untiled dimensions. Strides: {strides}, tiling: {tiling}\"\n    )\n  untiled_strides, tiled_strides = strides[:-len(tiling)], strides[-len(tiling):]\n\n  # Zip the strides and tiling together, in order to sort them together. This\n  # allows handling cases where multiple tiling dimensions have the same stride,\n  # which can occur with size-1 dimensions.\n  tiled_strides_and_tiling: list[tuple[int, int]] = list(\n      zip(tiled_strides, tiling, strict=True))\n  tiled_ordered_strides_and_tiling = sorted(\n      tiled_strides_and_tiling, reverse=True)\n\n  to_ordered = lambda i: tiled_ordered_strides_and_tiling.index(tiled_strides_and_tiling[i])\n  from_ordered = lambda i: tiled_strides_and_tiling.index(tiled_ordered_strides_and_tiling[i])","sourceCodeStart":1010,"sourceCodeEnd":1046,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/experimental/mosaic/gpu/dialect_lowering.py#L1010-L1046","documentation":"tile_strides tiles the trailing strides of a memref; the strides tuple must have rank >= tiling rank, otherwise the tiling is undefined.","triggerScenarios":"Computing tile_strides(strides, tiling) with len(strides) < len(tiling), typically from a memref layout whose rank is smaller than the tile dims.","commonSituations":"Applying a 2D tile transform to a 1D memref, or a strides/tiling rank mismatch when constructing transform_type.","solutions":["Match tiling rank to memref rank (len(strides))","Pass a full-rank strides array derived from the memref layout"],"exampleFix":"// before\ntile_strides((1,), (8, 4))\n// after\ntile_strides((4, 1), (8, 4))","handlingStrategy":"validation","validationCode":"assert len(strides) >= len(tiling), 'strides rank must cover tiling rank'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match tile rank to memref rank"],"tags":["jax","mosaic","gpu","tiling","strides","rank-mismatch"],"backgroundTag":"shape-rank-mismatch","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}