{"record":{"id":"a84f9419c502aa4d","repo":"jax-ml/jax","slug":"unsupported-block-shape-type-type-dim","errorCode":null,"errorMessage":"Unsupported block shape type: {type(dim)}","messagePattern":"Unsupported block shape type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/core.py","lineNumber":486,"sourceCode":"\ndef _canonicalize_block_shape(block_shape: Sequence[BlockDim | int | None]\n                              ) -> tuple[BlockDim, ...]:\n  return tuple(_canonicalize_block_dim(dim) for dim in block_shape)\n\n\ndef _get_block_dim_size(dim: BlockDim) -> int:\n  match dim:\n    case Squeezed():\n      return 1\n    case (\n        Blocked(block_size)\n        | Element(block_size)\n        | BoundedSlice(block_size)\n        | Indirect(block_size)\n    ):\n      return block_size\n    case _:\n      raise ValueError(f\"Unsupported block shape type: {type(dim)}\")\n\ndef get_block_size(dim: BlockDim | int | None) -> int:\n  match dim:\n    case int():\n      return dim\n    case Squeezed() | None:\n      return 1\n    case (\n        Blocked(block_size)\n        | Element(block_size)\n        | BoundedSlice(block_size)\n        | Indirect(block_size)\n    ):\n      return block_size\n    case _:\n      raise ValueError(f\"Unsupported block shape type: {type(dim)}\")\n\n","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/core.py#L468-L504","documentation":"Internal helper _get_block_dim_size extracts the size from a BlockDim via match: Squeezed/None -> 0, Blocked/Element/BoundedSlice/Indirect -> their block_size, plain int -> itself. Any other type falls to the wildcard case and raises this ValueError.","triggerScenarios":"Passing a custom or malformed object inside a canonicalized block_shape — typically from constructing BlockSpec with non-standard dims or from internal code paths (_get_block_shape, has_trivial_window, triton lowering) receiving corrupted block specs.","commonSituations":"Subclassing or monkey-patching BlockDim types; JAX internal version mismatches; feeding block shapes built by older/newer pallas APIs.","solutions":["Ensure every entry of block_shape is int, None, Blocked, Squeezed, Element, BoundedSlice, or Indirect from the same JAX version","Don't create custom block-dim classes; express custom tiling with index_map instead","Reinstall/align JAX versions if the values come from library internals"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from jax._src.pallas import core as pcore\nallowed = (int, type(None), pcore.Blocked, pcore.Squeezed, pcore.Element,\n           pcore.BoundedSlice, pcore.Indirect)\nassert all(isinstance(d, allowed) for d in block_shape)","typeGuard":"def is_valid_block_shape(shape):\n    return all(d is None or isinstance(d, (int, Blocked, Squeezed, Element, BoundedSlice, Indirect)) for d in shape)","tryCatchPattern":null,"preventionTips":["Canonicalize block shapes via the public helpers before transforms","Avoid custom block-dim classes"],"tags":["jax","pallas","block-spec","internal"],"backgroundTag":"invalid-type-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}