Skip to content

fix pin memory device #755

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

Merged
merged 2 commits into from
Jan 27, 2025
Merged
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
8 changes: 6 additions & 2 deletions flashinfer/decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ def __init__(
(8 * 1024 * 1024,), dtype=torch.uint8, device=self.device
)
self._pin_memory_int_workspace_buffer = torch.empty(
(8 * 1024 * 1024,), dtype=torch.uint8, pin_memory=True
(8 * 1024 * 1024,), dtype=torch.uint8,
pin_memory=True, device="cpu",
)

if use_cuda_graph:
Expand Down Expand Up @@ -718,6 +719,7 @@ def reset_workspace_buffer(
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape,
dtype=self._int_workspace_buffer.dtype,
device="cpu",
pin_memory=True,
)

Expand Down Expand Up @@ -1277,7 +1279,8 @@ def __init__(
(8 * 1024 * 1024,), dtype=torch.uint8, device=self.device
)
self._pin_memory_int_workspace_buffer = torch.empty(
(8 * 1024 * 1024,), dtype=torch.uint8, pin_memory=True
(8 * 1024 * 1024,), dtype=torch.uint8,
pin_memory=True, device="cpu",
)

if use_cuda_graph:
Expand Down Expand Up @@ -1330,6 +1333,7 @@ def reset_workspace_buffer(
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape,
dtype=self._int_workspace_buffer.dtype,
device="cpu",
pin_memory=True,
)

Expand Down
8 changes: 6 additions & 2 deletions flashinfer/prefill.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ def __init__(
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape,
dtype=self._int_workspace_buffer.dtype,
device="cpu",
pin_memory=True,
)
self._use_cuda_graph = use_cuda_graph
Expand Down Expand Up @@ -1165,6 +1166,7 @@ def reset_workspace_buffer(
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape,
dtype=self._int_workspace_buffer.dtype,
device="cpu",
pin_memory=True,
)

Expand Down Expand Up @@ -1415,7 +1417,7 @@ def plan(
if page_size != 1:
vector_sparse_indptr_host = torch.cat(
[
torch.tensor([0], dtype=torch.int32),
torch.tensor([0], dtype=torch.int32, device=kv_lens_arr_host.device),
torch.cumsum(kv_lens_arr_host, dim=0, dtype=torch.int32),
],
dim=0,
Expand Down Expand Up @@ -1858,7 +1860,8 @@ def __init__(
(8 * 1024 * 1024,), dtype=torch.uint8, device=self.device
)
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape, dtype=torch.uint8, pin_memory=True
self._int_workspace_buffer.shape, dtype=torch.uint8,
pin_memory=True, device="cpu",
)
self._use_cuda_graph = use_cuda_graph
if use_cuda_graph:
Expand Down Expand Up @@ -1911,6 +1914,7 @@ def reset_workspace_buffer(
self._pin_memory_int_workspace_buffer = torch.empty(
self._int_workspace_buffer.shape,
dtype=self._int_workspace_buffer.dtype,
device="cpu",
pin_memory=True,
)

Expand Down