MCPcopy Create free account
hub / github.com/DevTechJr/turboquant_cutile / test_higher_bits_lower_mse

Function test_higher_bits_lower_mse

tests/test_decompress.py:63–75  ·  view source on GitHub ↗

More bits → strictly lower reconstruction MSE.

()

Source from the content-addressed store, hash-verified

61
62
63def 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
78def test_norms_preserved():

Callers

nothing calls this directly

Calls 3

TurboQuantEngineClass · 0.90

Tested by

no test coverage detected