{"record":{"id":"95078b71d0b55e92","repo":"jax-ml/jax","slug":"jacobi-implementation-is-not-supported-on-cpu","errorCode":null,"errorMessage":"Jacobi implementation is not supported on CPU","messagePattern":"Jacobi implementation is not supported on CPU","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/linalg.py","lineNumber":1295,"sourceCode":"def _eigh_dtype_rule(dtype, **_):\n  return dtype, lax._complex_basetype(dtype)\n\ndef _eigh_cpu_gpu_lowering(\n    ctx, operand, *, lower, sort_eigenvalues, subset_by_index, algorithm,\n    target_name_prefix: str\n):\n  del sort_eigenvalues  # The CPU/GPU implementations always sort.\n  operand_aval, = ctx.avals_in\n  v_aval, w_aval = ctx.avals_out\n  n = operand_aval.shape[-1]\n  if not (subset_by_index is None or subset_by_index == (0, n)):\n    raise NotImplementedError(\"subset_by_index not supported on CPU and GPU\")\n  batch_dims = operand_aval.shape[:-2]\n\n  if algorithm == EighImplementation.QDWH:\n    raise NotImplementedError(\"QDWH implementation is only supported on TPU\")\n  if algorithm == EighImplementation.JACOBI and target_name_prefix == \"cpu\":\n    raise NotImplementedError(\"Jacobi implementation is not supported on CPU\")\n\n  if target_name_prefix == \"cpu\":\n    dtype = operand_aval.dtype\n    prefix = \"he\" if dtypes.issubdtype(dtype, np.complexfloating) else \"sy\"\n    target_name = lapack.prepare_lapack_call(f\"{prefix}evd_ffi\",\n                                             operand_aval.dtype)\n    kwargs = {\n      \"mode\": np.uint8(ord(\"V\")),\n      \"uplo\": np.uint8(ord(\"L\" if lower else \"U\")),\n    }\n  else:\n    target_name = f\"{target_name_prefix}solver_syevd_ffi\"\n    # Use Jacobi (algorithm=2) if requested, otherwise use QR (algorithm=1)\n    if algorithm is None:\n      algo_int = 0\n    else:\n      algo_int = 2 if algorithm == EighImplementation.JACOBI else 1\n    kwargs = {\"lower\": lower, \"algorithm\": np.uint8(algo_int)}","sourceCodeStart":1277,"sourceCodeEnd":1313,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/linalg.py#L1277-L1313","documentation":"jax/_src/lax/linalg.py:1295 in _eigh_cpu_gpu_lowering. EighImplementation.JACOBI is implemented only for GPU; selecting it while the target is CPU raises NotImplementedError. On CPU the LAPACK syevd/heevd path is used instead.","triggerScenarios":"Calling jax.lax.linalg.eigh(a, algorithm=EighImplementation.JACOBI) with jax backend cpu (e.g. JAX_PLATFORMS=cpu or no GPU present).","commonSituations":"GPU-authored config reused in CPU-only CI or a laptop; jax.config defaults changed; debugging numerics by forcing Jacobi for its better accuracy on GPU then running tests on CPU.","solutions":["Remove the explicit algorithm argument to use the LAPACK default on CPU","Conditionally select algorithm based on jax.default_backend()","Ensure the GPU is actually visible (nvidia-smi, jax.devices()) if Jacobi was intended"],"exampleFix":"// before\nevals, evecs = jax.lax.linalg.eigh(a, algorithm=lax.linalg.EighImplementation.JACOBI)  # on CPU\n// after\nalgo = lax.linalg.EighImplementation.JACOBI if jax.default_backend() == 'gpu' else None\nevals, evecs = jax.lax.linalg.eigh(a, algorithm=algo)","handlingStrategy":"validation","validationCode":"algo = (lax.linalg.EighImplementation.JACOBI\n         if jax.default_backend() == 'gpu' else None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Gate algorithm selection on jax.default_backend()","Keep CPU CI and GPU prod configs separate"],"tags":["jax","eigh","jacobi","cpu","backend","not-implemented"],"backgroundTag":"unsupported-operation-on-backend","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}