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

[KV Cache] Overwrite Cache - SW Attention #297

Closed
wants to merge 6 commits into from

Conversation

davidpissarra
Copy link
Member

Part of the effort on Sliding Window Attention (SWA) mlc-ai/mlc-llm#1003. Overwriting the cache is useful when computing SWA, so we can have a more efficient cache only containing the current window keys and values. Once the cache is full we start overwriting the older entries.

@davidpissarra davidpissarra changed the title [KV Cache] Overwrite SW Attention [KV Cache] Overwrite Cache - SW Attention Oct 15, 2023
@@ -159,6 +232,7 @@ class AttentionKVCache : public ObjectRef {
n->Append(init_data);
if (init_fill_count >= 0) {
n->fill_count = init_fill_count;
n->current_pos = init_fill_count; // sliding window attention only
Copy link
Contributor

Choose a reason for hiding this comment

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

window_attention_current_pos

* \brief Append value to the cache.
* \param value The value to overwrite previous elements.
*/
void Overwrite(NDArray value, int64_t max_cache_size) {
Copy link
Contributor

Choose a reason for hiding this comment

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

WindowOverride

@tqchen
Copy link
Contributor

tqchen commented Oct 21, 2023

Thanks @davidpissarra . The main comment is that given the impl is specialized to window, let us make sure tha API naming highlights the fact

@tqchen
Copy link
Contributor

tqchen commented Oct 21, 2023

please also send the PR to unity branch of https://github.com/apache/tvm

@tqchen tqchen closed this Oct 22, 2023
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.

2 participants