Improve GPU Hamming distance computation - #723
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #723 +/- ##
==========================================
- Coverage 78.29% 77.33% -0.96%
==========================================
Files 51 51
Lines 4607 4668 +61
==========================================
+ Hits 3607 3610 +3
- Misses 1000 1058 +58
🚀 New features to boost your workflow:
|
…lt blocks within Hamming kernel itself
676a2ec to
a2bba48
Compare
grst
left a comment
There was a problem hiding this comment.
Haven't reviewed the algorithm in detail, but the tests guarantee consistency with the reference, so this should be fine.
| gpu_block_width: int = 1000, | ||
| n_blocks: int = 1, | ||
| gpu_tile_rows: int = 100_000, | ||
| gpu_tile_cols: int = 100_000, |
There was a problem hiding this comment.
Could you please keep the previous parameters and mark them as deprecated?
It's fine if they do nothing and default values are used instead, I'd just like to avoid hard failures.
You can add a dependency on our new util package scverse-misc and use the @deprecated_arc decorator.
There was a problem hiding this comment.
you can take a look at #735 that introduces scverse-misc for deprecations across the codebase.
| `gpu_tile_buffer_cols` controls the initially reserved space for retained distances and is enlarged automatically | ||
| if necessary. | ||
|
|
||
| ### Using multiple GPUs |
There was a problem hiding this comment.
Do you think linking to the rapids-singlecell docs for advanced usage would make sense here?
Summary
This PR improves the GPU implementation of the Hamming distance metric by making the computation more memory-flexible and better suited for large datasets. The main change is that GPU Hamming computations can now be split into both row and column blocks. This replaces the previous single
gpu_n_blocksparameter withgpu_col_blocksand the newgpu_row_blocksparameter.Before, the result matrix was split only into column blocks using
gpu_n_blocks, whilegpu_block_widthcontrolled how much GPU memory was reserved for result values below the cutoff. This already assumed a certain level of sparsity to avoid reserving unnecessary amounts of memory. For larger datasets, it was difficult to choose parameters that kept the number of blocks low enough for good performance while still fitting into GPU memory. Therefore,gpu_row_blockswas introduced to also split the result matrix along the row dimension. This makes it possible to adjust the block size so that each block fits into GPU memory for larger input sizes.In first tests, the new GPU Hamming distance metric can run the largest full TCR dataset I currently have access to, containing around 8 million cells, in about 2 minutes on an NVIDIA A30 GPU. The same computation took around 35 minutes with the CPU Hamming implementation using 64 CPUs. Since this dataset is still too small for extensive stress testing, I also tested the
GPUHammingDistanceCalculatordirectly with 25 million synthetically generated unique CDR3 sequences, which took around 30 minutes on an NVIDIA A30 GPU.Main changes
API change
gpu_n_blockshas been replaced bygpu_col_blocks. A new parameter,gpu_row_blocks, has been added.