Skip to content

[IN REVIEW] refactor(multimodal): use standalone llm-multimodal crate - #1911

Open
BugenZhao wants to merge 2 commits into
smg-project:mainfrom
BugenZhao:bz/standalone-llm-multimodal
Open

[IN REVIEW] refactor(multimodal): use standalone llm-multimodal crate#1911
BugenZhao wants to merge 2 commits into
smg-project:mainfrom
BugenZhao:bz/standalone-llm-multimodal

Conversation

@BugenZhao

@BugenZhao BugenZhao commented Jul 13, 2026

Copy link
Copy Markdown

Description

Problem

llm-multimodal now lives in a standalone repository, while SMG retained an in-tree copy. The two copies have already accumulated changes independently, creating duplicate ownership for preprocessing behavior, fixtures, CI, and releases.

Solution

Use smg-project/llm-multimodal as the source of truth.

SMG now depends on the standalone crate at revision 7df38e53, while retaining version = "1.7.1" so Cargo uses the pinned Git revision during development and the crates.io version when packaging SMG.

Changes

  • Replace the workspace path dependency with a versioned and revision-pinned Git dependency.
  • Adapt SMG's TokenizerTrait to the standalone crate's narrow Tokenizer interface.
  • Use the standalone default features: rustls-tls and hf-hub.
  • Preserve explicit opencv-video feature forwarding from SMG.
  • Remove the in-tree crates/multimodal implementation and fixtures.
  • Remove stale SMG release, Golden Fixtures, CODEOWNERS, labeler, cache, and path-filter entries.
  • Keep the SMG-side dependency build check and make root Cargo.toml changes trigger the relevant integration tests.

The diff of generated Cargo.lock is clean:

diff --git a/Cargo.lock b/Cargo.lock
index 58771160..78bbf557 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3766,22 +3766,18 @@ checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092"
 [[package]]
 name = "llm-multimodal"
 version = "1.7.1"
