{"record":{"id":"09e33584848f6856","repo":"jax-ml/jax","slug":"only-float32-and-float64-inputs-are-supported-as-i","errorCode":null,"errorMessage":"Only float32 and float64 inputs are supported as inputs to jax.scipy.linalg.eigh_tridiagonal, got {alpha.dtype} and {beta.dtype}","messagePattern":"Only float32 and float64 inputs are supported as inputs to jax\\.scipy\\.linalg\\.eigh_tridiagonal, got (.+?) and (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/scipy/linalg.py","lineNumber":1785,"sourceCode":"    i, q, count = unrolled_steps((i, q, count))\n\n    # Run the remaining steps of the Sturm sequence using a partially\n    # unrolled while loop.\n    unroll_cnt = blocksize\n    def cond(iqc):\n      i, q, count = iqc\n      return jnp.less(i, n)\n    _, _, count = lax.while_loop(cond, unrolled_steps, (i, q, count))\n    return count\n\n  alpha = jnp.asarray(d)\n  beta = jnp.asarray(e)\n  supported_dtypes = (np.float32, np.float64, np.complex64, np.complex128)\n  if alpha.dtype != beta.dtype:\n    raise TypeError(\"diagonal and off-diagonal values must have same dtype, \"\n                    f\"got {alpha.dtype} and {beta.dtype}\")\n  if alpha.dtype not in supported_dtypes or beta.dtype not in supported_dtypes:\n    raise TypeError(\"Only float32 and float64 inputs are supported as inputs \"\n                    \"to jax.scipy.linalg.eigh_tridiagonal, got \"\n                    f\"{alpha.dtype} and {beta.dtype}\")\n  n = alpha.shape[0]\n  if n <= 1:\n    if eigvals_only:\n      return jnp.real(alpha)\n    else:\n      return jnp.real(alpha), jnp.eye(n, dtype=alpha.dtype)\n\n  if dtypes.issubdtype(alpha.dtype, np.complexfloating):\n    alpha = jnp.real(alpha)\n    beta_sq = jnp.real(beta * jnp.conj(beta))\n    beta_abs = jnp.sqrt(beta_sq)\n  else:\n    beta_abs = jnp.abs(beta)\n    beta_sq = jnp.square(beta)\n\n  # Estimate the largest and smallest eigenvalues of T using the Gershgorin","sourceCodeStart":1767,"sourceCodeEnd":1803,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/scipy/linalg.py#L1767-L1803","documentation":"eigh_tridiagonal only supports float32, float64, complex64, and complex128 (despite the message text mentioning only float32/float64). Inputs with other dtypes — float16, bfloat16, int — raise TypeError.","triggerScenarios":"Calling eigh_tridiagonal with bfloat16/float16 arrays (TPU or mixed-precision defaults), or integer diagonals.","commonSituations":"Mixed-precision pipelines on TPU; passing Python/NumPy int arrays without conversion to floating point.","solutions":["Cast inputs: eigh_tridiagonal(d.astype(jnp.float32), e.astype(jnp.float32))","For double precision, enable x64 first: jax.config.update('jax_enable_x64', True) and use float64"],"exampleFix":"// before\nw, v = jax.scipy.linalg.eigh_tridiagonal(d_bf16, e_bf16)\n// after\nw, v = jax.scipy.linalg.eigh_tridiagonal(d_bf16.astype(jnp.float32), e_bf16.astype(jnp.float32))","handlingStrategy":"type-guard","validationCode":"_OK = (np.float32, np.float64, np.complex64, np.complex128)\nif np.asarray(d).dtype not in _OK: d, e = jnp.asarray(d, np.float32), jnp.asarray(e, np.float32)","typeGuard":"_OK = (np.float32, np.float64, np.complex64, np.complex128)\ndef eigh_tridiag_dtype_ok(d, e): return np.asarray(d).dtype in _OK and np.asarray(e).dtype in _OK","tryCatchPattern":null,"preventionTips":["Cast away bfloat16/float16/int before eigh_tridiagonal","Note complex dtypes are supported despite the message wording"],"tags":["jax","linalg","tridiagonal","dtype"],"backgroundTag":"unsupported-dtype","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}