jax-ml/jax · error · TypeError
Value of type {type(self)} is not convertible to oct.
Error message
Value of type {type(self)} is not convertible to oct. What it means
Raised by JAXTracer.__oct__ when oct() is called on a JAX Tracer. Tracers stand for values under construction by transformations such as jit, grad, or vmap and carry no concrete host value, so an octal string representation cannot be produced. JAX raises this TypeError to make the abstract-value leak obvious.
Source
Thrown at jax/_src/core.py:1143
def __complex__(self):
check_scalar_conversion(self)
if not hasattr(self.aval, "_complex"):
raise TypeError(f"Value of type {type(self)} is not convertible to complex.")
return self.aval._complex(self)
def __hex__(self):
if is_concrete(self): return hex(self.to_concrete_value())
check_integer_conversion(self)
if not hasattr(self.aval, "_hex"):
raise TypeError(f"Value of type {type(self)} is not convertible to hex.")
return self.aval._hex(self)
def __oct__(self):
if is_concrete(self): return oct(self.to_concrete_value())
check_integer_conversion(self)
if not hasattr(self.aval, "_oct"):
raise TypeError(f"Value of type {type(self)} is not convertible to oct.")
return self.aval._oct(self)
def __index__(self):
if is_concrete(self): return operator.index(self.to_concrete_value())
check_integer_conversion(self)
if not hasattr(self.aval, "_index"):
raise TypeError(f"Value of type {type(self)} is not convertible to integer index.")
return self.aval._index(self)
# raises a useful error on attempts to pickle a Tracer.
def __reduce__(self):
raise ConcretizationTypeError(
self, ("The error occurred in the __reduce__ method, which may "
"indicate an attempt to serialize/pickle a traced value."))
# raises the better error message from ShapedArray
def __setitem__(self, key, value):
if not hasattr(self.aval, "_setitem"):View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Drop oct() from traced code; inspect values with jax.debug.print instead.
- Return the traced value and call oct() on the concrete output after jit returns.
- If base-8 math is needed, do it with jax.numpy (e.g. x // 8**k % 8) rather than string formatting.
Example fix
# before
@jax.jit
def f(mode):
log(oct(mode)) # TypeError
return mode & 0o777
# after
@jax.jit
def f(mode):
jax.debug.print('mode={mode:o}', mode=mode)
return mode & 0o777 Defensive patterns
Strategy: validation
Validate before calling
import jax
def oct_or_placeholder(x) -> str:
if isinstance(x, jax.core.Tracer):
return '<tracer>' # or jax.debug.print inside trace
return oct(int(x)) Type guard
import jax
def is_tracer(x) -> bool:
return isinstance(x, jax.core.Tracer) Prevention
- Avoid string-radix formatting of traced integers; compute digits with jnp ops if needed.
- Move oct() diagnostics outside transformations.
- Audit logging code reused from non-JAX codebases before placing it under jit.
When it happens
Trigger: Calling oct(tracer) inside jitted or autodiff-traced code; old-style '%o' % tracer formatting in traced functions; debugging bit flags or permission masks held in traced integers.
Common situations: Legacy Python 2-era or systems-flavored code (masks, file modes) reused inside jax.jit; verbose debug logging of traced integer state; porting NumPy integer pipelines that stringify intermediates.
Related errors
- Value of type {type(self)} is not convertible to hex.
- Value of type {type(self)} is not convertible to float.
- Value of type {type(self)} is not convertible to complex.
- Value of type {type(self)} is not convertible to integer ind
- The error occurred in the __reduce__ method, which may indic
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/2c33b995a7b14eee.
Report an issue: GitHub.