{"record":{"id":"92fd330bf724d5d3","repo":"huggingface/candle","slug":"is-a-dummy-type-and-does-not-support-operations","errorCode":null,"errorMessage":"{} is a dummy type and does not support operations","messagePattern":"(.+?) is a dummy type and does not support operations","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"candle-core/src/dummy_dtype.rs","lineNumber":90,"sourceCode":"\n            fn cpu_storage_as_slice(_s: &crate::CpuStorage) -> Result<&[Self]> {\n                Err(Error::UnsupportedDTypeForOp(DType::$dtype, \"cpu_storage_as_slice\").bt())\n            }\n        }\n    };\n}\n\ndummy_with_dtype!(F6E2M3, F6E2M3);\ndummy_with_dtype!(F6E3M2, F6E3M2);\ndummy_with_dtype!(F4, F4);\ndummy_with_dtype!(F8E8M0, F8E8M0);\n\n// Implement NumAssign traits for dummy types\nmacro_rules! dummy_num_assign {\n    ($ty:ty) => {\n        impl std::ops::AddAssign for $ty {\n            fn add_assign(&mut self, _other: Self) {\n                panic!(\n                    \"{} is a dummy type and does not support operations\",\n                    stringify!($ty)\n                )\n            }\n        }\n\n        impl std::ops::SubAssign for $ty {\n            fn sub_assign(&mut self, _other: Self) {\n                panic!(\n                    \"{} is a dummy type and does not support operations\",\n                    stringify!($ty)\n                )\n            }\n        }\n\n        impl std::ops::MulAssign for $ty {\n            fn mul_assign(&mut self, _other: Self) {\n                panic!(","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/huggingface/candle/blob/d5fee525bfde3273eb7c9b75fd2bc4937be867ca/candle-core/src/dummy_dtype.rs#L72-L108","documentation":"Dummy types implement AddAssign by panicking: F6E2M3, F6E3M2, F4 and F8E8M0 are unimplemented placeholders and support no arithmetic. The impl exists only so generic code bounded by num-traits/std-ops compiles; executing += on them always aborts.","triggerScenarios":"Using `x += y` where x has type F6E2M3/F6E3M2/F4/F8E8M0, or generic accumulation loops (sums, reductions, kernel loops bounded by Zero + AddAssign) instantiated over a dummy type.","commonSituations":"Generic numeric code (sums, reductions, kernel loops) instantiated over a dummy dtype instead of a real one; accidentally naming a dummy type as the element type parameter.","solutions":["Use a supported numeric element type (f32, f64, f16, bf16, i32, etc.) for arithmetic.","Audit generic functions' type parameters so they are never instantiated with the dummy types.","Convert dummy-dtype tensors to a supported dtype before reductions or element-wise ops.","If MX formats are needed, implement real arithmetic in a candle fork rather than relying on these stubs."],"exampleFix":"// before\nlet mut acc = F6E2M3; acc += x; // panics\n// after\nlet mut acc = 0.0f32; acc += x; // accumulate in a supported type","handlingStrategy":"type-guard","validationCode":"fn checked_add_assign<T: WithDType + AddAssign>(x: &mut T, y: T) -> Result<()> {\n    if DUMMY.contains(&T::DTYPE) {\n        return Err(Error::UnsupportedDTypeForOp(T::DTYPE, \"add_assign\").bt());\n    }\n    *x += y;\n    Ok(())\n}","typeGuard":"fn is_real_numeric<T: WithDType>(_v: &T) -> bool {\n    !matches!(T::DTYPE, DType::F6E2M3 | DType::F6E3M2 | DType::F4 | DType::F8E8M0)\n}","tryCatchPattern":"let r = std::panic::catch_unwind(|| { let mut a = F6E2M3; a += a; });\nif r.is_err() { eprintln!(\"arithmetic on dummy dtype is unsupported\"); }","preventionTips":["Constrain generic numeric code to real element types, never the dummy structs","Accumulate in f32/f64/i64 rather than experimental MX types","Convert tensors to supported dtypes before reductions","Add compile-time or runtime assertions excluding dummy DTYPEs in kernels"],"tags":["rust","panic","arithmetic","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"}