-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
minor: zero workspace buffer init for flashinfer trtllm-gen attn #22603
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -113,7 +113,7 @@ def test_flashinfer_trtllm_decode_with_baseline( | |||||
kv_indices = torch.tensor(kv_indices, dtype=torch.int32) | ||||||
kv_last_page_lens = torch.tensor(kv_last_page_lens, dtype=torch.int32) | ||||||
|
||||||
workspace_buffer = torch.empty(128 * 1024 * 1024, dtype=torch.int8) | ||||||
workspace_buffer = torch.zeros(128 * 1024 * 1024, dtype=torch.int8) | ||||||
wrapper = flashinfer.BatchDecodeWithPagedKVCacheWrapper( | ||||||
workspace_buffer, | ||||||
kv_layout, | ||||||
|
@@ -247,7 +247,7 @@ def test_flashinfer_trtllm_prefill_with_baseline( | |||||
kv_indices = torch.tensor(kv_indices, dtype=torch.int32) | ||||||
kv_last_page_lens = torch.tensor(kv_last_page_lens, dtype=torch.int32) | ||||||
|
||||||
workspace_buffer = torch.empty(128 * 1024 * 1024, dtype=torch.int8) | ||||||
workspace_buffer = torch.zeros(128 * 1024 * 1024, dtype=torch.int8) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The workspace buffer here is created with
Suggested change
|
||||||
wrapper = flashinfer.BatchPrefillWithPagedKVCacheWrapper( | ||||||
workspace_buffer, kv_layout) | ||||||
wrapper.plan(q_indptr, | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,7 @@ def __init__(self, kv_cache_spec: AttentionSpec, layer_names: list[str], | |
|
||
def _get_workspace_buffer(self): | ||
if self._workspace_buffer is None: | ||
self._workspace_buffer = torch.empty( | ||
self._workspace_buffer = torch.zeros( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also need to update in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Thanks for your review! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for accidentally pushing to another PR. It's added now. |
||
FLASHINFER_WORKSPACE_BUFFER_SIZE, | ||
dtype=torch.uint8, | ||
device=self.device) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workspace buffer is created with
torch.int8
dtype, while the main implementation invllm/v1/attention/backends/flashinfer.py
usestorch.uint8
. While this might not cause issues with a zero-initialized buffer, using an inconsistent data type can lead to subtle bugs if the underlying kernel has specific expectations about the data being signed or unsigned. For consistency and to prevent potential correctness issues, it's recommended to usetorch.uint8
here.