feat: share multimodal hash helpers#4704
Open
CUHKSZzxy wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes multimodal content hashing into a shared lmdeploy.vl helper module, then updates PyTorch prefix-cache code paths (and tests) to use the shared implementation while keeping existing cache-key behavior stable.
Changes:
- Added
lmdeploy/vl/hasher.pywith deterministic hashing helpers for both dataclass-style and dict-style multimodal payloads. - Rewired PyTorch prefix-cache hashing call sites to use the shared VL hasher (including unit test monkeypatch targets).
- Added focused unit tests covering hash stability, sensitivity to content/meta/mRoPE, and ignoring position-only keys for dict-style items.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lmdeploy/vl/hasher.py |
Introduces shared deterministic multimodal hashing + “ensure content_hash” helpers for two multimodal representations. |
lmdeploy/pytorch/multimodal/data_type.py |
Removes local hashing implementation and re-exports shared hashing helpers for compatibility. |
lmdeploy/pytorch/messages.py |
Updates prefix-cache meta hashing fallback to call the shared VL hasher. |
lmdeploy/pytorch/engine/engine.py |
Ensures multimodal content hashes are populated after preprocessing when prefix caching is enabled. |
tests/test_lmdeploy/test_vl/test_hasher.py |
Adds unit tests validating hash determinism and correct inclusion/exclusion rules. |
tests/pytorch/paging/test_block_trie.py |
Adjusts monkeypatching to target the shared hasher module instead of the previous PyTorch-local symbol. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Validation
Assistance
Assisted with Codex + GPT-5.5 xHigh Fast, reviewed manually