{"record":{"id":"a206ea5a348a948e","repo":"docling-project/docling","slug":"unsupported-numpy-dtype-for-grpc-inline-non-binar","errorCode":null,"errorMessage":"Unsupported numpy dtype for gRPC inline (non-binary) encoding: {tensor.dtype!s}. Supported non-binary dtypes: bool, uint8/uint16/uint32/uint64, int8/int16/int32/int64, float32/float64, BYTES.","messagePattern":"Unsupported numpy dtype for gRPC inline \\(non-binary\\) encoding: (.+?)\\. Supported non-binary dtypes: bool, uint8/uint16/uint32/uint64, int8/int16/int32/int64, float32/float64, BYTES\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/common/kserve_v2_grpc.py","lineNumber":131,"sourceCode":"    flat = tensor.flatten()\n    if tensor.dtype == np.float32:\n        contents.fp32_contents.extend(flat.tolist())\n    elif tensor.dtype == np.float64:\n        contents.fp64_contents.extend(flat.tolist())\n    elif tensor.dtype in (np.int8, np.int16, np.int32):\n        contents.int_contents.extend(flat.astype(np.int32).tolist())\n    elif tensor.dtype == np.int64:\n        contents.int64_contents.extend(flat.tolist())\n    elif tensor.dtype in (np.uint8, np.uint16, np.uint32):\n        contents.uint_contents.extend(flat.astype(np.uint32).tolist())\n    elif tensor.dtype == np.uint64:\n        contents.uint64_contents.extend(flat.tolist())\n    elif tensor.dtype == np.bool_:\n        contents.bool_contents.extend(flat.tolist())\n    elif tensor.dtype == object:\n        contents.bytes_contents.extend(encode_bytes_element(value) for value in flat)\n    else:\n        raise ValueError(\n            f\"Unsupported numpy dtype for gRPC inline (non-binary) encoding: {tensor.dtype!s}. \"\n            \"Supported non-binary dtypes: bool, uint8/uint16/uint32/uint64, \"\n            \"int8/int16/int32/int64, float32/float64, BYTES.\"\n        )\n\n\ndef _decode_contents(\n    contents: Any, np_dtype: np.dtype[Any], shape: tuple[int, ...]\n) -> np.ndarray:\n    \"\"\"Decode an InferTensorContents message to a numpy array (non-binary path).\"\"\"\n    canonical_dtype = np.dtype(np_dtype)\n\n    if canonical_dtype == np.dtype(np.float32):\n        data = list(contents.fp32_contents)\n    elif canonical_dtype == np.dtype(np.float64):\n        data = list(contents.fp64_contents)\n    elif canonical_dtype in (\n        np.dtype(np.int8),","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/common/kserve_v2_grpc.py#L113-L149","documentation":"Raised as ValueError by _encode_contents when building a non-binary (inline) KServe gRPC tensor from a numpy array whose dtype is not in the supported set (bool, u8-u64, i8-i64, f32/f64, object/BYTES). Notably float16 and bfloat16 are rejected.","triggerScenarios":"Sending a np.float16 image tensor, a float128, a datetime64, or a structured dtype through the inline tensor-contents path of the gRPC client.","commonSituations":"Half-precision preprocessing pipelines (fp16 common on GPUs); mixed-precision exports; object arrays containing non-bytes elements hitting the BYTES branch expectations.","solutions":["Cast to a supported dtype before the request: arr.astype(np.float32).","For half-precision pipelines, cast at the boundary right before sending.","If binary transport is enabled (use_binary_data=True), raw bytes are sent instead and the dtype restriction applies to the declared datatype string — but casting to fp32 is still the simplest fix."],"exampleFix":"# before\npayload = pixels.astype(np.float16)  # -> ValueError on encode\n\n# after\npayload = pixels.astype(np.float32)  # supported inline dtype","handlingStrategy":"validation","validationCode":"import numpy as np\nSUPPORTED = {np.bool_, np.uint8, np.uint16, np.uint32, np.uint64,\n             np.int8, np.int16, np.int32, np.int64, np.float32, np.float64, np.dtype(object)}\nif tensor.dtype not in SUPPORTED:\n    tensor = tensor.astype(np.float32)","typeGuard":"import numpy as np\n\ndef is_supported_inline_dtype(arr: np.ndarray) -> bool:\n    return arr.dtype in (np.bool_, np.uint8, np.uint16, np.uint32, np.uint64,\n                         np.int8, np.int16, np.int32, np.int64,\n                         np.float32, np.float64) or arr.dtype == object","tryCatchPattern":null,"preventionTips":["Cast tensors to float32/uint8 at the client boundary, especially from fp16 pipelines.","Standardize one preprocessing dtype for all remote calls.","Document the supported dtype set next to your request builder."],"tags":["kserve","grpc","numpy","dtype","serialization"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}