huggingface/candle · error
{} is a dummy type and cannot be converted
Error message
{} is a dummy type and cannot be converted What it means
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.
Source
Thrown at candle-core/src/dummy_dtype.rs:42
/// This is a dummy type.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct F8E8M0;
// Implement WithDType for dummy types
macro_rules! dummy_with_dtype {
($ty:ty, $dtype:ident) => {
impl WithDType for $ty {
const DTYPE: DType = DType::$dtype;
fn from_f64(_v: f64) -> Self {
panic!(
"{} is a dummy type and cannot be constructed",
stringify!($ty)
)
}
fn to_f64(self) -> f64 {
panic!(
"{} is a dummy type and cannot be converted",
stringify!($ty)
)
}
fn to_scalar(self) -> crate::scalar::Scalar {
panic!(
"{} is a dummy type and cannot be converted to scalar",
stringify!($ty)
)
}
fn cpu_storage_ref(_data: &[Self]) -> crate::CpuStorageRef<'_> {
panic!(
"{} is a dummy type and does not support storage",
stringify!($ty)
)
}View on GitHub (pinned to d5fee525bf)
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.
Example fix
// before let x = tensor_i_hope_f64(t_dummy); // panics in to_f64 // after let t = t_dummy.to_dtype(DType::F32)?; // convert first, after validating dtype is supported
Defensive patterns
Strategy: validation
Validate before calling
if !is_supported_dtype(tensor.dtype()) {
return Err(Error::UnsupportedDTypeForOp(tensor.dtype(), "element read").bt());
} Type guard
fn is_supported_dtype(dtype: DType) -> bool {
!matches!(dtype, DType::F6E2M3 | DType::F6E3M2 | DType::F4 | DType::F8E8M0)
} Try / catch
let r = std::panic::catch_unwind(|| dummy_val.to_f64());
if r.is_err() { eprintln!("cannot read dummy dtype; convert tensor first"); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {} is a dummy type and cannot be constructed
- {} is a dummy type and cannot be converted to scalar
- {} is a dummy type and does not support storage
- {} is a dummy type and does not support operations
- {} is a dummy type and does not support parsing
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/7b6f120de76350b0.
Report an issue: GitHub.