MCPcopy Create free account
hub / github.com/evilsocket/cake / test_dequantize_fp8_blockwise_scaling

Function test_dequantize_fp8_blockwise_scaling

cake-core/src/utils/fp8.rs:309–320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

307
308 #[test]
309 fn test_dequantize_fp8_blockwise_scaling() {
310 let f32_weight =
311 Tensor::from_vec(vec![1.0f32; 128 * 128], (128, 128), &Device::Cpu).unwrap();
312 let weight = f32_weight.to_dtype(DType::F8E4M3).unwrap();
313 let scale_inv = Tensor::from_vec(vec![2.0f32], (1, 1), &Device::Cpu).unwrap();
314 let result = dequantize_fp8_blockwise(&weight, &scale_inv).unwrap();
315 let first: f32 = result.flatten_all().unwrap().to_vec1::<f32>().unwrap()[0];
316 assert!(
317 (first - 2.0).abs() < 0.1,
318 "scale=2.0 should double value, got {first}"
319 );
320 }
321
322 #[test]
323 fn test_is_fp8_quantized() {

Callers

nothing calls this directly

Calls 1

dequantize_fp8_blockwiseFunction · 0.70

Tested by

no test coverage detected