{"record":{"id":"cccadf2a10db24ec","repo":"jax-ml/jax","slug":"the-precision-precision-is-not-supported-by-do","errorCode":null,"errorMessage":"The precision '{precision}' is not supported by dot_general on CPU","messagePattern":"The precision '(.+?)' is not supported by dot_general on CPU","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/lax.py","lineNumber":6217,"sourceCode":"  # The *_ lets us reuse this for ragged_dot_general, which has group_sizes.\n  lhs_aval, rhs_aval, *_ = ctx.avals_in\n  lhs_dtype, rhs_dtype = lhs_aval.dtype, rhs_aval.dtype\n  aval_out, = ctx.avals_out\n  accumulation_aval = aval_out\n  algorithm_kwarg = {}\n  if isinstance(precision, (DotAlgorithm, DotAlgorithmPreset)):\n    # The CPU backend silently ignores the algorithm spec, so we check here to\n    # make sure that the selected algorithm is supported. We could be a little\n    # bit more liberal here (any algorithm where the input and output types\n    # match and all the other parameters have default values should work), but\n    # it's probably sufficient to just check the presets here.\n    if platform == \"cpu\" and precision not in {\n        DotAlgorithmPreset.DEFAULT, DotAlgorithmPreset.F16_F16_F16,\n        DotAlgorithmPreset.F32_F32_F32, DotAlgorithmPreset.F64_F64_F64,\n        DotAlgorithmPreset.BF16_BF16_F32, DotAlgorithmPreset.BF16_BF16_F32_X3,\n        DotAlgorithmPreset.BF16_BF16_F32_X6,\n    }:\n      raise ValueError(\n          f\"The precision '{precision}' is not supported by dot_general on CPU\")\n\n    # If an explicit algorithm was specified, we always cast the input types to\n    # the correct types.\n    def maybe_convert_dtype(operand, operand_aval, target_dtype):\n      if target_dtype is None or operand_aval.dtype == target_dtype:\n        return operand\n      aval = core.ShapedArray(operand_aval.shape, target_dtype)\n      return mlir.convert_hlo(ctx, operand, operand_aval, aval)\n\n    lhs_dtype, rhs_dtype, accumulation_dtype = get_algorithm_compute_types(\n        precision, lhs_dtype, rhs_dtype, aval_out.dtype)\n    lhs = maybe_convert_dtype(lhs, lhs_aval, lhs_dtype)\n    rhs = maybe_convert_dtype(rhs, rhs_aval, rhs_dtype)\n    if accumulation_dtype is not None:\n      accumulation_aval = core.ShapedArray(aval_out.shape, accumulation_dtype)\n\n    if precision != DotAlgorithmPreset.DEFAULT:","sourceCodeStart":6199,"sourceCodeEnd":6235,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/lax.py#L6199-L6235","documentation":"Raised when lowering dot_general on the CPU platform with a precision (DotAlgorithmPreset/DotAlgorithm) outside the supported CPU set (DEFAULT, F16_F16_F16, F32_F32_F32, F64_F64_F64, BF16_BF16_F32, BF16_BF16_F32_X3, BF16_BF16_F32_X6). CPU lacks the fp8/fp4 mixed-precision units these imply.","triggerScenarios":"Running lax.dot_general(..., precision=DotAlgorithmPreset.F8_E4M3FN_...) or an fp8 DotAlgorithm while the computation executes on jax.devices('cpu').","commonSituations":"Developing on a laptop without GPU; CI running CPU-only; device placement falling back to CPU when the GPU is busy/unavailable; forcing jax_platforms=cpu for debugging.","solutions":["Gate precision by platform: use the fp8 preset only when jax.default_backend() indicates gpu/tpu","Fall back to DotAlgorithmPreset.DEFAULT (or BF16 presets) on CPU","Ensure the process actually sees the GPU (check jax.devices()) instead of silently running on CPU"],"exampleFix":"# before\nprec = DotAlgorithmPreset.F8_E4M3FN_F8_E4M3FN_F32\nout = lax.dot_general(a, b, dn, precision=prec)\n# after\nfrom jax import default_backend\nprec = (DotAlgorithmPreset.F8_E4M3FN_F8_E4M3FN_F32\n        if default_backend() != 'cpu' else DotAlgorithmPreset.DEFAULT)\nout = lax.dot_general(a, b, dn, precision=prec)","handlingStrategy":"validation","validationCode":"from jax import default_backend\nCPU_OK = {'DEFAULT', 'F16_F16_F16', 'F32_F32_F32', 'F64_F64_F64',\n          'BF16_BF16_F32', 'BF16_BF16_F32_X3', 'BF16_BF16_F32_X6'}\nif default_backend() == 'cpu':\n    assert precision.name in CPU_OK or precision is None, f'precision {precision} unsupported on CPU'","typeGuard":"def precision_supported(precision, backend=None):\n    from jax import default_backend\n    b = backend or default_backend()\n    if b != 'cpu':\n        return True\n    from jax._src.lax.lax import DotAlgorithmPreset as P\n    return precision in {P.DEFAULT, P.F16_F16_F16, P.F32_F32_F32, P.F64_F64_F64,\n                         P.BF16_BF16_F32, P.BF16_BF16_F32_X3, P.BF16_BF16_F32_X6}","tryCatchPattern":"try:\n    out = lax.dot_general(a, b, dn, precision=prec)\nexcept ValueError:\n    out = lax.dot_general(a, b, dn, precision=DotAlgorithmPreset.DEFAULT)","preventionTips":["Branch precision selection on jax.default_backend()","Log jax.devices() at startup so CPU fallback is visible in CI"],"tags":["jax","dot-general","cpu-backend","precision","fp8"],"backgroundTag":"feature-unsupported-on-backend","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}