{"record":{"id":"7b6f120de76350b0","repo":"huggingface/candle","slug":"is-a-dummy-type-and-cannot-be-converted","errorCode":null,"errorMessage":"{} is a dummy type and cannot be converted","messagePattern":"(.+?) is a dummy type and cannot be converted","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/dummy_dtype.rs","lineNumber":42,"sourceCode":"/// This is a dummy type.\n#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]\npub struct F8E8M0;\n\n// Implement WithDType for dummy types\nmacro_rules! dummy_with_dtype {\n    ($ty:ty, $dtype:ident) => {\n        impl WithDType for $ty {\n            const DTYPE: DType = DType::$dtype;\n\n            fn from_f64(_v: f64) -> Self {\n                panic!(\n                    \"{} is a dummy type and cannot be constructed\",\n                    stringify!($ty)\n                )\n            }\n\n            fn to_f64(self) -> f64 {\n                panic!(\n                    \"{} is a dummy type and cannot be converted\",\n                    stringify!($ty)\n                )\n            }\n\n            fn to_scalar(self) -> crate::scalar::Scalar {\n                panic!(\n                    \"{} is a dummy type and cannot be converted to scalar\",\n                    stringify!($ty)\n                )\n            }\n\n            fn cpu_storage_ref(_data: &[Self]) -> crate::CpuStorageRef<'_> {\n                panic!(\n                    \"{} is a dummy type and does not support storage\",\n                    stringify!($ty)\n                )\n            }","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/dummy_dtype.rs#L24-L60","documentation":"The dummy types (F6E2M3, F6E3M2, F4, F8E8M0) implement WithDType::to_f64 as an unconditional panic because they cannot hold real values. Any attempt to convert a dummy-typed element to f64 aborts the thread. The type is metadata-only for unimplemented safetensors float formats.","triggerScenarios":"Calling WithDType::to_f64 on a value typed as F6E2M3/F6E3M2/F4/F8E8M0, or generic code (e.g. tensor printing, reduction, element access like Tensor::to_vec or get) that converts elements of a dummy-dtype tensor to f64.","commonSituations":"Inspecting or printing a tensor whose dtype came from an experimental MX-format checkpoint; generic debugging helpers that call to_f64 on every element regardless of dtype.","solutions":["Convert the tensor to a supported dtype (e.g. to_dtype(DType::F32)) before reading elements.","Avoid element access/printing on tensors with dummy dtypes; check Tensor::dtype() first.","Migrate the checkpoint to a supported format (f16/bf16/f32) before loading.","Patch candle to implement the MX formats if you genuinely need them."],"exampleFix":"// before\nlet x = tensor_i_hope_f64(t_dummy); // panics in to_f64\n// after\nlet t = t_dummy.to_dtype(DType::F32)?; // convert first, after validating dtype is supported","handlingStrategy":"validation","validationCode":"if !is_supported_dtype(tensor.dtype()) {\n    return Err(Error::UnsupportedDTypeForOp(tensor.dtype(), \"element read\").bt());\n}","typeGuard":"fn is_supported_dtype(dtype: DType) -> bool {\n    !matches!(dtype, DType::F6E2M3 | DType::F6E3M2 | DType::F4 | DType::F8E8M0)\n}","tryCatchPattern":"let r = std::panic::catch_unwind(|| dummy_val.to_f64());\nif r.is_err() { eprintln!(\"cannot read dummy dtype; convert tensor first\"); }","preventionTips":["Call tensor.to_dtype(DType::F32)? before element access","Check dtype before to_vec/get/print helpers on untrusted checkpoints","Reject experimental MX dtypes at load time","Do not call to_f64 inside generic code over unverified T: WithDType"],"tags":["rust","panic","unsupported-dtype","candle"],"backgroundTag":"unsupported-dtype","analyzedSha":"d5fee525bfde3273eb7c9b75fd2bc4937be867ca","analyzedAt":"2026-09-02T00:15:47.023Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}