Skip to content

Conversation

grahamking
Copy link
Contributor

@grahamking grahamking commented May 29, 2025

Previously mistral.rs was the default engine for both safetensors and GGUF models. Now it is only the default for safetensors, llama.cpp becomes the default for GGUF.

Why?

Dynamo's multi-engine support gives us a secret super-power: we can use the best engine for this specific format or model.

We can still run GGUF with mistralrs by doing out=mistralrs.

Summary by CodeRabbit

  • New Features

    • Added new methods to easily check if a model or model card uses the GGUF format.
  • Refactor

    • Improved handling of output engine selection and logging for model execution.
    • Simplified logic for determining and logging supported hardware acceleration features.
  • Chores

    • Removed default output engine selection and related logging to streamline configuration options.

Previously `mistral.rs` was the default engine for both safetensors and
GGUF models. Now it is only the default for safetensors, `llama.cpp`
becomes the default for GGUF.

Why?

- Since #1177 `llama.cpp` is built-in by default, so we can switch.
- `llama.cpp` is very very good at running GGUF (but can't run other types
  of model), so we should switch.

Dynamo's multi-engine support gives us a secret super-power: we can
use the best engine for this specific format or model.

We can still run GGUF with mistralrs by doing `out=mistralrs`.
Copy link
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

The changes refactor the handling of output engine selection in the run function and related code. The output parameter is now optional, with defaulting logic moved into the library. New helper methods and checks for GGUF model types are introduced, and CUDA/Metal/Vulkan info logging is centralized. Default output logic and related code are removed from the CLI entry point.

Changes

File(s) Change Summary
launch/dynamo-run/src/lib.rs Refactored run to accept Option<Output>, added helpers for input/output checks, centralized defaulting and CUDA info logging, and updated model handling logic.
launch/dynamo-run/src/main.rs Removed defaulting and logging for output engine, deleted print_cuda function, simplified argument handling.
launch/dynamo-run/src/opt.rs Removed Default trait implementation for Output enum.
lib/llm/src/local_model.rs Added is_gguf method to LocalModel to check if model path is a file (GGUF format).
lib/llm/src/model_card/model.rs Added is_gguf methods to ModelDeploymentCard and ModelInfoType for GGUF type checking.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI (main.rs)
    participant Lib (lib.rs)
    participant Model
    User->>CLI (main.rs): Provide input and optional output engine
    CLI (main.rs)->>Lib (lib.rs): Call run(runtime, input, out_opt, flags)
    Lib (lib.rs)->>Lib (lib.rs): Check input/output compatibility
    Lib (lib.rs)->>Model: Build or prepare local model
    Model->>Lib (lib.rs): Return LocalModel
    Lib (lib.rs)->>Lib (lib.rs): Determine output engine (default if needed)
    Lib (lib.rs)->>Lib (lib.rs): Log CUDA/Metal/Vulkan info if applicable
    Lib (lib.rs)->>User: Proceed with execution
Loading

Possibly related PRs

Poem

A bunny hopped through code so bright,
Making output engines optional felt just right.
GGUF checks now quick as a breeze,
CUDA logs handled with elegant ease.
Defaults moved in, old code swept away—
The codebase is cleaner for another day!
🐇✨


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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fb4bf25 and 01c2489.

📒 Files selected for processing (5)
  • launch/dynamo-run/src/lib.rs (4 hunks)
  • launch/dynamo-run/src/main.rs (1 hunks)
  • launch/dynamo-run/src/opt.rs (0 hunks)
  • lib/llm/src/local_model.rs (1 hunks)
  • lib/llm/src/model_card/model.rs (2 hunks)
💤 Files with no reviewable changes (1)
  • launch/dynamo-run/src/opt.rs
🧰 Additional context used
🧬 Code Graph Analysis (2)
lib/llm/src/local_model.rs (1)
lib/llm/src/model_card/model.rs (2)
  • is_gguf (229-234)
  • is_gguf (390-392)
lib/llm/src/model_card/model.rs (1)
lib/llm/src/local_model.rs (1)
  • is_gguf (65-69)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build and Test - vllm
  • GitHub Check: pre-merge-rust (lib/runtime/examples)
  • GitHub Check: pre-merge-rust (lib/bindings/python)
  • GitHub Check: pre-merge-rust (.)
🔇 Additional comments (8)
lib/llm/src/model_card/model.rs (2)

229-234: Well-structured delegation pattern.

The is_gguf() method on ModelDeploymentCard correctly delegates to the underlying ModelInfoType through the model_info field. The handling of the None case is appropriate, returning false when no model info is available.


390-392: Clean and explicit pattern matching.

The is_gguf() method on ModelInfoType uses proper pattern matching with matches! macro, making the intent clear and the implementation safe. This provides a consistent API across different model info representations.

launch/dynamo-run/src/main.rs (1)

106-108: Good refactoring to simplify CLI parsing logic.

The simplified handling of out_opt correctly moves the responsibility for default engine selection from the CLI parsing layer to the business logic layer in lib.rs. This separation of concerns improves maintainability.

launch/dynamo-run/src/lib.rs (5)

44-50: Clean helper functions improve readability.

The new helper functions is_in_dynamic and is_out_dynamic make the conditional logic more readable and maintainable. The pattern matching is explicit and correct.


55-55: Function signature change aligns with PR objectives.

The change to accept Option<Output> enables the dynamic default selection based on model type, which is the core objective of this PR. The helper function usage makes the incompatibility check cleaner.

Also applies to: 58-58


68-91: Proper conditional model creation logic.

The refactored model creation logic correctly handles the case where output is dynamic (creating a default empty model) versus other cases where a real model needs to be prepared or constructed. The logic flow is clear and handles all the necessary cases.


117-129: Excellent implementation of the core PR feature.

This code segment perfectly implements the PR objective: using llama.cpp as the default engine for GGUF models and mistral.rs for others. The logic:

  1. Correctly uses the new is_gguf() method on the model card
  2. Provides appropriate logging for transparency
  3. Falls back gracefully when no output is specified

The user experience is improved with informative logging about the chosen default and available alternatives.


368-402: Well-implemented conditional compilation for hardware acceleration info.

The print_cuda function properly handles different compilation scenarios:

  1. Only logs for engines that actually need compile-time acceleration features (mistralrs, llamacpp)
  2. Uses appropriate conditional compilation directives for different acceleration backends
  3. Provides helpful guidance when no acceleration features are enabled
  4. Has a no-op version when no relevant engines are compiled

The implementation is both informative and non-intrusive.

@grahamking grahamking enabled auto-merge (squash) May 29, 2025 22:34
Copy link
Contributor

@nnshah1 nnshah1 left a comment

Choose a reason for hiding this comment

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

High level - no particular issue - another avenue to consider is to remove any default and force the user to provide an engine - generally speaking for a multi-engine tool I think that kind of makes sense - choosing a default for the user is convenient but at the same time a little confusing - as in why this one vs that one ....

an aside: 'out' is maybe confusing and what it we overlap options with --engine ?

so user could do either out=vllm or --engine vllm , --engine remote (for dyn:// ?)

@grahamking grahamking merged commit 3e3c3b1 into main May 29, 2025
15 checks passed
@grahamking grahamking deleted the gk-default-llamacpp-gguf branch May 29, 2025 23:16
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.

2 participants