-
Notifications
You must be signed in to change notification settings - Fork 83
[Misc] [Offload] Update typehints, add docstrings #622
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
Open
kylesayrs
wants to merge
13
commits into
main
Choose a base branch
from
kylesayrs/fix-offload-typehints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
add30d3
Fix DeviceCache ignoring offload_device for cross-device CUDA offloading
changjonathanc b671f70
Update src/compressed_tensors/offload/cache/base.py
changjonathanc dcc360e
Update src/compressed_tensors/offload/module.py
changjonathanc 2b1ff77
Update src/compressed_tensors/offload/cache/device.py
changjonathanc bb61c93
Address review: revert offload_model, add DiskCache/CPUCache support,…
changjonathanc b4a1230
Move assert to OffloadCache.__init__, fix DiskCache caller in from_ac…
changjonathanc d5260f4
Add type hint to DiskCache.offload_device parameter
changjonathanc 0b4d57b
Merge branch 'main' into fix/device-cache-cross-device-offload
kylesayrs 1e533ac
typehints
kylesayrs d39cfcb
fix style, add docstring
kylesayrs ff07bd6
remove assert
kylesayrs df852eb
Resolve merge conflicts in 5 file(s)
coderabbitai[bot] ee19e05
Resolve merge conflicts in 5 file(s)
coderabbitai[bot] 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
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
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
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
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.
🧩 Analysis chain
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 4390
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 5353
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 543
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 2316
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 7067
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 7278
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 2514
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 192
🏁 Script executed:
Repository: vllm-project/compressed-tensors
Length of output: 6674
Type annotation mismatch:
get_execution_device()return type is incorrectThe function
get_execution_device()declares a return type oftorch.device(line 141 in__init__.py), but it directly returnsmodule._parameters.onload_devicewhich is typed asDeviceLikeTypeand can be a string. Indispatch.py(line 56), strings are assigned directly:module._parameters.onload_device = onload_devicewhere the parameter acceptstorch.device | str.While the code works in practice because callers accept
DeviceLikeType, the type contract is violated. Normalizing totorch.devicein the constructor resolves this:🔧 Suggested fix
def __init__( self, onload_device: torch.device | str, offload_device: torch.device | str | Literal["disk"] | None = None, ): super().__init__() - self.onload_device = onload_device + self.onload_device = torch.device(onload_device) self.offloaded_values = dict()🤖 Prompt for AI Agents