jax-ml/jax · error · ValueError

There is no -> in rule: '{rule}'

Error message

There is no -> in rule: '{rule}'

What it means

The rule must separate operands from results with '->'. rule.split('->') raises ValueError when no arrow is present, which is re-raised with this message.

Source

Thrown at jax/_src/custom_partitioning_sharding_rule.py:352

  """
  if not isinstance(rule, str):
    raise TypeError(f"rule must be a str, but got {type(rule)}")
  if not all(isinstance(size, int) for size in factor_sizes.values()):
    raise TypeError(
        f"factor_sizes must be a dict of str to int, but got {factor_sizes}")

  # Replace ... with a single char to simplify parsing.
  if BATCHING in rule:
    raise ValueError(f"Unknown character '{BATCHING}'")
  if "." in rule:
    rule = rule.replace("...", BATCHING)
    if "." in rule:
      raise ValueError("Character '.' must be used inside ellipsis '...'")

  try:
    operands, results = rule.split("->")
  except ValueError as e:
    raise ValueError(f"There is no -> in rule: '{rule}'") from e

  operand_mappings = _parse_values(operands)
  result_mappings = _parse_values(results)
  return SdyShardingRule(operand_mappings, result_mappings,
                         reduction_factors=reduction_factors,
                         need_replication_factors=need_replication_factors,
                         permutation_factors=permutation_factors,
                         **factor_sizes)


def sdy_sharding_rule_to_mlir(
  rule: SdyShardingRule,
  operand_types: list[ir.Type],
  result_types: list[ir.Type],) -> ir.Attribute:
  """Builds the MLIR representation for the sharding rule.

  This is done by verifying that the rule is consistent with the types of
  the operation and converting the Einsum notation like string to

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Add exactly one '->' between operands and results, e.g. 'ij,jk->ik'
  2. Verify rule.count('->') == 1 before calling

Example fix

# before
rule = 'ij,jk'
# after
rule = 'ij,jk->ik'
Defensive patterns

Strategy: validation

Validate before calling

assert rule.count('->') == 1, "rule needs exactly one '->'"

Type guard

def has_single_arrow(rule: str) -> bool:
    return rule.count('->') == 1

Prevention

When it happens

Trigger: Passing rule='ij' (no arrow) or using '=' / ':' instead of '->'.

Common situations: Also fires with multiple '->' (split yields >2 parts); adapting einsum strings that use '->' but dropping it during edits.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/ffef664840c83caf. Report an issue: GitHub.