{"record":{"id":"d24ceccaf360da27","repo":"jax-ml/jax","slug":"ellipsis-can-t-be-used-in-a-compound-factor","errorCode":null,"errorMessage":"Ellipsis can't be used in a compound factor","messagePattern":"Ellipsis can't be used in a compound factor","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning_sharding_rule.py","lineNumber":70,"sourceCode":"\ndef _get_batching_group(factor: str) -> str:\n  \"\"\"Extracts the batching group from a factor for leading batching dimensions.\"\"\"\n  return factor[1:] if len(factor) > 1 else \"0\"\n\nclass CompoundFactor(tuple):\n  \"\"\"Describes the factors for a compound factor.\n\n  A compound factor should contain at least two factors, e.g.\n  * CompoundFactor('b', 'c').\n  \"\"\"\n  def __init__(self, *factors):\n    if len(factors) < 2:\n      raise ValueError(\"A compound factor should contain at least two factors\")\n    for factor in factors:\n      if not isinstance(factor, str):\n        raise ValueError(f\"Each element of CompoundFactor must be a str, but got {type(factor)}\")\n      if _is_batching(factor):\n        raise ValueError(\"Ellipsis can't be used in a compound factor\")\n      else:\n        _check_factor(factor)\n\n  def __new__(cls, *factors):\n    return tuple.__new__(CompoundFactor, factors)\n\n\nclass ArrayMapping(tuple):\n  \"\"\"Describes the factors for an operand or result.\n\n  Each element is either a factor or a CompoundFactor. A leading element can\n  also be BATCHING, which represents batching dimensions. examples:\n  * ArrayMapping('a')\n  * ArrayMapping('b', 'c')\n  * ArrayMapping(CompoundFactor('b', 'c'), 'd')\n  * ArrayMapping(BATCHING, CompoundFactor('b', 'c'), 'd')\n  \"\"\"\n  def __init__(self, *dim_mappings):","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning_sharding_rule.py#L52-L88","documentation":"Ellipsis ('...'/batching notation) cannot appear inside a CompoundFactor, because compound factors map to concrete factor groups on one dimension. Using a batching factor there raises ValueError.","triggerScenarios":"CompoundFactor('...', 'b') or CompoundFactor('...0', 'c') while writing an SdyShardingRule.","commonSituations":"Trying to express 'leading dims plus factors' inside one compound token instead of at the mapping's leading position.","solutions":["Place ellipsis/batching at the start of the ArrayMapping: ArrayMapping('...', CompoundFactor('b','c'))","Remove ellipsis from CompoundFactor elements","Use the BATCHING constant at position 0 of the ArrayMapping"],"exampleFix":"# before\nArrayMapping(CompoundFactor('...', 'b'), 'i')\n\n# after\nArrayMapping(BATCHING, CompoundFactor('b', 'c'), 'i')","handlingStrategy":"validation","validationCode":"def no_ellipsis(factors):\n    return all(not f.startswith('...') for f in factors)\nassert no_ellipsis(factors)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Put BATCHING/'...' only at index 0 of ArrayMapping","Flatten nested compounds into strings"],"tags":["jax","shardy","sharding-rule","ellipsis"],"backgroundTag":"invalid-sharding-rule-config","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}