Repository navigation
fix(cache): persist regenerated responses after invalid cache entries - #1474
Open
Cookie0103 wants to merge 1 commit into
Open
Cookie0103 wants to merge 1 commit into
Cookie0103 wants to merge 1 commit into
Conversation
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.
What changes
Allow
SampleCacheto persist regenerated responses when the previous Parquet row cannot be decoded as aModelResponse.Startup indexing already skips undecodable rows so those docs will be recomputed. However,
cache_samplesbuilds its duplicate-ID set from every old row, keeps the invalid one, and discards the replacement. The@cachedwrapper then reloads the same invalid row and raises. In a legacy-schema file, Arrow can also carry the obsolete response field into newly appended rows.Validate old rows with the same
_load_samplecriterion before merging. Discard rejected rows with a count warning, retain valid cached work and its existing precedence, and append regenerated responses. Cache keys, layout, public APIs and validation criteria are unchanged.Example: a cache containing a valid response for
goodand a null response forbad, followed by a request for[new, good, bad], now computes only[new, bad], returns all three responses in request order, and reuses all three after reopening. An obsolete response-schema field is covered separately.Tests
Real local Parquet files and the real
@cachedwrapper, with a scripted model body; no provider credentials or GPU inference.b97a6533bec22c4184b88526366fdf5d73d502c9: 6 failed, 1 passed. The failures reproduce null/obsolete-schema response loading, across GENERATIVE, LOGPROBS and PERPLEXITY.test_cache_recovery.py,test_utils.py,test_model_input.py,test_cache_directory_structure,test_cache_sglang): 18 passed, 9 subtests passed separately.pre-commit run --all-filesand hooks on both changed files: passed.git diff --check: passed.Environment: macOS ARM64, Python 3.12.13, editable
.[dev]installation. Concurrent writers, atomic file replacement, cache identity changes and stronger response validation are outside this repair.AI assistance: OpenAI Codex investigated, implemented, tested and performed a separate AI review. The account owner has not personally reviewed or run these tests.