fix(sampling): preserve cached choices during scoring - #10138
Open
Excelius-Wang wants to merge 2 commits into
Open
Excelius-Wang wants to merge 2 commits into
Excelius-Wang wants to merge 2 commits 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.
PR type
PR information
When sampling from a valid cache,
generatereturns the cached choices list.do_sampleappends the ground truth to that same list, changing the cache's answer count. Reusing the cache key then misses the exact-count check and attempts generation; with--sampler_engine no, this raisesAttributeError: 'NoneType' object has no attribute 'infer'. Duplicate rows within a batch also share the mutated list.Copy the choices list before adding the ground truth. This preserves the cache while reusing the existing scoring and output logic.
Experiment results
CUDA_VISIBLE_DEVICES='' OMP_NUM_THREADS=1 HF_HUB_OFFLINE=1 \ PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 python -m pytest \ tests/general/test_sampler_cache.py \ tests/general/test_sampler_engine_kwargs.py -q pre-commit run --all-files pre-commit run isort --all-filesSwiftSampling.run, then reused it with the original dataset sampled twice via#2. The upstream method fails on the second row; the fixed method writes both scored rows and preserves the cache.Sampling and cache methods run natively; model outputs and reward scores are mocked. Full model inference and a live Ray cluster were not run.