Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/DevTechJr/turboquant_cutile
/ functions
Functions
74 in github.com/DevTechJr/turboquant_cutile
⨍
Functions
74
◇
Types & classes
2
↓ 29 callers
Method
compress_keys_pytorch
K: (seq_k, head_dim) -> compressed dict.
turboquant_cutile/host.py:61
↓ 15 callers
Method
compress_values_pytorch
V: (seq_v, head_dim) -> compressed dict (MSE only, no QJL).
turboquant_cutile/host.py:92
↓ 11 callers
Method
attention_scores_pytorch
Asymmetric estimator: term1 (MSE dot) + term2 (QJL correction).
turboquant_cutile/host.py:117
↓ 8 callers
Method
decompress_values_pytorch
(self, compressed_v: dict)
turboquant_cutile/host.py:110
↓ 7 callers
Method
fused_attention_pytorch
Full pipeline: scores -> softmax -> weighted V sum.
turboquant_cutile/host.py:136
↓ 6 callers
Function
_make_random_keys
(seq_k: int, head_dim: int = 128)
tests/test_compress.py:21
↓ 5 callers
Method
_cdiv
(self, a: int, b: int)
turboquant_cutile/host.py:148
↓ 3 callers
Function
_standard_attention
(Q, K, V, head_dim)
tests/test_end_to_end.py:13
↓ 2 callers
Method
compressed_size_bytes
(self, seq_len: int)
turboquant_cutile/host.py:362
↓ 2 callers
Method
dequantize
(self, indices: torch.Tensor)
turboquant_cutile/codebook.py:74
↓ 2 callers
Method
quantize
(self, x: torch.Tensor)
turboquant_cutile/codebook.py:70
↓ 1 callers
Method
_dequant_keys_from_indices
indices -> centroids -> un-rotate -> rescale.
turboquant_cutile/host.py:197
↓ 1 callers
Function
_gaussian_pdf
(x: float, sigma: float)
turboquant_cutile/codebook.py:14
↓ 1 callers
Function
_generate_qjl_matrix
Random Gaussian projection matrix for QJL.
turboquant_cutile/host.py:27
↓ 1 callers
Function
_generate_rotation_matrix
Haar-distributed random orthogonal matrix via QR of Gaussian.
turboquant_cutile/host.py:16
↓ 1 callers
Method
launch_decompress_values
(self, compressed_v: dict)
turboquant_cutile/host.py:249
↓ 1 callers
Function
solve_lloyd_max
Returns (centroids, boundaries) as sorted float32 tensors. centroids: (2^bits,) boundaries: (2^bits - 1,)
turboquant_cutile/codebook.py:20
Method
__init__
(self, d: int, bits: int)
turboquant_cutile/codebook.py:64
Method
__init__
( self, head_dim: int = HEAD_DIM, total_bits: int = DEFAULT_TOTAL_BITS, seed:
turboquant_cutile/host.py:37
Method
__repr__
(self)
turboquant_cutile/codebook.py:77
Method
launch_attention_scores
( self, Q: torch.Tensor, compressed_k: dict, use_swizzle: bool = False )
turboquant_cutile/host.py:281
Method
launch_compress_keys
(self, K: torch.Tensor)
turboquant_cutile/host.py:152
Method
launch_compress_values
(self, V: torch.Tensor)
turboquant_cutile/host.py:207
Method
launch_fused_attention
( self, Q: torch.Tensor, compressed_k: dict, compressed_v: dict, use_s
turboquant_cutile/host.py:306
Function
test_bits_sweep_scores_reasonable
Higher bits should produce lower MSE in scores.
tests/test_attention.py:140
Function
test_boundaries_between_centroids
(bits)
tests/test_codebook.py:50
Function
test_compress_keys_shapes
(seq_k, total_bits)
tests/test_compress.py:28
Function
test_compress_matches_reference
Compare our engine against the original cutiledump compressors.py implementation.
tests/test_compress.py:88
Function
test_compress_values_shapes
()
tests/test_compress.py:70
Function
test_compression_ratios
()
tests/test_end_to_end.py:110
Function
test_correct_num_levels
(d, bits)
tests/test_codebook.py:24
Function
test_correlation_with_true_scores
Estimated scores should correlate well with true Q·K^T scores.
tests/test_attention.py:61
Function
test_decompress_shape
(seq_v, total_bits)
tests/test_decompress.py:15
Function
test_deterministic_with_same_seed
()
tests/test_end_to_end.py:126
Function
test_different_head_dims
(head_dim)
tests/test_end_to_end.py:154
Function
test_different_seeds_different_results
()
tests/test_end_to_end.py:140
Function
test_distortion_within_paper_bound
MSE distortion per vector <= sqrt(3) * pi/2 * (1/4^b) for unit vectors.
tests/test_codebook.py:57
Function
test_edge_case_large_values
()
tests/test_compress.py:129
Function
test_edge_case_zero_vector
()
tests/test_compress.py:121
Function
test_full_pipeline_output_shape
(seq_q, seq_k, total_bits)
tests/test_end_to_end.py:22
Function
test_higher_bits_lower_mse
More bits → strictly lower reconstruction MSE.
tests/test_decompress.py:63
Function
test_indices_in_valid_range
(total_bits)
tests/test_compress.py:41
Function
test_k_mse_reconstruction_quality
k_mse should be a reasonable approximation of K.
tests/test_compress.py:107
Function
test_mse_within_bound
Per-vector MSE should be bounded by paper's theoretical upper bound.
tests/test_decompress.py:44
Function
test_needle_in_haystack
Can we still find the most-attended key after compression?
tests/test_attention.py:115
Function
test_needle_retrieval_through_full_pipeline
()
tests/test_end_to_end.py:64
Function
test_norms_positive
()
tests/test_compress.py:61
Function
test_norms_preserved
Vector norms should be approximately preserved after round-trip.
tests/test_decompress.py:78
Function
test_output_cosine_similarity
(total_bits)
tests/test_end_to_end.py:38
Function
test_quantize_nearest_centroid
Values close to a centroid should map to that centroid's index.
tests/test_codebook.py:86
Function
test_reconstruction_quality
Cosine similarity between original and reconstructed should be high.
tests/test_decompress.py:26
Function
test_roundtrip_identity
Quantize → dequantize should map each centroid exactly to itself.
tests/test_codebook.py:78
Function
test_scaling_correct
Scores should be scaled by 1/√d.
tests/test_attention.py:84
Function
test_scores_shape
(seq_q, seq_k, total_bits)
tests/test_attention.py:23
Function
test_signs_are_pm1
()
tests/test_compress.py:52
Function
test_single_decode_token
Typical decode scenario: seq_q=1, seq_k=large.
tests/test_attention.py:101
Function
test_softmax_distribution_preserved
()
tests/test_end_to_end.py:88
Function
test_sorted
(bits)
tests/test_codebook.py:41
Function
test_symmetry
(d, bits)
tests/test_codebook.py:33
Function
test_unbiasedness
The asymmetric estimator should be unbiased: E[estimated_ip] ≈ true_ip. We test by averaging over many random pairs.
tests/test_attention.py:35
Function
test_value_indices_in_valid_range
()
tests/test_compress.py:79
Function
test_vfused_cosine_vs_fp16
(total_bits)
tests/test_end_to_end.py:192
Function
test_vfused_matches_pytorch_reference
(seq_q, seq_k, total_bits)
tests/test_end_to_end.py:173
Function
test_vfused_needle_retrieval
(total_bits)
tests/test_end_to_end.py:219
Function
turboquant_attention_scores
Score-only kernel. One program per query block, streams over KV.
turboquant_cutile/attention.py:27
Function
turboquant_compress_2bit
2-bit MSE (4 centroids) + 1-bit QJL. total_bits=3.
turboquant_cutile/compress.py:12
Function
turboquant_compress_3bit
3-bit MSE (8 centroids) + 1-bit QJL. total_bits=4.
turboquant_cutile/compress.py:66
Function
turboquant_compress_values_2bit
MSE-only value compression, 2-bit (4 levels).
turboquant_cutile/compress.py:169
Function
turboquant_compress_values_3bit
MSE-only value compression, 3-bit (8 levels). No QJL.
turboquant_cutile/compress.py:130
Function
turboquant_decompress_2bit
4-level centroid lookup, un-rotate, rescale.
turboquant_cutile/decompress.py:49
Function
turboquant_decompress_3bit
8-level centroid lookup, un-rotate, rescale.
turboquant_cutile/decompress.py:12
Function
turboquant_fused_attention
Fused attention + online softmax. V is pre-decompressed FP16.
turboquant_cutile/attention.py:75
Function
turboquant_fused_attention_vfused_2bit
Fused attention + online softmax, decompresses 2-bit V on-chip.
turboquant_cutile/attention.py:274
Function
turboquant_fused_attention_vfused_3bit
Fused attention + online softmax, decompresses 3-bit V on-chip.
turboquant_cutile/attention.py:163