Repository navigation
perf(consolidation): look up recalled observations by id - #6406
Merged
Merged
Conversation
The recalled observations are now kept in one dict, filled once in recall order, instead of a list plus a set of ids beside it. The delete check, the merge-target check and the update lookup read that dict directly, rather than copying the id set on every merge and scanning the list on every update. No behaviour change: the observation list handed to the prompt is the same objects in the same order, and every delete/merge/update decision is the same. Checked by comparing old and new logic on 200k random inputs and by running both side by side on every batch of the api-slim suite. Adds a regression test that a merge moves its evidence only onto an observation the model was shown; it fails with the target check removed. Closes #6324 Co-authored-by: harshitgupta31415 <[email protected]>
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.
Closes #6324. Patch by @harshitgupta31415 (credited as co-author), plus a regression test.
What changes
The recalled observations are kept in one dict, filled once in recall order. The delete check, the merge-target check and the update lookup read it directly, instead of a list plus a set of ids beside it, a copy of that set for every merge, and a scan of the list for every update.
This is a cleanup more than a speed fix: the saved time is microseconds per batch, next to a model call that takes seconds.
No behaviour change
Nonetargets): identical results every time.Test
tests/test_consolidation_merge_target.py: a merge delete moves its evidence onto an observation the model was shown, never onto one it was not shown. Removing the target check makes it fail.