{"record":{"id":"fe4d5b74c4819428","repo":"jax-ml/jax","slug":"unknown-fft-type-value-fft-type","errorCode":null,"errorMessage":"Unknown FFT type value '{fft_type}'","messagePattern":"Unknown FFT type value '(.+?)'","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/fft.py","lineNumber":74,"sourceCode":"  if s in (\"fft\", \"FFT\"):\n    return FftType.FFT\n  elif s in (\"ifft\", \"IFFT\"):\n    return FftType.IFFT\n  elif s in (\"rfft\", \"RFFT\"):\n    return FftType.RFFT\n  elif s in (\"irfft\", \"IRFFT\"):\n    return FftType.IRFFT\n  else:\n    raise ValueError(f\"Unknown FFT type '{s}'\")\n\n@jit(static_argnums=(1, 2))\ndef fft(x, fft_type: FftType | str, fft_lengths: Sequence[int]):\n  if isinstance(fft_type, str):\n    typ = _str_to_fft_type(fft_type)\n  elif isinstance(fft_type, FftType):\n    typ = fft_type\n  else:\n    raise TypeError(f\"Unknown FFT type value '{fft_type}'\")\n\n  if typ == FftType.RFFT:\n    if np.iscomplexobj(x):\n      raise ValueError(\"only real valued inputs supported for rfft\")\n    x = lax.convert_element_type(x, dtypes.to_inexact_dtype(dtypes.dtype(x)))\n  else:\n    x = lax.convert_element_type(x, dtypes.to_complex_dtype(dtypes.dtype(x)))\n  if len(fft_lengths) == 0:\n    # XLA FFT doesn't support 0-rank.\n    return x\n  fft_lengths = tuple(fft_lengths)\n  return fft_p.bind(x, fft_type=typ, fft_lengths=fft_lengths)\n\ndef _fft_impl(x, fft_type, fft_lengths):\n  return dispatch.apply_primitive(fft_p, x, fft_type=fft_type, fft_lengths=fft_lengths)\n\n_complex_dtype = lambda dtype: (np.zeros((), dtype) + np.zeros((), np.complex64)).dtype\n_real_dtype = lambda dtype: np.finfo(dtype).dtype","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/fft.py#L56-L92","documentation":"The fft_type argument must be a str (parsed by name) or a lax.FftType enum member. Passing any other type (int, numpy integer, None) raises this TypeError, since JAX will not guess an enum from raw integers.","triggerScenarios":"lax.fft(x, 0, (n,)) using the XLA integer enum value, or passing an int pulled from a config file/serialized spec.","commonSituations":"Deserializing FFT configs where the type round-trips to a plain int; interoperating with code that uses XLA's numeric FftType.","solutions":["Convert integers to lax.FftType(n) before calling, e.g. lax.FftType(0)","Store/transport the string names ('fft','ifft','rfft','irfft') instead of ints","Use jax.numpy.fft high-level functions which need no type argument"],"exampleFix":"# before\ny = lax.fft(x, 0, (64,))\n# after\ny = lax.fft(x, lax.FftType(0), (64,))  # FFT type","handlingStrategy":"type-guard","validationCode":"if isinstance(fft_type, int):\n    fft_type = lax.FftType(fft_type)\nassert isinstance(fft_type, (str, lax.FftType))","typeGuard":"def coerce_fft_type(t):\n    if isinstance(t, int):\n        return lax.FftType(t)\n    if isinstance(t, str):\n        return t\n    raise TypeError(f'bad fft_type {t!r}')","tryCatchPattern":null,"preventionTips":["Serialize FFT configs as string names","Convert ints at the config boundary with lax.FftType(n)"],"tags":["jax","fft","type-error"],"backgroundTag":"invalid-argument-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}