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

Remove the constraint of pages_per_sequence%num_kv_pages_per_compute_… #8457

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/test_tpu_paged_attention_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def setUp(self):
q_kv_head_ratio=(1, 4, 8),
head_dim=(128, 256),
num_queries_per_compute_block=(16, 32),
block_kv_size=(128, 256),
block_kv_size=(128, 192, 256),
)
def test_paged_attention_without_query_padding(
self,
Expand Down Expand Up @@ -206,7 +206,7 @@ def test_paged_attention_without_query_padding(
q_kv_head_ratio=(1, 4, 8),
head_dim=(128, 256),
num_queries_per_compute_block=(16, 32),
block_kv_size=(128, 256),
block_kv_size=(128, 192, 256),
)
def test_paged_attention_with_query_padding(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,6 @@ def paged_attention(
raise ValueError(
f"{num_kv_pages_per_compute_block=} should be smaller or equal to {pages_per_sequence=}"
)
if pages_per_sequence % num_kv_pages_per_compute_block != 0:
raise ValueError(
"num_kv_pages_per_compute_block must be divisible by pages per sequence. Got"
f" {pages_per_sequence=} and {num_kv_pages_per_compute_block=}.")
if num_q_heads % num_kv_heads != 0:
raise ValueError(
"Number of Q heads must be divisible by number of KV heads. Got"
Expand All @@ -491,8 +487,8 @@ def paged_attention(
num_kv_heads,
pl.cdiv(query_len, num_queries_per_compute_block
), # how many compute blocks we need to loop the query_len
pages_per_sequence //
num_kv_pages_per_compute_block, # how many compute blocks we need to loop the kv_len
pl.cdiv(pages_per_sequence, num_kv_pages_per_compute_block
), # how many compute blocks we need to loop the kv_len
)

# out_shape
Expand Down
Loading