diff --git a/crates/ml/src/mamba/mod.rs b/crates/ml/src/mamba/mod.rs index 9f53b1030..c4ddee06e 100644 --- a/crates/ml/src/mamba/mod.rs +++ b/crates/ml/src/mamba/mod.rs @@ -602,7 +602,16 @@ impl Mamba2SSM { reason: e.to_string(), }) }, - DType::F8E4M3 | DType::U8 | DType::U32 | DType::I64 | DType::BF16 | DType::F16 => { + DType::BF16 | DType::F16 => { + // Create as F32 scalar, then cast to the target half-precision dtype. + Tensor::new(&[value as f32], device) + .and_then(|t| t.to_dtype(dtype)) + .map_err(|e| MLError::TensorCreationError { + operation: format!("scalar_tensor ({:?} via F32)", dtype), + reason: e.to_string(), + }) + }, + DType::F8E4M3 | DType::U8 | DType::U32 | DType::I64 => { Err(MLError::ModelError(format!( "Unsupported dtype: {:?}", dtype