jax-ml/jax · error · ValueError
Constraint parsing error: must contain one of '==' or '>=' o
Error message
Constraint parsing error: must contain one of '==' or '>=' or '<='
What it means
A constraint string must contain exactly one of the comparison tokens '==', '>=' or '<='. If none of these substrings is found, the parser cannot split it into two sides and raises ValueError.
Source
Thrown at jax/_src/export/shape_poly.py:1054
if self._explicit_constraints:
extras.append(" with constraints:")
for constr in self._explicit_constraints:
extras.append(f" {constr.debug_str}")
loc = source_info_util._summarize_frame(self._location_frame) if self._location_frame else "unknown"
return f"{id(self)} created at {loc}" + "\n".join(extras)
__repr__ = __str__
def _parse_and_process_explicit_constraint(self, c_str: str):
if not isinstance(c_str, str):
raise ValueError(
f"SymbolicScope constraint must be a string: got {repr(c_str)}")
cmp_pos, cmp, is_geq = c_str.find("=="), Comparator.EQ, True
if cmp_pos < 0:
cmp_pos, cmp, is_geq = c_str.find(">="), Comparator.GEQ, True
if cmp_pos < 0:
cmp_pos, cmp, is_geq = c_str.find("<="), Comparator.GEQ, False
if cmp_pos < 0:
raise ValueError("Constraint parsing error: must contain one of '==' or '>=' or '<='")
e1_str = c_str[:cmp_pos]
e1, = _Parser(e1_str, None, repr(e1_str), self).parse()
e2_str = c_str[cmp_pos + 2:]
e2, = _Parser(e2_str, None, repr(e2_str), self).parse()
if cmp == Comparator.GEQ and not is_geq:
e1, e2 = e2, e1
# Compute e1 - e2 before we add to normalization rules
constr = _SymbolicConstraint(debug_str=c_str, cmp=cmp, e1=e1, e2=e2,
diff=e1 - e2)
self._process_explicit_constraint(constr)
def _process_explicit_constraint(self, constr: _SymbolicConstraint):
if (diff_const := _DimExpr._to_constant(constr.diff)) is not None:
if ((constr.cmp == Comparator.EQ and diff_const != 0) or
(constr.cmp == Comparator.GEQ and diff_const < 0)):
raise ValueError(f"Unsatisfiable explicit constraint: {constr.debug_str}")
returnView on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Use only '==', '>=', '<=' in constraint strings; rewrite 'n > 4' as 'n >= 5' for integers
- Fix typos ('=>' -> '>=', '=' -> '==')
- Validate each constraint contains a supported token before constructing the scope
Example fix
# before
constraints = ('n > 4',)
# after
constraints = ('n >= 5',) # strict inequalities not supported Defensive patterns
Strategy: validation
Validate before calling
import re assert all(re.search(r'(==|>=|<=)', c) for c in constraints), 'need ==, >=, or <='
Type guard
def well_formed_constraint(c: str) -> bool:
return isinstance(c, str) and any(t in c for t in ('==','>=','<=')) Prevention
- Remember strict > and < are unsupported; use >= / <=
- Automate the comparator check in test fixtures
When it happens
Trigger: Constraints like 'n > 4' (strict inequality, unsupported), 'n = 4', 'n 4', or 'max(n, 4)' with no comparator.
Common situations: Typos in constraint strings; assuming strict > or < is supported (only >=/<=/== are); copying Python syntax like 'n != 4'.
Related errors
- The symbolic constraints should be a sequence of strings. Go
- SymbolicScope constraint must be a string: got {repr(c_str)}
- Unsatisfiable explicit constraint: {constr.debug_str}
- Invalid equality constraint: {e1} == {e2}. The left-hand-sid
- Found multiple equality constraints with the same left-hand-
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/e7dd1d7def552f78.
Report an issue: GitHub.