Full GPU acceleration for the entire PQ pipeline: encoder training, PQ encoding, cluster training, and label assignment#5
Merged
Conversation
- Fix GPU tensor cache to use content comparison instead of memory address, preventing stale tensor reuse after Python frees/reuses the same address - Add CPU transform fallback using codewords when sklearn models aren't available (e.g. loaded encoder without pq_trained) - Add GPU-accelerated KMeans fit with batched GEMM assignment - Add _update_centers for PQ centroid recomputation with empty cluster preservation - Add early stopping with tolerance and oscillation detection - Add device validation and GPU support gating (m=6, k<=256) - Remove stray debug print in ImportError handler - Clean up comment artifacts and unused variables - All 53 tests pass (CPU + GPU paths)
- Replace hand-unrolled M=6 kernel with tl.static_range(M) loop, supporting any number of subvectors via compile-time unrolling - Add adaptive BLOCK_K sizing based on M to manage register pressure - Remove m=6 guard from PQKMeans GPU support check - Update README with 1B GPU benchmark results on real Enamine data (2.9 hrs total for full pipeline on RTX 4070 Ti SUPER) - Add reproducible benchmark script (scripts/benchmark_1B_pipeline.py) that streams fingerprint chunks from disk
- Update k-selection table with both GPU and CPU fit times on 100M Enamine molecules (GPU: 1.7 min to 17.6 min vs CPU: 1.3h to 26.4h) - Add scripts/k_selection_gpu.py for reproducible GPU k-selection - Remove outdated CPU-only scaling note
- Change MQN fingerprint dtype from uint8 to int16 (values can exceed 255 for large molecules) - Guard torch.cuda monkeypatch with importorskip for CI without CUDA - Update test assertions to match correct dtypes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmarks
1B Enamine REAL molecules (RTX 4070 Ti SUPER 16GB):
k-selection on 100M: GPU fit times: 1.7 min (k=10K) to 17.6 min (k=200K), vs 1.3h to 26.4h on CPU (45-90x speedup).