{"record":{"id":"dac77b29a3e08f82","repo":"huggingface/candle","slug":"is-a-dummy-type-and-cannot-be-constructed","errorCode":null,"errorMessage":"{} is a dummy type and cannot be constructed","messagePattern":"(.+?) is a dummy type and cannot be constructed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/dummy_dtype.rs","lineNumber":35,"sourceCode":"\n/// 4-bit float (MX4 format)\n/// This is a dummy type.\n#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]\npub struct F4;\n\n/// 8-bit float with 8 exponent bits and 0 mantissa bits\n/// 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            }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/dummy_dtype.rs#L17-L53","documentation":"The dummy types F6E2M3, F6E3M2, F4, and F8E8M0 in candle-core are placeholders for experimental safetensors float formats that are not yet implemented. Their WithDType::from_f64 method unconditionally panics, so no value of these types can ever be created. This is intentional: the type exists only so its DTYPE can appear in type metadata, not to hold data.","triggerScenarios":"Calling WithDType::from_f64::<F6E2M3|F6E3M2|F4|F8E8M0>(v), directly or via generic tensor code that materializes values of a dummy dtype (e.g. creating a tensor or filling it with a value typed as one of the dummy types).","commonSituations":"Loading a checkpoint or safetensors file whose dtype is one of the experimental MX formats (F6E2M3, F6E3M2, F4, F8E8M0) and running generic code that tries to construct element values; passing such a dtype to APIs generic over WithDType.","solutions":["Do not construct tensors with the dummy dtypes F6E2M3, F6E3M2, F4, F8E8M0; convert data to a supported dtype (f32, f16, bf16, etc.) instead.","Check the dtype of loaded safetensors tensors and reject/migrate experimental MX dtypes before processing.","Upgrade or patch candle if you actually need MX-format support, as these types are placeholders for future implementations.","Wrap generic construction paths in catch_unwind if you must probe unsupported dtypes without aborting."],"exampleFix":"// before\nlet v = F6E2M3::from_f64(1.0); // panics\n// after\nlet v = f32::from_f64(1.0); // use a supported dtype","handlingStrategy":"validation","validationCode":"const DUMMY_DTYPES: [DType; 4] = [DType::F6E2M3, DType::F6E3M2, DType::F4, DType::F8E8M0];\nfn assert_supported(dtype: DType) -> Result<(), DType> {\n    if DUMMY_DTYPES.contains(&dtype) { Err(dtype) } else { Ok(()) }\n}","typeGuard":"fn is_supported_dtype(dtype: DType) -> bool {\n    !matches!(dtype, DType::F6E2M3 | DType::F6E3M2 | DType::F4 | DType::F8E8M0)\n}","tryCatchPattern":"let t = std::panic::catch_unwind(|| F6E2M3::from_f64(1.0));\nmatch t { Ok(_) => unreachable!(), Err(_) => eprintln!(\"dummy dtype not constructible; use f32/f16/bf16\") }","preventionTips":["Check Tensor::dtype() against the dummy dtypes before generic WithDType code","Convert MX-format checkpoints to f16/bf16/f32 before loading into candle","Keep dummy-dtype tensors on metadata-only paths; never create/inspect their values","Track candle releases for real MX-format support before using these dtypes"],"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"}