Skip to content

feat: share multimodal hash helpers#4704

Open
CUHKSZzxy wants to merge 3 commits into
InternLM:mainfrom
CUHKSZzxy:feat/share-vl-mm-hasher
Open

feat: share multimodal hash helpers#4704
CUHKSZzxy wants to merge 3 commits into
InternLM:mainfrom
CUHKSZzxy:feat/share-vl-mm-hasher

Conversation

@CUHKSZzxy

Copy link
Copy Markdown
Collaborator

Summary

  • move multimodal content hashing into a shared VL helper
  • update PyTorch prefix-cache paths to use the shared helper while preserving existing cache-key behavior
  • populate dict-style multimodal content hashes before TurboMind conversion when prefix caching is enabled

Validation

  • Focused VL hasher unit tests passed
  • PyTorch block-trie prefix-cache unit tests passed
  • Real PyTorch VL server repeated-image check showed cache reuse on a cacheable repeated multimodal prompt

Assistance

Assisted with Codex + GPT-5.5 xHigh Fast, reviewed manually

@CUHKSZzxy CUHKSZzxy marked this pull request as ready for review June 25, 2026 09:28
Copilot AI review requested due to automatic review settings June 25, 2026 09:28

Copilot AI left a comment

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.

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.py with 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants