[Feat] Add pipelined pointer-return kernel for find* at high load factor#251
Open
rhdong wants to merge 1 commit intoNVIDIA-Merlin:masterfrom
Open
[Feat] Add pipelined pointer-return kernel for find* at high load factor#251rhdong wants to merge 1 commit intoNVIDIA-Merlin:masterfrom
rhdong wants to merge 1 commit intoNVIDIA-Merlin:masterfrom
Conversation
## Problem `find*` (pointer-return find) shows a ~61% throughput cliff at λ=1.0, dropping from ~7.0 to ~2.7 B-KV/s, while value-copy `find` stays stable at ~3.9 B-KV/s. This is logically wrong — `find*` does strictly less work than `find`, so it should never be slower. **Root cause:** `find*` dispatches to `tlp_lookup_ptr_kernel_with_filter`, a 1-thread-per-key kernel that scans bucket digests serially in 9 iterations of 16 digests each, relying on empty-slot early termination. At λ=1.0, all 128 slots are occupied, so every miss scans all 9 iterations instead of ~2. ## Solution Add `lookup_ptr_kernel_with_pipeline` — a stripped-down version of the value-copy `lookup_kernel_with_io_pipeline_v1` that returns `V*` pointers instead of copying values. - **Thread model:** 32 threads per key (cooperative group), 4 keys/block - **Pipeline:** 3-stage double-buffered (vs 4-stage in value-copy): 1. Digest prefetch (all 128 digests in 1 parallel step) 2. Digest match + key prefetch 3. Key verify + write pointer (no value copy) - **Dispatch:** `load_factor > 0.875 && max_bucket_size == 128` selects the pipelined kernel; otherwise the fast TLP kernel is used as before. ## Benchmark (H100 NVL, pure HBM, dim=8, capacity=128M) | λ | find* before | find* after | find (ref) | Δ | |------|-------------|------------|-----------|-------| | 0.50 | 6.977 | 6.942 | 3.910 | -0.5% | | 0.75 | 5.954 | 5.963 | 3.881 | +0.2% | | 1.00 | 2.688 | **4.366** | 3.929 | **+62%** | `find*` at λ=1.0 is now 11% faster than `find` (was 32% slower). No regression at low load factors.
Documentation previewhttps://nvidia-merlin.github.io/HierarchicalKV/review/pr-251 |
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.
Problem
find*(pointer-return find) shows a ~61% throughput cliff at λ=1.0, dropping from ~7.0 to ~2.7 B-KV/s, while value-copyfindstays stable at ~3.9 B-KV/s. This is logically wrong —find*does strictly less work thanfind, so it should never be slower.Root cause:
find*dispatches totlp_lookup_ptr_kernel_with_filter, a 1-thread-per-key kernel that scans bucket digests serially in 9 iterations of 16 digests each, relying on empty-slot early termination. At λ=1.0, all 128 slots are occupied, so every miss scans all 9 iterations instead of ~2.Solution
Add
lookup_ptr_kernel_with_pipeline— a stripped-down version of the value-copylookup_kernel_with_io_pipeline_v1that returnsV*pointers instead of copying values.load_factor > 0.875 && max_bucket_size == 128selects the pipelined kernel; otherwise the fast TLP kernel is used as before.Benchmark (H100 NVL, pure HBM, dim=8, capacity=128M)
find*at λ=1.0 is now 11% faster thanfind(was 32% slower). No regression at low load factors.