huggingface/candle · error

{} is a dummy type and cannot be constructed

Error message

{} is a dummy type and cannot be constructed

What it means

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.

Source

Thrown at candle-core/src/dummy_dtype.rs:35

/// 4-bit float (MX4 format)
/// This is a dummy type.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct F4;

/// 8-bit float with 8 exponent bits and 0 mantissa bits
/// 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)
                )
            }

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Do not construct tensors with the dummy dtypes F6E2M3, F6E3M2, F4, F8E8M0; convert data to a supported dtype (f32, f16, bf16, etc.) instead.
  2. Check the dtype of loaded safetensors tensors and reject/migrate experimental MX dtypes before processing.
  3. Upgrade or patch candle if you actually need MX-format support, as these types are placeholders for future implementations.
  4. Wrap generic construction paths in catch_unwind if you must probe unsupported dtypes without aborting.

Example fix

// before
let v = F6E2M3::from_f64(1.0); // panics
// after
let v = f32::from_f64(1.0); // use a supported dtype
Defensive patterns

Strategy: validation

Validate before calling

const DUMMY_DTYPES: [DType; 4] = [DType::F6E2M3, DType::F6E3M2, DType::F4, DType::F8E8M0];
fn assert_supported(dtype: DType) -> Result<(), DType> {
    if DUMMY_DTYPES.contains(&dtype) { Err(dtype) } else { Ok(()) }
}

Type guard

fn is_supported_dtype(dtype: DType) -> bool {
    !matches!(dtype, DType::F6E2M3 | DType::F6E3M2 | DType::F4 | DType::F8E8M0)
}

Try / catch

let t = std::panic::catch_unwind(|| F6E2M3::from_f64(1.0));
match t { Ok(_) => unreachable!(), Err(_) => eprintln!("dummy dtype not constructible; use f32/f16/bf16") }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02). Data as JSON: /api/errors/dac77b29a3e08f82. Report an issue: GitHub.