-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
[Bugfix] Respect VLLM_WEIGHT_OFFLOADING_DISABLE_PIN_MEMORY in prefetch offloader #37699
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
vllm-bot
merged 3 commits into
vllm-project:main
from
he-yufeng:fix/prefetch-offload-disable-pin-memory
Apr 15, 2026
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 logic to decide whether to use pinned memory,
is_pin_memory_available() and not envs.VLLM_WEIGHT_OFFLOADING_DISABLE_PIN_MEMORY, is now duplicated in three places within this file. This creates a maintenance risk, as future changes to this logic might not be applied consistently across all locations, potentially re-introducing bugs.To improve maintainability, I recommend extracting this logic into a single, module-level helper function.
For example:
This function can then be used in all three modified locations:
_CpuParamOffloader._offload_to_cpu_internal(this location):_CpuParamOffloader._update_cpu_storage_from_param:PrefetchOffloader.start_onload_to_static:This refactoring will make the code cleaner, less error-prone, and easier to understand and modify in the future.
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.
@gemini-code-assist This is not just limited to prefetch.py. You need to take a look at all files in
vllm/model_executor/offloader.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.
You are absolutely correct, @he-yufeng. My apologies for the oversight. I will expand the scope of the refactoring to include all relevant files within the
vllm/model_executor/offloaderdirectory to ensure consistency in handling theVLLM_WEIGHT_OFFLOADING_DISABLE_PIN_MEMORYenvironment variable.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.
Good point, thanks for the catch. I went through every file in
vllm/model_executor/offloader/:base.py— added a sharedshould_pin_memory()helper that consolidates theis_pin_memory_available() and not envs.VLLM_WEIGHT_OFFLOADING_DISABLE_PIN_MEMORYcheckprefetch.py— all 3 call sites now use the helperuva.py— switched to the same helper (was already correct, just DRY'd it up)prefetch_ops.py— no pin memory usage, nothing to change__init__.py— just exports, addedshould_pin_memoryAlso noted there's one more instance in
model_loader/utils.py(outside the offloader dir) that could be migrated to the helper in a follow-up if desired.