Accelerate rank-list construction with Numba - #142
Draft
afermg wants to merge 1 commit into
Draft
Conversation
afermg
marked this pull request as draft
September 2, 2026 17:12
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.
Stack
perf/numba-cosine)Summary
When
backend="numba"is explicitly selected for regular AP:np.lexsortcompute.ap_contiguousThe NumPy backend is byte-for-byte unchanged. The optional compiled rank kernel validates a narrow native float32/float64 score contract before JIT dispatch; malformed shapes, mismatched lengths, integer/float16/complex/object/non-native scores, and invalid pair dtypes fail safely and explicitly.
Benchmark
Synthetic JUMP-shaped rank workload: 39,858 profiles, 50,000 positive pairs, 898,101 negative pairs, and 1,896,202 directed entries. Two-run medians:
Rank-list, AP, and null-configuration digests were byte-identical; maximum AP difference was exactly zero.
Separate-process peak RSS was 172 MB for NumPy and 260 MB for Numba because loading/JIT-compiling the optional runtime costs memory despite avoiding global rank-sort temporaries. In normal use #141 has already loaded Numba for cosine, so much of that runtime overhead is shared.
Absolute times are noisy on the contended host, but cold and warm improvements and output parity were repeatable.
Exactness and validation