Skip to content

Conversation

@FanhaiLu1
Copy link
Collaborator

This PR adds two classes, fundamental for page attention in JetStream:

PageAttentionManager:

This class manages and frees page resources, calculates page metadata, and supports cache insertion.

PageKVCacheGenerate:

This class updates decode caches in a page-attention format. Unlike the standard LLM KV cache shape ([batch_size, num_heads, seq_len, head_dim]), PageKVCache uses the shape [num_heads, total_num_pages, page_size, head_dim].

page_size: int,
max_pages_per_sequence: int,
):
self.unused_pages = queue.Queue()
Copy link
Collaborator

Choose a reason for hiding this comment

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

use deque

Copy link
Collaborator Author

@FanhaiLu1 FanhaiLu1 Aug 6, 2024

Choose a reason for hiding this comment

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

Current jet stream implementation's detokenize_threads and _generate_threads are different thread, both of them need to access this queue. So the queue should be thread safe, but deque is not thread safe.

@FanhaiLu1 FanhaiLu1 merged commit eb360ee into AI-Hypercomputer:main Aug 6, 2024
@FanhaiLu1 FanhaiLu1 deleted the pa_decode_checkin_2 branch August 9, 2024 18:00
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