Skip to content

Commit 660cf25

Browse files
test: add numerical accuracy integration tests for bitnet-quantization (#838)
## Summary Add six new integration tests to `crates/bitnet-quantization/tests/integration_tests.rs` that validate actual numerical correctness of the quantization implementations. ## New Tests | Test | What it checks | |------|---------------| | `test_i2s_dequantize_known_values` | Hand-crafted I2_S block (byte `0xE4`, scale 1.0) decodes to `[-2, -1, 0, 1]` | | `test_tl1_lut_entry_count` | TL1 2-bit config has 4 LUT levels (2²), packed bytes = `n × 2 / 8`, all codes ∈ `[0, 3]` | | `test_tl2_dequantize_symmetry` | Codes `[0,1,2,3]` with scale 1.0 decode to symmetric `[-2,-1,0,1]` via `(code − shift) × scale` | | `test_quantize_dequantize_round_trip_accuracy` | Seeded-random 64 values in `[-0.1, 0.1]`; I2_S reconstruction error < 0.1 per element | | `test_qk256_block_size` | `QK256_BLOCK == 256` and `QK256_PACKED_BYTES == 64`; validates `I2SQk256NoScale::new` | | `test_zero_vector_quantizes_to_zero` | All-zeros input → all-zeros output for I2S, TL1, and TL2 | ## Structural Change ## Test Run ``` cargo test -p bitnet-quantization --no-default-features --features cpu --test integration_tests running 6 tests test test_qk256_block_size ... ok test test_i2s_dequantize_known_values ... ok test test_tl2_dequantize_symmetry ... ok test test_tl1_lut_entry_count ... ok test test_quantize_dequantize_round_trip_accuracy ... ok test test_zero_vector_quantizes_to_zero ... ok test result: ok. 6 passed; 0 failed; 0 ignored ``` Full suite: zero failures across all bitnet-quantization test files. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 97bd1f3 commit 660cf25

1 file changed

Lines changed: 435 additions & 233 deletions

File tree

0 commit comments

Comments
 (0)