+source = "git+https://github.com/smg-project/llm-multimodal.git?rev=7df38e53f99aefaebe86934f010aa8084ec99b2f#7df38e53f99aefaebe86934f010aa8084ec99b2f"
 dependencies = [
  "anyhow",
  "base64 0.22.1",
  "blake3",
  "bytes",
  "cc",
- "criterion",
  "fast_image_resize",
- "futures",
  "hf-hub",
- "http",
  "image",
  "libloading",
- "llm-tokenizer",
  "ndarray",
- "npyz",
  "once_cell",
  "opencv",
  "pkg-config",
@@ -3789,8 +3785,8 @@ dependencies = [
  "reqwest 0.13.4",
  "rustfft",
  "serde",
- "serde_bytes",
  "serde_json",
+ "serde_with",
  "symphonia",
  "tempfile",
  "thiserror 2.0.18",
@@ -6818,16 +6814,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "serde_bytes"
-version = "0.11.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
-dependencies = [
- "serde",
- "serde_core",
-]
-
 [[package]]
 name = "serde_core"
 version = "1.0.228"

Test Plan

Checklist
  • cargo +nightly fmt passes
  • cargo clippy --all-targets --all-features -- -D warnings passes
  • (Optional) Documentation updated
  • (Optional) Please join us on Slack #sig-smg to discuss, review, and merge PRs

Summary by CodeRabbit

Summary by CodeRabbit

  • Refactor

    • Switched multimodal processing to the externally maintained llm-multimodal package (the in-repo multimodal crate was removed from the workspace).
    • Updated gateway multimodal integration to use a tokenizer adapter for placeholder tokens.
    • Added WebAssembly support to the workspace.
  • Chores

    • Removed in-repository multimodal implementation artifacts (benchmarks, golden fixtures, and related tests) and updated release/version checks.
  • CI / Automation

    • Updated CI path filters/labels and adjusted nightly benchmark cache behavior; removed a Python golden-fixture generation step from PR tests.
  • Release

    • Excluded llm-multimodal from the tier2 publish matrix.

@BugenZhao BugenZhao changed the title Bz/standalone llm multimodal refactor(multimodal): use standalone llm-multimodal crate Jul 13, 2026
@github-actions github-actions Bot added dependencies Dependency updates ci CI/CD configuration changes grpc gRPC client and router changes tests Test changes multimodal Multimodal crate changes model-gateway Model gateway crate changes labels Jul 13, 2026
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR removes the in-repository multimodal crate, switches llm-multimodal to a pinned git dependency, adds a gateway tokenizer adapter, and updates CI, release, ownership, labeling, benchmark, and documentation references.

Changes

Multimodal dependency transition

Layer / File(s) Summary
External dependency and gateway adapter
Cargo.toml, model_gateway/..., crates/grpc_client/proto/...
The workspace consumes a pinned external llm-multimodal dependency, while gateway metadata construction uses MultimodalTokenizer to implement the external tokenizer interface.
Local multimodal implementation removal
Cargo.toml, crates/multimodal/...
The local multimodal crate is removed from workspace membership and its processors, media helpers, OpenCV capture code, and preprocessing tooling are deleted.
Automation and release updates
.github/..., .pre-commit-config.yaml, scripts/check_release_versions.sh
Repository automation no longer assigns, labels, tests, caches, publishes, or version-checks the local multimodal crate.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MultimodalPlan
  participant MultimodalTokenizer
  participant TokenizerTrait
  participant ModelMetadata
  MultimodalPlan->>MultimodalTokenizer: wrap tokenizer
  MultimodalTokenizer->>TokenizerTrait: forward token lookup and text encoding
  MultimodalTokenizer->>ModelMetadata: provide external tokenizer implementation
Loading

Possibly related PRs

Suggested labels: workflow

Suggested reviewers: slin1237, key4ng, catherinesue, xinyuezhang369, gongwei-130

Poem

A rabbit hops past crates gone still,
While tokens cross the gateway hill.
Old vision paths fade from sight,
A pinned git hop guides the flight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: switching to the standalone llm-multimodal crate.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request removes the crates/multimodal crate from the workspace, updates related configuration files like CODEOWNERS and labeler.yml, and updates documentation references. Additionally, the llm-multimodal dependency is now sourced from a remote git repository. I have no further feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/pr-test-rust.yml (1)

302-303: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove the stale fixture-generation reference.

.gitignore:130 still instructs developers to run the removed generate_vision_golden.py script. Delete or update that entry in this PR so repository guidance matches the removal.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pr-test-rust.yml around lines 302 - 303, Update the stale
`.gitignore` guidance entry for `generate_vision_golden.py` to remove it or
replace it with the current fixture-generation workflow, ensuring repository
instructions no longer reference the removed script.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/pr-test-rust.yml:
- Line 275: Update the workflow step named “Verify default multimodal dependency
build does not require OpenCV” to stop invoking the non-workspace
`llm-multimodal` package via `cargo check -p`. Check an in-workspace consumer of
that git dependency or use an appropriate standalone manifest while preserving
the OpenCV-free default-build verification.

---

Outside diff comments:
In @.github/workflows/pr-test-rust.yml:
- Around line 302-303: Update the stale `.gitignore` guidance entry for
`generate_vision_golden.py` to remove it or replace it with the current
fixture-generation workflow, ensuring repository instructions no longer
reference the removed script.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cad9ddb4-6887-4103-8e5d-fd587c06d198

📥 Commits

Reviewing files that changed from the base of the PR and between 4219188 and 3ee8aaf.

⛔ Files ignored due to path filters (10)
  • crates/multimodal/tests/fixtures/images/grayscale.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/large.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/odd_dims.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/small.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/square.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/tall.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/tiny.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/very_tall.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/very_wide.jpg is excluded by !**/*.jpg
  • crates/multimodal/tests/fixtures/images/wide.jpg is excluded by !**/*.jpg
📒 Files selected for processing (69)
  • .github/CODEOWNERS
  • .github/labeler.yml
  • .github/workflows/nightly-benchmark.yml
  • .github/workflows/pr-test-rust.yml
  • .github/workflows/release-crates.yml
  • .pre-commit-config.yaml
  • Cargo.toml
  • crates/grpc_client/proto/tokenspeed_scheduler.proto
  • crates/multimodal/Cargo.toml
  • crates/multimodal/benches/image_preprocess.rs
  • crates/multimodal/build.rs
  • crates/multimodal/scripts/generate_qwen_preprocess_fingerprints.py
  • crates/multimodal/scripts/generate_vision_golden.py
  • crates/multimodal/src/audio/decode.rs
  • crates/multimodal/src/audio/mod.rs
  • crates/multimodal/src/audio/processor.rs
  • crates/multimodal/src/audio/processors/mod.rs
  • crates/multimodal/src/audio/processors/qwen3_audio.rs
  • crates/multimodal/src/audio/transforms.rs
  • crates/multimodal/src/encoder_inputs.rs
  • crates/multimodal/src/error.rs
  • crates/multimodal/src/hasher.rs
  • crates/multimodal/src/hub.rs
  • crates/multimodal/src/jpeg_turbo.rs
  • crates/multimodal/src/lib.rs
  • crates/multimodal/src/media.rs
  • crates/multimodal/src/opencv_buffer.rs
  • crates/multimodal/src/opencv_buffer_capture.cpp
  • crates/multimodal/src/registry/kimi_k25.rs
  • crates/multimodal/src/registry/llama4.rs
  • crates/multimodal/src/registry/llava.rs
  • crates/multimodal/src/registry/mod.rs
  • crates/multimodal/src/registry/phi3_v.rs
  • crates/multimodal/src/registry/qwen3_asr.rs
  • crates/multimodal/src/registry/qwen3_omni.rs
  • crates/multimodal/src/registry/qwen3_vl.rs
  • crates/multimodal/src/registry/qwen_vl.rs
  • crates/multimodal/src/registry/traits.rs
  • crates/multimodal/src/tracker.rs
  • crates/multimodal/src/types.rs
  • crates/multimodal/src/vision/execution.rs
  • crates/multimodal/src/vision/mod.rs
  • crates/multimodal/src/vision/preprocessor_config.rs
  • crates/multimodal/src/vision/processor.rs
  • crates/multimodal/src/vision/processors/kimi_k25.rs
  • crates/multimodal/src/vision/processors/llama4_vision.rs
  • crates/multimodal/src/vision/processors/llava.rs
  • crates/multimodal/src/vision/processors/mod.rs
  • crates/multimodal/src/vision/processors/phi3_vision.rs
  • crates/multimodal/src/vision/processors/phi4_vision.rs
  • crates/multimodal/src/vision/processors/pixtral.rs
  • crates/multimodal/src/vision/processors/qwen2_vl.rs
  • crates/multimodal/src/vision/processors/qwen3_omni_vision.rs
  • crates/multimodal/src/vision/processors/qwen3_vl.rs
  • crates/multimodal/src/vision/processors/qwen_vl_base.rs
  • crates/multimodal/src/vision/scratch.rs
  • crates/multimodal/src/vision/transforms.rs
  • crates/multimodal/tests/decode_preprocess_bench.rs
  • crates/multimodal/tests/fixtures/golden/qwen_preprocess_fingerprints.json
  • crates/multimodal/tests/multimodal_tracker_test.rs
  • crates/multimodal/tests/preprocess_fingerprint.rs
  • crates/multimodal/tests/qwen_preprocess_golden.rs
  • crates/multimodal/tests/resize_fingerprint.rs
  • crates/multimodal/tests/vision_golden_tests.rs
  • model_gateway/Cargo.toml
  • model_gateway/src/routers/grpc/multimodal/mod.rs
  • model_gateway/src/routers/grpc/multimodal/plan.rs
  • model_gateway/src/routers/grpc/multimodal/process.rs
  • scripts/check_release_versions.sh
💤 Files with no reviewable changes (60)
  • crates/multimodal/tests/preprocess_fingerprint.rs
  • crates/multimodal/tests/multimodal_tracker_test.rs
  • crates/multimodal/Cargo.toml
  • crates/multimodal/tests/fixtures/golden/qwen_preprocess_fingerprints.json
  • crates/multimodal/tests/resize_fingerprint.rs
  • crates/multimodal/build.rs
  • crates/multimodal/src/media.rs
  • crates/multimodal/src/error.rs
  • crates/multimodal/benches/image_preprocess.rs
  • .github/CODEOWNERS
  • crates/multimodal/src/audio/processors/mod.rs
  • crates/multimodal/src/vision/mod.rs
  • crates/multimodal/src/vision/execution.rs
  • crates/multimodal/src/hasher.rs
  • crates/multimodal/src/opencv_buffer_capture.cpp
  • crates/multimodal/tests/qwen_preprocess_golden.rs
  • .pre-commit-config.yaml
  • .github/workflows/release-crates.yml
  • crates/multimodal/src/registry/traits.rs
  • crates/multimodal/src/registry/llama4.rs
  • crates/multimodal/src/vision/processors/mod.rs
  • crates/multimodal/src/tracker.rs
  • crates/multimodal/src/jpeg_turbo.rs
  • crates/multimodal/src/registry/qwen3_omni.rs
  • .github/labeler.yml
  • crates/multimodal/src/opencv_buffer.rs
  • crates/multimodal/src/registry/kimi_k25.rs
  • crates/multimodal/src/registry/qwen_vl.rs
  • crates/multimodal/src/registry/qwen3_asr.rs
  • crates/multimodal/src/registry/phi3_v.rs
  • crates/multimodal/src/audio/mod.rs
  • crates/multimodal/src/registry/llava.rs
  • crates/multimodal/src/encoder_inputs.rs
  • crates/multimodal/src/hub.rs
  • crates/multimodal/src/vision/processors/pixtral.rs
  • crates/multimodal/tests/decode_preprocess_bench.rs
  • crates/multimodal/src/vision/processors/phi4_vision.rs
  • crates/multimodal/scripts/generate_vision_golden.py
  • crates/multimodal/scripts/generate_qwen_preprocess_fingerprints.py
  • crates/multimodal/src/audio/decode.rs
  • crates/multimodal/src/registry/mod.rs
  • crates/multimodal/src/lib.rs
  • crates/multimodal/src/vision/processors/kimi_k25.rs
  • crates/multimodal/src/vision/scratch.rs
  • crates/multimodal/src/registry/qwen3_vl.rs
  • crates/multimodal/src/vision/processors/llama4_vision.rs
  • crates/multimodal/src/vision/processors/phi3_vision.rs
  • scripts/check_release_versions.sh
  • crates/multimodal/src/vision/processor.rs
  • crates/multimodal/src/vision/preprocessor_config.rs
  • crates/multimodal/src/types.rs
  • crates/multimodal/src/vision/processors/llava.rs
  • crates/multimodal/src/audio/processors/qwen3_audio.rs
  • crates/multimodal/src/vision/processors/qwen3_omni_vision.rs
  • crates/multimodal/src/vision/processors/qwen3_vl.rs
  • crates/multimodal/src/vision/processors/qwen_vl_base.rs
  • crates/multimodal/src/audio/processor.rs
  • crates/multimodal/src/vision/transforms.rs
  • crates/multimodal/src/audio/transforms.rs
  • crates/multimodal/src/vision/processors/qwen2_vl.rs

Comment thread .github/workflows/pr-test-rust.yml

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ee8aafa58

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Cargo.toml Outdated
@mergify

mergify Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Hi @BugenZhao, this PR has merge conflicts that must be resolved before it can be merged. Please rebase your branch:

git fetch origin main
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

@mergify mergify Bot added the needs-rebase PR has merge conflicts that need to be resolved label Jul 13, 2026
@BugenZhao
BugenZhao force-pushed the bz/standalone-llm-multimodal branch from 3ee8aaf to 9725c66 Compare July 14, 2026 04:37
@mergify mergify Bot removed the needs-rebase PR has merge conflicts that need to be resolved label Jul 14, 2026
@BugenZhao
BugenZhao force-pushed the bz/standalone-llm-multimodal branch from 9725c66 to 8af1e38 Compare July 14, 2026 04:49
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
Signed-off-by: Bugen Zhao <i@bugenzhao.com>
@BugenZhao
BugenZhao force-pushed the bz/standalone-llm-multimodal branch from 8af1e38 to 5ab8477 Compare July 14, 2026 06:10
@lightseek-bot lightseek-bot changed the title refactor(multimodal): use standalone llm-multimodal crate [IN REVIEW] refactor(multimodal): use standalone llm-multimodal crate Jul 14, 2026
@mergify

mergify Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Hi @BugenZhao, this PR has merge conflicts that must be resolved before it can be merged. Please rebase your branch:

git fetch origin main
git rebase origin/main
# resolve any conflicts, then:
git push --force-with-lease

@mergify mergify Bot added the needs-rebase PR has merge conflicts that need to be resolved label Jul 16, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity within 14 days. It will be automatically closed if no further activity occurs within 16 days. Leave a comment if you feel this pull request should remain open. Thank you!

@github-actions github-actions Bot added the stale PR has been inactive for 14+ days label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD configuration changes dependencies Dependency updates grpc gRPC client and router changes model-gateway Model gateway crate changes multimodal Multimodal crate changes needs-rebase PR has merge conflicts that need to be resolved priority:high High priority stale PR has been inactive for 14+ days tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants