Cover reused search-query batch rows with tests - #91
Open
jnadeau207-collab wants to merge 1 commit into
Open
Conversation
Author
|
Contribution by Jesse Nadeau @villain_thropic on X |
Extract the RankingBatchPrep search-query fill into fill_candidate_search_query_embeddings and pin the rows the per-item write never touches: items whose input_buffer is None, rows past length_of_input in a reused array, and an empty or wrong-width query. Production behavior is unchanged; each test fails if the sq_slice.fill(0.0) guard is removed.
jnadeau207-collab
force-pushed
the
fix/stale-search-query-embeddings
branch
from
September 2, 2026 23:06
de9f975 to
1d55fc9
Compare
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.
Context
The original version of this PR fixed a stale-search-query-embedding bug in
InputBuffer::new_with_candidatesby returning a zero vector instead of anempty one. That bug was real at the base commit this branch was cut from
(
7ba7768), whereRankingBatchPrepwrote the reused search-query array withno prior zeroing.
Upstream
85ac72alanded independently and fixed it directly, by addingsq_slice.fill(0.0)before the per-item write. That fix is strictly morecomplete than the one proposed here: it also clears rows the per-item write
never reaches. The
util.rschange is therefore redundant onmainand hasbeen dropped.
What is left
sq_slice.fill(0.0)is currently unguarded by any test. Nothing fails if it isdeleted, and the rows it protects are exactly the ones that are easiest to
overlook:
input_bufferisNone, which theif let Some(..)skips.take(length_of_input)when a batch follows a larger onesrc.len() == search_query_embedding_dimguard skipsChange
Extract the search-query fill from
RankingBatchPrep::prepareintoutil::fill_candidate_search_query_embeddingsso it is reachable from a unittest without a Python interpreter. The move is mechanical and production
behavior is unchanged.
Five tests cover the rows above, including a query-then-queryless reuse of one
array. Each of them fails if
sq_slice.fill(0.0)is removed.InputBuffergains#[derive(Default)]so a test can build one with only thetwo fields the fill path reads.