Skip to content
Merged
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
7 changes: 6 additions & 1 deletion vllm/v1/attention/backends/flashinfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,12 @@ def __init__(
"earlier GPUs."
)
# Preparing persistent buffers
self.pin_memory = is_pin_memory_available()
# Since we do not have explicit synchronization in ModelRunnerV2, we do not pin
# reused CPU buffers to avoid a race condition between step N async copies to
# GPU and step N+1 buffer updates.
self.pin_memory = (
not envs.VLLM_USE_V2_MODEL_RUNNER and is_pin_memory_available()
Comment on lines +609 to +610

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The decision to disable pin_memory is critical for ModelRunnerV2 due to its lack of explicit synchronization, as noted in the comment. However, relying on the global envs.VLLM_USE_V2_MODEL_RUNNER environment variable introduces a tight coupling between FlashInferMetadataBuilder and the global state. This approach can make the system harder to reason about, test, and debug, especially if the activation of ModelRunnerV2 is not perfectly synchronized with the environment variable's state. For improved modularity and explicitness, consider passing a use_v2_model_runner boolean parameter directly to the FlashInferMetadataBuilder constructor. This would ensure that the pin_memory behavior is directly controlled by the active ModelRunner instance rather than an implicit global flag.

)
self.paged_kv_indptr = self._make_buffer(max_num_reqs + 1)
self.paged_kv_indptr_cpu_buffer = torch.zeros_like(
self.paged_kv_indptr.cpu, pin_memory=self.pin_memory
Expand Down
Loading