Fix cache position phase detection 🤖🤖🤖#243
Open
fallintoplace wants to merge 1 commit into
Open
Conversation
Signed-off-by: Minh Vu <[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.
Summary
is_prefillinghelper based on zero-basedcache_positionlength.Root cause
cache_positionis zero-based, so checks likecache_position[-1] <= q_lenmissed the+1when comparing againstq_len. That madecache_position=[1]withq_len=1look like prefill even though it is the first decode step after a one-token prompt.Validation
uv run pytest tests/test_phase_detection.pyuv run pytest tests/test_decoding_compression.py::test_decoding_press_reuse_across_sequencesuv run flake8 kvpress/presses/base_press.py kvpress/presses/decoding_press.py kvpress/presses/prefill_decoding_press.py kvpress/presses/cam_press.py kvpress/presses/dms_press.py kvpress/presses/fastkvzip_press.py tests/test_phase_detection.pyuv run mypy kvpress/presses/base_press.py kvpress/presses/decoding_press.py kvpress/presses/prefill_decoding_press.py kvpress/presses/cam_press.py kvpress/presses/dms_press.py kvpress/presses/fastkvzip_press.py --check-untyped-defsmake style