jax-ml/jax · error · ValueError
Ellipsis can't be used in a compound factor
Error message
Ellipsis can't be used in a compound factor
What it means
ArrayMapping rejects the ellipsis placeholder inside a CompoundFactor: '...' (representing batching dims) is only allowed as a standalone leading element of a dimension mapping, never as a member of a parenthesized compound factor.
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
Example fix
# before
ArrayMapping(CompoundFactor('...', 'b'), 'i')
# after
ArrayMapping(BATCHING, CompoundFactor('b', 'c'), 'i') Defensive patterns
Strategy: validation
Validate before calling
def no_ellipsis(factors):
return all(not f.startswith('...') for f in factors)
assert no_ellipsis(factors) Prevention
- Put BATCHING/'...' only at index 0 of ArrayMapping
- Flatten nested compounds into strings
When it happens
Trigger: CompoundFactor('...', 'b') or CompoundFactor('...0', 'c') while writing an SdyShardingRule.
Common situations: Trying to express 'leading dims plus factors' inside one compound token instead of at the mapping's leading position.
Related errors
- Ellipsis can only be used at the beginning of a dimension
- A compound factor should contain at least two factors
- Each element of ArrayMapping must be a str or…
- Each element of CompoundFactor must be a str, but got
- Factor names have to start with a letter, but got
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/d24ceccaf360da27.
Report an issue: GitHub.
Appendix: source
Thrown at jax/_src/custom_partitioning_sharding_rule.py:70
def _get_batching_group(factor: str) -> str:
"""Extracts the batching group from a factor for leading batching dimensions."""
return factor[1:] if len(factor) > 1 else "0"
class CompoundFactor(tuple):
"""Describes the factors for a compound factor.
A compound factor should contain at least two factors, e.g.
* CompoundFactor('b', 'c').
"""
def __init__(self, *factors):
if len(factors) < 2:
raise ValueError("A compound factor should contain at least two factors")
for factor in factors:
if not isinstance(factor, str):
raise ValueError(f"Each element of CompoundFactor must be a str, but got {type(factor)}")
if _is_batching(factor):
raise ValueError("Ellipsis can't be used in a compound factor")
else:
_check_factor(factor)
def __new__(cls, *factors):
return tuple.__new__(CompoundFactor, factors)
class ArrayMapping(tuple):
"""Describes the factors for an operand or result.
Each element is either a factor or a CompoundFactor. A leading element can
also be BATCHING, which represents batching dimensions. examples:
* ArrayMapping('a')
* ArrayMapping('b', 'c')
* ArrayMapping(CompoundFactor('b', 'c'), 'd')
* ArrayMapping(BATCHING, CompoundFactor('b', 'c'), 'd')
"""
def __init__(self, *dim_mappings):View on GitHub (pinned to 1e1c6a8fc0)