{"record":{"id":"08ecfd77e42ba8f2","repo":"jax-ml/jax","slug":"ellipsis-can-only-be-used-at-the-beginning-of-a-di","errorCode":null,"errorMessage":"Ellipsis can only be used at the beginning of a dimension","messagePattern":"Ellipsis can only be used at the beginning of a dimension","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning_sharding_rule.py","lineNumber":97,"sourceCode":"  \"\"\"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):\n    for i, d in enumerate(dim_mappings):\n      if not isinstance(d, str) and not isinstance(d, CompoundFactor):\n        raise ValueError(\n            \"Each element of ArrayMapping must be a str or CompoundFactor, but\"\n            f\" got {type(d)}\")\n      if isinstance(d, str):\n        if _is_batching(d):\n          if i != 0:\n            raise ValueError(\"Ellipsis can only be used at the beginning of a dimension\")\n        else:\n          _check_factor(d)\n\n  def __new__(cls, *dim_mappings):\n    return tuple.__new__(ArrayMapping, dim_mappings)\n\n\nclass SdyShardingRule:\n  \"\"\"Represents a Shardy sharding rule.\n\n  An SdyShardingRule contains the ArrayMappings for operands and results,\n  optional special factors and optional factor sizes. A factor is a name used in\n  the ArrayMappings. If a factor is only used in CompoundFactors, its size must\n  be specified.\n\n  By default, a factor is a passthrough factor. Keyword arguments can be used to\n  specify other factor kinds including reduction_factors, need_replication_factors,\n  and permutation_factors.","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning_sharding_rule.py#L79-L115","documentation":"In ArrayMapping, ellipsis/batching notation is only allowed as the first element (mapping the leading batch dimensions). Using it at any later position raises ValueError.","triggerScenarios":"ArrayMapping('i', '...', 'j') or ArrayMapping('i', '...0'), i.e. ellipsis anywhere but index 0.","commonSituations":"Attempting to represent trailing variable-rank dims with '...' at the end of a mapping; misunderstanding that batching dims are leading only.","solutions":["Move the ellipsis/BATCHING token to the first position of the ArrayMapping","For trailing dims, enumerate explicit factor names instead of ellipsis","Re-express the rule so variable-rank dims are leading (transpose the problem)"],"exampleFix":"# before\nArrayMapping('i', '...')\n\n# after\nArrayMapping('...', 'i')","handlingStrategy":"validation","validationCode":"def valid_ellipsis_pos(ms):\n    return all(not str(m).startswith('...') for m in ms[1:])\nassert valid_ellipsis_pos(dim_mappings)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember batching dims are leading-only; restructure rules so '...' comes first"],"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"}