{"record":{"id":"972d026b0ec5ae78","repo":"PaddlePaddle/PaddleOCR","slug":"invalid-precision-precision-supported-values-a","errorCode":null,"errorMessage":"Invalid precision: {precision}. Supported values are: {SUPPORTED_PRECISION_LIST}.","messagePattern":"Invalid precision: (.+?)\\. Supported values are: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"paddleocr/_common_args.py","lineNumber":67,"sourceCode":"        \"enable_cinn\": DEFAULT_USE_CINN,\n    }\n\n    unknown_names = kwargs.keys() - default_vals.keys()\n    for name in unknown_names:\n        raise ValueError(f\"Unknown argument: {name}\")\n\n    kwargs = {**default_vals, **kwargs}\n\n    if (\n        kwargs[\"engine\"] is not None\n        and kwargs[\"engine\"] not in SUPPORTED_INFERENCE_ENGINE_LIST\n    ):\n        raise ValueError(\n            f\"Invalid engine: {kwargs['engine']}. Supported values are: {SUPPORTED_INFERENCE_ENGINE_LIST}.\"\n        )\n\n    if kwargs[\"precision\"] not in SUPPORTED_PRECISION_LIST:\n        raise ValueError(\n            f\"Invalid precision: {kwargs['precision']}. Supported values are: {SUPPORTED_PRECISION_LIST}.\"\n        )\n\n    kwargs[\"use_pptrt\"] = kwargs.pop(\"use_tensorrt\")\n    kwargs[\"pptrt_precision\"] = kwargs.pop(\"precision\")\n\n    return kwargs\n\n\ndef _build_paddle_static_engine_config(common_args, device_type):\n    cfg = {}\n    if device_type == \"gpu\":\n        if common_args[\"use_pptrt\"]:\n            if common_args[\"pptrt_precision\"] == \"fp32\":\n                cfg[\"run_mode\"] = \"trt_fp32\"\n            else:\n                assert common_args[\"pptrt_precision\"] == \"fp16\", common_args[\n                    \"pptrt_precision\"","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_common_args.py#L49-L85","documentation":"ValueError raised by parse_common_args when precision is not in SUPPORTED_PRECISION_LIST (['fp32', 'fp16']). Unlike engine, precision is always checked even at its default, so an invalid value anywhere in the config chain fails immediately.","triggerScenarios":"PaddleOCR(precision='int8'), precision='float16', or precision='FP16' (case-sensitive check).","commonSituations":"Coming from TensorRT configs where 'int8'/'bf16' are valid; assuming case-insensitivity; abbreviating float16 as fp16 correctly but trying bfloat16.","solutions":["Use exactly 'fp32' or 'fp16' (lowercase)","For other numeric formats on TensorRT paths, check whether your version supports them via SUPPORTED_PRECISION_LIST before passing"],"exampleFix":"# before\nocr = PaddleOCR(precision='float16', use_tensorrt=True)\n# after\nocr = PaddleOCR(precision='fp16', use_tensorrt=True)","handlingStrategy":"type-guard","validationCode":"from paddleocr._constants import SUPPORTED_PRECISION_LIST\n\nif precision not in SUPPORTED_PRECISION_LIST:\n    raise ValueError(f'precision must be one of {SUPPORTED_PRECISION_LIST}')","typeGuard":"from typing import Literal\n\nPrecision = Literal['fp32', 'fp16']\n\ndef is_precision(v: str) -> 'TypeGuard[Precision]':\n    return v in ('fp32', 'fp16')","tryCatchPattern":null,"preventionTips":["Use lowercase 'fp32'/'fp16' exactly","Check SUPPORTED_PRECISION_LIST when upgrading, not docs memory"],"tags":["validation","configuration","precision"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}