pytorch/pytorch · error · ValueError
'{_ellipsis}' is not an allowed axis identifier
Error message
'{_ellipsis}' is not an allowed axis identifier What it means
Thrown in functorch/einops `_parsing.py` when the user-supplied `axes_lengths` mapping contains the ellipsis symbol (`'…'`, or `'...'` converted during parsing) as a key. The ellipsis stands for 'all remaining axes' and cannot be assigned a fixed length.
Source
Thrown at functorch/einops/_parsing.py:230
) -> tuple[ParsedExpression, ParsedExpression]:
"""Parse an `einops`-style pattern into a left-hand side and right-hand side `ParsedExpression` object.
Args:
pattern (str): the `einops`-style rearrangement pattern
axes_lengths (Mapping[str, int]): any additional length specifications for dimensions
Returns:
tuple[ParsedExpression, ParsedExpression]: a tuple containing the left-hand side and right-hand side expressions
"""
# adapted from einops.einops._prepare_transformation_recipe
# https://github.com/arogozhnikov/einops/blob/230ac1526c1f42c9e1f7373912c7f8047496df11/einops/einops.py
try:
left_str, right_str = pattern.split("->")
except ValueError:
raise ValueError("Pattern must contain a single '->' separator") from None
if _ellipsis in axes_lengths:
raise ValueError(f"'{_ellipsis}' is not an allowed axis identifier")
left = ParsedExpression(left_str)
right = ParsedExpression(right_str)
if not left.has_ellipsis and right.has_ellipsis:
raise ValueError(
f"Ellipsis found in right side, but not left side of a pattern {pattern}"
)
if left.has_ellipsis and left.has_ellipsis_parenthesized:
raise ValueError(
f"Ellipsis is parenthesis in the left side is not allowed: {pattern}"
)
return left, right
def validate_rearrange_expressions(
left: ParsedExpression, right: ParsedExpression, axes_lengths: Mapping[str, int]View on GitHub (pinned to dcd2ecae77)
Solutions
- Remove the ellipsis entry from `axes_lengths`
- If you need to fix the number of remaining axes, name them explicitly in the pattern instead of using `...`
Example fix
# before
y = rearrange(x, '... h -> h', **{'...': 3})
# after
y = rearrange(x, 'b c h -> h') # name the axes explicitly Defensive patterns
Strategy: validation
Validate before calling
_ELLIPSIS = "\u2026"
def axes_lengths_ok(axes_lengths) -> bool:
return _ELLIPSIS not in axes_lengths and "..." not in axes_lengths Prevention
- Never put '...' or '…' in axes_lengths; the ellipsis is a wildcard
- Name axes explicitly when you need fixed lengths
When it happens
Trigger: Calling `rearrange(t, '... h -> h', **{'...': 3})` or otherwise passing an ellipsis key/keyword in the length specification.
Common situations: Programmatically forwarding a config dict of axis lengths that includes a placeholder for the ellipsis; misunderstanding that `...` is a wildcard, not a nameable axis.
Related errors
- Expression may contain dots only inside ellipsis (...)
- Expression may contain dots only inside ellipsis (...); only
- Ellipsis found in right side, but not left side of a pattern
- Ellipsis is parenthesis in the left side is not allowed: {pa
- Anonymous axis should have positive length, not {self.value}
AI-assisted analysis of pytorch/pytorch@dcd2ecae77 (2026-08-14).
Data as JSON: /api/errors/5ebbed70e2cd6ad5.
Report an issue: GitHub.