Skip to content

Commit

Permalink
Potential bug on q4k.
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Jan 5, 2024
1 parent fa3ea98 commit 504d0b9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion candle-core/tests/quantized_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,17 @@ fn quantized_matmul_q4k() -> Result<()> {

let rhs = quantized::QTensor::quantize::<BlockQ4K>(&rhs)?;
let rhs = quantized::QMatMul::from_qtensor(rhs)?;
let mm = rhs.forward(&lhs)?;
let qmm = rhs.forward(&lhs)?;

let error: f32 = ((&mm - &qmm)?.abs()? / &mm.abs()?)?
.sum_all()?
.to_scalar()?;
let error = error / (m * n) as f32;

assert!(
error < 0.01,
"{error} is too big, shouldn't exceed a few percent. \nGot:{qmm}\nExpected:\n{mm} "
);

assert_eq!(mm.dims(), [m, n]);
let dst = mm.flatten_all()?.to_vec1::<f32>()?;
Expand Down

0 comments on commit 504d0b9

Please sign in to comment.