Skip to content
Open
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
2 changes: 1 addition & 1 deletion flashinfer/prefill.py
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ def plan(
self._max_q_len = max_token_per_sequence
else:
qo_indptr_host = qo_indptr.to("cpu")
self._max_q_len = max(qo_indptr_host).item()
self._max_q_len = max(qo_indptr_host[1:] - qo_indptr_host[:-1]).item()
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This line correctly calculates the maximum query length. However, it can raise a RuntimeError if qo_indptr_host contains only one element (i.e., when batch_size is 0), because max() would be called on an empty tensor. This can be handled by checking if batch_size > 0.

self._max_q_len = (qo_indptr_host[1:] - qo_indptr_host[:-1]).max().item() if batch_size > 0 else 0

total_num_rows = int(qo_indptr_host[-1])

if max_sequence_kv is not None:
Expand Down
Loading