Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix caching improvements #758

Merged

Conversation

popovaan
Copy link
Contributor

@popovaan popovaan commented Aug 9, 2024

Applied comments from #675

@ilya-lavrenov ilya-lavrenov self-assigned this Aug 9, 2024
@ilya-lavrenov ilya-lavrenov added this to the 2024.4 milestone Aug 9, 2024
src/cpp/src/continuous_batching_pipeline.cpp Outdated Show resolved Hide resolved
src/cpp/src/sequence_group.hpp Outdated Show resolved Hide resolved
src/cpp/src/sequence_group.cpp Outdated Show resolved Hide resolved
namespace ov {
namespace genai {
size_t Sequence::_make_hash(size_t content_length) {
auto sequence_group = get_sequence_group_ptr();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add an assert that content_length corresponds to last uncomputed block? E.g. if we have 1 block with has, but content_length is 3x of block_size.

E.g. block_start_idx / block_size == m_prefix_hashes.size()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a case when block_start_idx / block_size < m_prefix_hashes.size().
When we restore blocks of prompt first we check hash of full block and it is saved in m_prefix_hashes, then if we couldn't find hash of full block in cashed_blocks we check hashes of partially completed content of this block. So content_length in this case is less than m_prefix_hashes.size() * block_size.

So I added assert block_start_idx / block_size <= m_prefix_hashes.size().

src/cpp/src/sequence_group.cpp Outdated Show resolved Hide resolved
@ilya-lavrenov ilya-lavrenov added this pull request to the merge queue Aug 14, 2024
Merged via the queue into openvinotoolkit:master with commit 762fc93 Aug 14, 2024
33 checks passed
@ilya-lavrenov ilya-lavrenov added the category: continuous batching Continuous batching label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants