{"record":{"id":"cbd56acb20bf82d0","repo":"jax-ml/jax","slug":"commuting-a-untilingtransform-with-a-reshapetra-cbd56a","errorCode":null,"errorMessage":"Commuting a `UntilingTransform` with a `ReshapeTransform` is not supported when the tiling is empty","messagePattern":"Commuting a `UntilingTransform` with a `ReshapeTransform` is not supported when the tiling is empty","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic_gpu/core.py","lineNumber":861,"sourceCode":"        *(a // b for a, b in zip(untiled_shape, self.tiling)),\n        *self.tiling,\n    ]\n    new_indexer = indexing.NDIndexer.from_indices_shape(\n        indices=(*untiled_idxs, *idxs_after_tiling),\n        shape=(*leading_shape, *tiled_shape)\n    )\n    return new_indexer, self\n\n  def commute_reshape(\n      self, aval: jax_core.ShapedArray, transform: state_types.ReshapeTransform\n  ) -> tuple[state_types.ReshapeTransform, UntilingTransform]:\n    if not transform.shape:\n      raise NotImplementedError(\n          \"Commuting a `UntilingTransform` with a `ReshapeTransform` is not \"\n          \"supported when the target shape has 0 dimensions\"\n      )\n    if not self.tiling:\n      raise NotImplementedError(\n          \"Commuting a `UntilingTransform` with a `ReshapeTransform` is not \"\n          \"supported when the tiling is empty\"\n      )\n    untiled_aval = self.transform_type(aval)\n    assert isinstance(untiled_aval, jax_core.ShapedArray)\n    components = [[]]\n    # We assume that we support only folds here for the moment. Therefore, we\n    # can gather a number of consecutive dimensions such that their product\n    # equals the dimension currently being processed in the reshaped shape.\n    for d in untiled_aval.shape:\n      reshaped_dim_size = transform.shape[len(components) - 1]\n      components[-1].append(d)\n      component_size = math.prod(components[-1])\n      if component_size == reshaped_dim_size:\n        components.append([])\n      elif component_size > reshaped_dim_size:\n        raise NotImplementedError(\n            \"Unfolding dimensions is not supported when commuting an \"","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic_gpu/core.py#L843-L879","documentation":"Raised when commuting an UntilingTransform with a ReshapeTransform while the untiling's tiling tuple is empty. An empty tiling means there is nothing to untile, so the commutation algorithm has no dimensions to redistribute across the reshape and bails out.","triggerScenarios":"commute_reshape invoked with self.tiling == () — an UntilingTransform constructed with an empty tiling tuple, typically via pallas_core.untile or an internal pipeline pass.","commonSituations":"Programmatically building transform stacks (e.g. custom lowering or transforms applied to non-tiled refs) that accidentally create UntilingTransform(()) instead of skipping the transform.","solutions":["Don't construct UntilingTransform with an empty tiling; skip adding it when tiling is ()","Check ref.transforms and drop no-op untile transforms before reshaping","Update JAX — empty-tiling transforms may indicate a stale pipeline bug; report upstream if produced internally"],"exampleFix":"// before\ntransforms = (*ref.transforms, UntilingTransform(()))\n\n// after\ntransforms = tuple(t for t in ref.transforms if getattr(t, 'tiling', None))","handlingStrategy":"validation","validationCode":"assert untile.tiling, 'empty tiling: skip the UntilingTransform instead'","typeGuard":"def is_valid_untile(t): return isinstance(t, UntilingTransform) and bool(t.tiling)","tryCatchPattern":null,"preventionTips":["Filter no-op transforms out of transform stacks before reshaping"],"tags":["jax","pallas","mosaic-gpu","tiling","transforms"],"backgroundTag":"unsupported-transform-commutation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}