huggingface/candle · error

{} is a dummy type and does not support storage

Error message

{} is a dummy type and does not support storage

What it means

Dummy types' WithDType::cpu_storage_ref panics because F6E2M3, F6E3M2, F4 and F8E8M0 have no CPU storage representation in candle-core; they exist only as dtype metadata for unimplemented safetensors formats. Borrowing a slice of dummy-typed data as CpuStorageRef is therefore impossible.

Source

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

                )
            }

            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)
                )
            }

            fn to_cpu_storage_owned(_data: Vec<Self>) -> crate::CpuStorage {
                panic!(
                    "{} is a dummy type and does not support storage",
                    stringify!($ty)
                )
            }

            fn cpu_storage_data(_s: crate::CpuStorage) -> Result<Vec<Self>> {
                Err(Error::UnsupportedDTypeForOp(DType::$dtype, "cpu_storage_data").bt())
            }

            fn cpu_storage_as_slice(_s: &crate::CpuStorage) -> Result<&[Self]> {
                Err(Error::UnsupportedDTypeForOp(DType::$dtype, "cpu_storage_as_slice").bt())

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Do not run CPU kernels on dummy-dtype tensors; convert to a supported dtype first (to_dtype(DType::F32)).
  2. Validate the source dtype when loading safetensors and reject F6E2M3/F6E3M2/F4/F8E8M0.
  3. Keep such tensors on paths that only inspect DTYPE metadata, never touch storage.
  4. Patch candle to add real storage support for the MX formats if needed.

Example fix

// before
cpu_op::<F4>(&tensor); // panics in cpu_storage_ref
// after
let t = tensor.to_dtype(DType::F32)?; // convert before CPU kernels
cpu_op::<f32>(&t);
Defensive patterns

Strategy: validation

Validate before calling

fn run_cpu_op(t: &Tensor) -> Result<()> {
    if !is_supported_dtype(t.dtype()) {
        return Err(Error::UnsupportedDTypeForOp(t.dtype(), "cpu op").bt());
    }
    Ok(())
}

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(|| <F4 as WithDType>::cpu_storage_ref(&data));
if r.is_err() { eprintln!("dummy dtype has no CPU storage"); }

Prevention

When it happens

Trigger: Calling WithDType::cpu_storage_ref::<F6E2M3|F6E3M2|F4|F8E8M0>, typically from generic CPU kernel code that wraps &[T] into a CpuStorageRef for a tensor with a dummy dtype.

Common situations: Running CPU ops (map, unary/binary kernels) on tensors whose dtype is an experimental MX format loaded from a checkpoint; generic device storage code paths.

Related errors


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