More bits → strictly lower reconstruction MSE.
()
| 61 | |
| 62 | |
| 63 | def test_higher_bits_lower_mse(): |
| 64 | """More bits → strictly lower reconstruction MSE.""" |
| 65 | d = 128 |
| 66 | V = torch.randn(256, d).half() |
| 67 | prev_mse = float("inf") |
| 68 | |
| 69 | for bits in [2, 3, 4]: |
| 70 | engine = TurboQuantEngine(head_dim=d, total_bits=bits, device="cpu") |
| 71 | compressed = engine.compress_values_pytorch(V) |
| 72 | V_recon = engine.decompress_values_pytorch(compressed) |
| 73 | mse = ((V.float() - V_recon.float()) ** 2).sum(dim=-1).mean().item() |
| 74 | assert mse < prev_mse, f"bits={bits}: MSE={mse:.6f} >= prev={prev_mse:.6f}" |
| 75 | prev_mse = mse |
| 76 | |
| 77 | |
| 78 | def test_norms_preserved(): |
nothing calls this directly
no test coverage detected