{"record":{"id":"9488972f5ea798e4","repo":"jax-ml/jax","slug":"unsupported-data-dtype-s","errorCode":null,"errorMessage":"Unsupported data dtype: %s","messagePattern":"Unsupported data dtype: (.+?)","errorType":"validation","errorClass":"std::invalid_argument","httpStatus":null,"severity":"error","filePath":"jaxlib/gpu/sparse.cc","lineNumber":73,"sourceCode":"      new absl::flat_hash_map<std::pair<char, int>, gpuDataType>({\n          {{'f', 2}, GPU_R_16F},\n          {{'c', 4}, GPU_C_16F},\n          {{'f', 4}, GPU_R_32F},\n          {{'c', 8}, GPU_C_32F},\n          {{'f', 8}, GPU_R_64F},\n          {{'c', 16}, GPU_C_64F},\n#ifdef JAX_GPU_CUDA\n          {{'i', 1}, CUDA_R_8I},\n          {{'u', 1}, CUDA_R_8U},\n          {{'i', 4}, CUDA_R_32I},\n          {{'u', 4}, CUDA_R_32U},\n          {{'V', 2}, CUDA_R_16BF},\n#endif  // JAX_GPU_CUDA\n      });\n  auto it = types->find({np_type.kind(), np_type.itemsize()});\n  if (it == types->end()) {\n    nb::str repr = nb::repr(np_type);\n    throw std::invalid_argument(\n        absl::StrFormat(\"Unsupported data dtype: %s\", repr.c_str()));\n  }\n  return it->second;\n}\n// Returns the descriptor for a Sparse matrix.\nSparseMatDescriptor BuildSparseMatDescriptor(const dtype& data_dtype,\n                                             const dtype& index_dtype, int rows,\n                                             int cols, int nnz, int batch_count,\n                                             int batch_stride) {\n  gpuDataType value_type = DtypeToCudaDataType(data_dtype);\n  gpusparseIndexType_t index_type = DtypeToCuSparseIndexType(index_dtype);\n  return SparseMatDescriptor{value_type, index_type,  rows,        cols,\n                             nnz,        batch_count, batch_stride};\n}\n\n// Returns the descriptor for a Dense matrix.\nDenseMatDescriptor BuildDenseMatDescriptor(const dtype& data_dtype, int rows,\n                                           int cols, int batch_count,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jaxlib/gpu/sparse.cc#L55-L91","documentation":"Maps NumPy dtypes to gpuDataType (cudaDataType/hipDataType) for GPU sparse/dense operations; unsupported dtypes (e.g. float64 on builds without it, uint types, bool) are rejected with the offending dtype's repr.","triggerScenarios":"Calling jaxlib GPU sparse matmul descriptors with a data dtype unsupported by the compiled jaxlib GPU support table — e.g. complex, integer, or unsigned data in sparse ops, or bfloat16 on a CUDA build where it is compiled out.","commonSituations":"jax.experimentalsparse matmuls with unusual dtypes; ROCm/CUDA build differences where some dtype entries are ifdef'd out.","solutions":["Use a supported dtype (float32, float64 where available, complex64/128, or bfloat16)","Cast inputs before calling the sparse op","Reinstall a jaxlib build matching your platform with full dtype support"],"exampleFix":"# before\nspmm(a_bfloat16_unsupported_build, b)\n# after\nspmm(a.astype(jnp.float32), b)","handlingStrategy":"type-guard","validationCode":"SUPPORTED = {jnp.float32, jnp.float64, jnp.complex64, jnp.complex128}\nassert x.dtype in SUPPORTED, f'unsupported {x.dtype}'","typeGuard":"def supported_data_dtype(dt) -> bool:\n    return dt in (jnp.float32, jnp.float64, jnp.complex64, jnp.complex128)","tryCatchPattern":null,"preventionTips":["Default sparse GPU ops to float32/complex64","Check jaxlib platform build supports your dtype before use"],"tags":["jax","gpu","sparse","dtype"],"backgroundTag":"unsupported-dtype","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}