Skip to content

kv-cells : track min/max used cells and per-sequence positions #13808

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

Merged
merged 3 commits into from
May 27, 2025

Conversation

ggerganov
Copy link
Member

cont #13706

The llama_kv_cells_unified now tracks 2 new min/max quantities:

  • The min/max indices of used cells
    Mainly needed for determining the range of KV cells [0, n_kv) which are considered during the attention computation with unified KV cache (a.k.a. the old cell_max()).

  • The min/max positions for each sequence currently present in the KV cache
    Will be used in kv-cache : refactor + add llama_memory_state_i #13746 to improve the find_slot() logic in SWA cases.

To amortize the cost, we utilize std::set.

@ggerganov ggerganov force-pushed the gg/kv-cells-track-min-max branch from dc6b26d to 9bf13fd Compare May 26, 2025 15:33
@ggerganov ggerganov merged commit 8171312 into master May 27, 2025
53 checks passed
@ggerganov ggerganov deleted the gg/kv-cells-track-min-max branch May 27, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant