jax-ml/jax · error · ValueError
Unknown FFT type '{s}'
Error message
Unknown FFT type '{s}' What it means
jax.lax.fft accepts the FFT type either as a FftType enum or as one of the strings 'fft','ifft','rfft','irfft' (case-insensitive). Any other string falls through _str_to_fft_type and raises this ValueError echoing the unknown name.
Source
Thrown at jax/_src/lax/fft.py:65
RFFT = 2
"Forward real-to-complex FFT."
IRFFT = 3
"Inverse real-to-complex FFT."
def _str_to_fft_type(s: str) -> FftType:
if s in ("fft", "FFT"):
return FftType.FFT
elif s in ("ifft", "IFFT"):
return FftType.IFFT
elif s in ("rfft", "RFFT"):
return FftType.RFFT
elif s in ("irfft", "IRFFT"):
return FftType.IRFFT
else:
raise ValueError(f"Unknown FFT type '{s}'")
@jit(static_argnums=(1, 2))
def fft(x, fft_type: FftType | str, fft_lengths: Sequence[int]):
if isinstance(fft_type, str):
typ = _str_to_fft_type(fft_type)
elif isinstance(fft_type, FftType):
typ = fft_type
else:
raise TypeError(f"Unknown FFT type value '{fft_type}'")
if typ == FftType.RFFT:
if np.iscomplexobj(x):
raise ValueError("only real valued inputs supported for rfft")
x = lax.convert_element_type(x, dtypes.to_inexact_dtype(dtypes.dtype(x)))
else:
x = lax.convert_element_type(x, dtypes.to_complex_dtype(dtypes.dtype(x)))
if len(fft_lengths) == 0:
# XLA FFT doesn't support 0-rank.View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Use one of 'fft', 'ifft', 'rfft', 'irfft' or the lax.FftType enum members
- For multi-axis FFTs, pass all axes in fft_lengths with type 'fft' rather than a 'fft2' name
- Prefer jax.numpy.fft wrappers (jnp.fft.fft2 etc.) for familiar names
Example fix
# before y = lax.fft(x, 'fft2', (64, 64)) # after y = lax.fft(x, 'fft', (64, 64)) # or jnp.fft.fft2(x)
Defensive patterns
Strategy: type-guard
Validate before calling
assert fft_type in ('fft','ifft','rfft','irfft') or isinstance(fft_type, lax.FftType) Type guard
def valid_fft_type(t) -> bool:
return (isinstance(t, lax.FftType) or
(isinstance(t, str) and t.lower() in ('fft','ifft','rfft','irfft'))) Prevention
- Use the lax.FftType enum instead of strings
- For familiar semantics, call jnp.fft.* wrappers
When it happens
Trigger: Calling jax.lax.fft(x, 'dft', (n,)) or 'fft2'/'complex_fft' — names that exist in other libraries but not here.
Common situations: Porting from numpy/scipy or TensorFlow naming (fft2, fftn, hfft); typos like 'fftn' expecting multi-axis behavior.
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
- only real valued inputs supported for rfft
- {name} wrapped function must be passed at least one argument
- primal and tangent arguments to jax.jvp must be tuples or li
- check_error takes an Error as argument, got type {type(error
- Can't use ``defjvps`` with ``nondiff_argnums``.
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/76639c5959a4bb4a.
Report an issue: GitHub.