jax-ml/jax · error · TypeError
argument of ManualAxisType should of type `frozenset` or…
Error message
{name} argument of ManualAxisType should of type `frozenset` or `set`. Got type {type(val)} What it means
Validation inside the ManualAxisType construction path of _check_mat: the named set (e.g. varying, unreduced, or reduced) must be a frozenset or set of mesh axes. Passing a list, tuple, or other iterable of axes trips this guard.
Solutions
- Wrap in set()/frozenset(): ManualAxisType(varying={'x','y'})
- Validate inputs before constructing if they come from user config
- Update any tuple-producing callers to convert
Example fix
// before
mat = ManualAxisType(varying=['x', 'y'])
// after
mat = ManualAxisType(varying={'x', 'y'}) Defensive patterns
Strategy: type-guard
Validate before calling
varying = frozenset(varying) if not isinstance(varying, frozenset) else varying # note: only set/frozenset accepted; convert lists first
Type guard
def is_ok_axis_container(v): return isinstance(v, (set, frozenset))
Prevention
- Always use set literals {'x'} for mat arguments
- Convert external config data to sets before constructing ManualAxisType
When it happens
Trigger: ManualAxisType(varying=['x','y']) or varying=('x',) — lists/tuples are rejected rather than coerced.
Common situations: Naturally writing a list literal for the axis names; copy-pasting from reprs that show different containers; older code assuming lenient coercion.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- : arrays must have same number of dimensions, got .
- Expected unreduced_kind to be of type…
- Expected unreduced_kind to be of type…
- factor_sizes must be a dict of str to int, but got
- must be a tuple of factors
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/608ce37b620f606d.
Report an issue: GitHub.
Appendix: source
Thrown at jax/_src/core.py:2366
if varying & reduced:
raise ValueError(
"varying and reduced cannot have common mesh axes. Got"
f" varying={varying} and reduced={reduced}")
assert not (varying & unreduced & reduced)
if unreduced_kind is not None and not isinstance(unreduced_kind, UnreducedKind):
raise TypeError(
"Expected unreduced_kind to be of type `jax.sharding.UnreducedKind`"
f" but got {type(unreduced_kind)}")
if not unreduced and unreduced_kind is not None:
raise ValueError(
"`unreduced_kind` should be `None` when `unreduced` is an empty set."
f" Got {unreduced_kind=} and {unreduced=}")
def _canonicalize_mat(name, val):
if not isinstance(val, frozenset):
if not isinstance(val, set):
raise TypeError(
f"{name} argument of ManualAxisType should "
f"of type `frozenset` or `set`. Got type {type(val)}")
val = frozenset(val)
return val
@immutable
class ManualAxisType:
__slots__ = ('varying', 'unreduced', 'reduced', 'unreduced_kind',
'__weakref__')
varying: frozenset
unreduced: frozenset
reduced: frozenset
unreduced_kind: UnreducedKind | None
@staticmethod
@weak_value_internerView on GitHub (pinned to 1e1c6a8fc0)