{"record":{"id":"0cb5549ea1be7c71","repo":"docling-project/docling","slug":"unsupported-numpy-dtype-for-grpc-inline-non-binar-0cb554","errorCode":null,"errorMessage":"Unsupported numpy dtype for gRPC inline (non-binary) decoding: {canonical_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\\) decoding: (.+?)\\. Supported non-binary dtypes: bool, uint8/uint16/uint32/uint64, int8/int16/int32/int64, float32/float64, BYTES\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/common/kserve_v2_grpc.py","lineNumber":169,"sourceCode":"        np.dtype(np.int32),\n    ):\n        data = list(contents.int_contents)\n    elif canonical_dtype == np.dtype(np.int64):\n        data = list(contents.int64_contents)\n    elif canonical_dtype in (\n        np.dtype(np.uint8),\n        np.dtype(np.uint16),\n        np.dtype(np.uint32),\n    ):\n        data = list(contents.uint_contents)\n    elif canonical_dtype == np.dtype(np.uint64):\n        data = list(contents.uint64_contents)\n    elif canonical_dtype == np.dtype(np.bool_):\n        data = list(contents.bool_contents)\n    elif canonical_dtype == np.dtype(object):\n        data = list(contents.bytes_contents)\n    else:\n        raise RuntimeError(\n            f\"Unsupported numpy dtype for gRPC inline (non-binary) decoding: {canonical_dtype!s}. \"\n            \"Supported non-binary dtypes: bool, uint8/uint16/uint32/uint64, \"\n            \"int8/int16/int32/int64, float32/float64, BYTES.\"\n        )\n    return np.asarray(data, dtype=canonical_dtype).reshape(shape)\n\n\n@dataclass\nclass KserveV2GrpcClient:\n    \"\"\"Minimal client for KServe v2 gRPC infer requests.\"\"\"\n\n    base_url: str\n    model_name: str\n    model_version: str | None\n    timeout: float\n    metadata: Mapping[str, str]\n    use_tls: bool\n    max_message_bytes: int","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/common/kserve_v2_grpc.py#L151-L187","documentation":"Raised as RuntimeError by _decode_contents when a response tensor's declared datatype maps to a numpy dtype outside the supported inline decoding set (bool, u8-u64, i8-i64, f32/f64, object/BYTES). The server sent a tensor whose datatype this client cannot materialize into a numpy array.","triggerScenarios":"The KServe server responds with a tensor datatype such as FP16, BF16, FP8 or a string datatype that canonicalizes to an unsupported numpy dtype, and the response was not binary-encoded.","commonSituations":"Remote model served with half-precision outputs; server and client disagree on the allowed datatype vocabulary; newer KServe datatypes not known to this client version.","solutions":["Configure the server (or model output signature) to emit FP32/FP64 tensors instead of FP16/BF16.","Upgrade docling so the client knows the datatype, if support was added.","Enable binary tensor contents on the server side so raw bytes + explicit datatype are used rather than inline decoding."],"exampleFix":"# before: server outputs fp16 -> RuntimeError on decode\n# after: configure the model server to cast outputs to fp32\n# e.g. in the model's inference fn: return {'outputs': out.astype(np.float32)}","handlingStrategy":"try-catch","validationCode":"meta = client.get_model_metadata()\nunsupported = {t.datatype for t in meta.outputs} - {'BOOL','UINT8','UINT16','UINT32','UINT64','INT8','INT16','INT32','INT64','FP32','FP64','BYTES'}\nif unsupported:\n    raise RuntimeError(f'server emits unsupported datatypes: {unsupported}')","typeGuard":null,"tryCatchPattern":"try:\n    result = client.infer(...)\nexcept RuntimeError as e:\n    if 'decoding' in str(e):\n        raise RuntimeError('server datatype unsupported by client; emit FP32 or enable binary contents') from e\n    raise","preventionTips":["Probe get_model_metadata() at client startup to learn output datatypes.","Configure servers to output fp32 tensors for gRPC clients.","Keep server and docling client versions aligned on the datatype vocabulary."],"tags":["kserve","grpc","numpy","dtype","decoding","server-compat"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}