Skip to content

Conversation

@PeaBrane
Copy link
Contributor

@PeaBrane PeaBrane commented Jul 31, 2025

Overview:

closes #2088

Add is_mocker to LocalModelBuilder. If true, then ignore downloading weight files (matching common patterns such as .bin, .safetensors, .h5, etc). Only applies to hf paths for now.

Tests:

  • Verified that the per-merge CI tests with mockers only download the tokenizer
  • Verified other engine types still download model weights and run as normal (e.g. vllm, trtllm)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Walkthrough

The changes introduce an is_mocker flag to the LocalModelBuilder and propagate this configuration through the builder pattern in both Rust and Python entrypoints. The flag is used to skip downloading model weight files when initializing mocker engines, modifying relevant logic in model hub handling and associated tests.

Changes

Cohort / File(s) Change Summary
LocalModelBuilder: Add is_mocker flag and builder method
lib/llm/src/local_model.rs
Added is_mocker boolean field and builder method; build passes flag to model hub download logic.
Model Hub: Skip weight files if is_mocker
lib/llm/src/hub.rs
Added is_weight_file helper; from_hf signature updated to accept ignore_weights; logic skips weights if requested.
Entrypoints: Pass is_mocker flag
launch/dynamo-run/src/lib.rs, lib/bindings/python/rust/llm/entrypoint.rs
Updated to set .is_mocker() based on output/engine type when building models.
Test: Remove model download, add setup delay
tests/router/test_router_e2e_with_mockers.py
Removed explicit model download; added sleep delay after mocker start for setup.

Sequence Diagram(s)

sequenceDiagram
    participant Test as test_router_e2e_with_mockers.py
    participant Entrypoint as Python/Rust Entrypoint
    participant Builder as LocalModelBuilder
    participant Hub as Model Hub

    Test->>Entrypoint: Start mocker engine (engine_type=Mocker)
    Entrypoint->>Builder: .is_mocker(true)
    Builder->>Hub: from_hf(..., ignore_weights=true)
    Hub->>Hub: Filter out weight files if ignore_weights
    Hub-->>Builder: Download only tokenizer (no weights)
    Builder-->>Entrypoint: Build mocker engine
    Entrypoint-->>Test: Engine ready for requests
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Assessment against linked issues

Objective Addressed Explanation
Add ability for mockers to skip downloading model weights (#2088)
Ensure tokenizer is still downloaded for mockers (#2088)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

  • feat: vllm mocker enhancement #1236: Adds is_mocker flag to LocalModelBuilder and integrates mocker engine configuration, directly relating to the handling and initialization logic for mocker engines in this PR.

Poem

A flag for the mockers, so light on their feet,
No weights to download, just tokens to greet.
With builder and hub now working in sync,
The mockers can start in a flutter and blink.
🐇✨ Hooray for the code—so nimble and neat!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 97390ac and 355271b.

📒 Files selected for processing (5)
  • launch/dynamo-run/src/lib.rs (1 hunks)
  • lib/bindings/python/rust/llm/entrypoint.rs (1 hunks)
  • lib/llm/src/hub.rs (3 hunks)
  • lib/llm/src/local_model.rs (4 hunks)
  • tests/router/test_router_e2e_with_mockers.py (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: PeaBrane
PR: ai-dynamo/dynamo#1285
File: lib/llm/src/kv_router/scheduler.rs:260-266
Timestamp: 2025-05-30T06:34:12.785Z
Learning: In the KV router scheduler code, PeaBrane prefers fail-fast behavior over silent failure handling. When accessing worker metrics data that could be out-of-bounds (like dp_rank indexing), explicit panics are preferred over graceful degradation with continue statements to ensure data integrity issues are caught early.
lib/bindings/python/rust/llm/entrypoint.rs (1)

Learnt from: ryanolson
PR: #1919
File: lib/runtime/src/engine.rs:168-168
Timestamp: 2025-07-14T21:25:56.930Z
Learning: The AsyncEngineContextProvider trait in lib/runtime/src/engine.rs was intentionally changed from Send + Sync + Debug to Send + Debug because the Sync bound was overly constraining. The trait should only require Send + Debug as designed.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pre-merge-rust (.)
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: Build and Test - vllm
🔇 Additional comments (12)
launch/dynamo-run/src/lib.rs (1)

43-44: LGTM! Correctly sets mocker flag based on output type.

The use of matches! macro to set the is_mocker flag is clean and accurately identifies when the mocker engine is being used.

tests/router/test_router_e2e_with_mockers.py (2)

8-8: LGTM! Import needed for sleep functionality.


132-133: LGTM! Appropriate delay for mocker setup.

The 2-second delay allows time for tokenizer download and setup, which aligns with the new behavior where mockers skip weight file downloads but still need tokenizer initialization.

lib/bindings/python/rust/llm/entrypoint.rs (1)

159-160: LGTM! Consistent implementation with CLI version.

The is_mocker flag is correctly set based on the engine type, maintaining consistency across different entry points.

lib/llm/src/local_model.rs (4)

50-50: LGTM! Clean addition of mocker flag field.


66-66: LGTM! Appropriate default value.

The default value of false for is_mocker ensures backwards compatibility.


124-127: LGTM! Builder method follows established pattern.

The is_mocker builder method is consistent with other builder methods in the struct.


179-179: LGTM! Correctly passes mocker flag to hub download.

The flag is properly propagated to control weight file downloading behavior.

lib/llm/src/hub.rs (4)

30-37: LGTM! Comprehensive weight file detection.

The is_weight_file function covers the most common model weight file extensions. The implementation is clean and focused.


41-42: LGTM! Clear function signature extension.

The addition of the ignore_weights parameter is well-named and documented.


79-82: LGTM! Correct implementation of weight file filtering.

The logic correctly skips weight files when ignore_weights is true, allowing mockers to download only tokenizer files.


101-109: LGTM! Improved error messaging.

The error message appropriately distinguishes between scenarios where no files vs. no non-weight files were found, providing better debugging information.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@PeaBrane PeaBrane enabled auto-merge (squash) July 31, 2025 17:59
@PeaBrane PeaBrane merged commit bae25dc into main Jul 31, 2025
11 of 12 checks passed
@PeaBrane PeaBrane deleted the rupei/mocker-no-weights branch July 31, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: mockers should not require downloading model weights

3 participants