Skip to content

Conversation

@paulhendricks
Copy link
Member

@paulhendricks paulhendricks commented Jul 23, 2025

Overview:

Fixes compile issue.

  • Still uses mistralrs v0.6.0 but rev 8a4faf3
  • Updates tokenizers from 0.21.1 to 0.21.2
  • Updates toktrie and toktrie_hf_tokenizers from 0.6.28 to 1.1
  • Adds ahash to lib/llm/Cargo.toml as we need to use ahash::AHashMap instead of std::collections::HashMap in gguf_tokenizer.rs to satisfy new trait bounds in bpe_tokenizer(..)
  • Adds ureq as a feature for huggingface-hub since tests in gguf_tokenizer.rs use it

Details:

error[E0599]: no method named `get_normalizers` found for reference `&tokenizers::normalizers::Sequence` in the current scope
  --> /Users/phendricks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/toktrie_hf_tokenizers-0.6.31/src/lib.rs:83:23
   |
83 |                     x.get_normalizers()
   |                       ^^^^^^^^^^^^^^^
   |
help: there is a method `normalize` with a similar name, but with different arguments
  --> /Users/phendricks/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokenizers-0.21.2/src/tokenizer/mod.rs:57:5
   |
57 |     fn normalize(&self, normalized: &mut NormalizedString) -> Result<()>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0599`.
error: could not compile `toktrie_hf_tokenizers` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

Where should the reviewer start?

  • ./lib/engines/mistralrs/Cargo.toml
  • /lib/llm/Cargo.toml
  • lib/llm/src/gguf/gguf_tokenizer.rs

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

Relates to:

Summary by CodeRabbit

  • Chores
    • Updated dependency versions for improved compatibility and performance.
    • Pinned a dependency to a specific commit for consistency.
    • Replaced standard hash map implementation with a faster alternative for internal processing.

@copy-pr-bot
Copy link

copy-pr-bot bot commented Jul 23, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@paulhendricks paulhendricks marked this pull request as ready for review July 23, 2025 17:22
@paulhendricks paulhendricks requested a review from a team as a code owner July 23, 2025 17:22
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 23, 2025

Walkthrough

The changes update dependency specifications in Cargo.toml files by pinning mistralrs to a specific commit, upgrading tokenizers, toktrie, and toktrie_hf_tokenizers versions, and adding ahash as a new dependency. Additionally, the tokenizer implementation in Rust is updated to use ahash::AHashMap instead of the standard HashMap.

Changes

File(s) Change Summary
lib/engines/mistralrs/Cargo.toml Pins the mistralrs dependency to a specific Git commit using rev = "8a4faf3".
lib/llm/Cargo.toml Upgrades tokenizers to 0.21.2, toktrie and toktrie_hf_tokenizers to 1.1.0, and adds ahash 0.8.12.
lib/llm/src/gguf/gguf_tokenizer.rs Replaces HashMap with ahash::AHashMap for vocabulary and special tokens in the tokenizer implementation.

Estimated code review effort

1 (~5 minutes)

Possibly related PRs

Poem

In the garden of code where dependencies grow,
AHashMap now blossoms, swift in its flow.
Tokenizers upgraded, crates aligned with care,
Pinning down versions for builds that are rare.
With every small tweak, the project hops on—
A rabbit’s delight as the code marches on! 🐇


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.

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: 0

🔭 Outside diff range comments (1)
lib/llm/Cargo.toml (1)

104-108: tokenizers version does not match the PR objective / likely still incompatible

The PR description says we migrate to tokenizers 0.22.2, yet the manifest only bumps to 0.21.2.
API changes (e.g. removal of get_normalizers) landed in 0.22, so this line probably leaves the original compile error unresolved.

-tokenizers = { version = "0.21.2", default-features = false, features = [
+tokenizers = { version = "0.22.2", default-features = false, features = [

Please adjust the version (and run cargo update -p tokenizers) or amend the PR notes.

🧹 Nitpick comments (3)
lib/llm/Cargo.toml (1)

113-115: Minor: align sub-crates to a caret requirement

Unless you need an exact patch, consider a caret requirement to allow bug-fixes automatically:

-toktrie = { version = "1.1.0" }
-toktrie_hf_tokenizers =  { version = "1.1.0" }
+toktrie = "1.1"
+toktrie_hf_tokenizers = "1.1"

Nit, feel free to ignore if pinning is intentional.

lib/llm/src/gguf/gguf_tokenizer.rs (2)

238-244: Pre-reserve capacity for vocab to avoid re-hashing

We already know the final size (p.tokens.len()), so we can avoid several reallocations:

-let mut vocab: AHashMap<String, u32> = AHashMap::new();
+let mut vocab: AHashMap<String, u32> = AHashMap::with_capacity(p.tokens.len());

Tiny but basically free.


269-272: Same reservation nit for special_toks

-let mut special_toks: AHashMap<String, processors::template::SpecialToken> =
-    AHashMap::new();
+let mut special_toks: AHashMap<String, processors::template::SpecialToken> =
+    AHashMap::with_capacity(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 c6f12f6 and 8bd8e0e.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • lib/bindings/python/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • lib/engines/mistralrs/Cargo.toml (1 hunks)
  • lib/llm/Cargo.toml (3 hunks)
  • lib/llm/src/gguf/gguf_tokenizer.rs (3 hunks)
🧠 Learnings (1)
lib/engines/mistralrs/Cargo.toml (3)

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:07:24.843Z
Learning: The codebase uses async-nats version 0.40, not the older nats crate. Error handling should use async_nats::error::Error variants, not nats::Error variants.

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.

Learnt from: grahamking
PR: #1962
File: lib/runtime/src/component/client.rs:270-273
Timestamp: 2025-07-16T12:41:12.543Z
Learning: In lib/runtime/src/component/client.rs, the current mutex usage in get_or_create_dynamic_instance_source is temporary while evaluating whether the mutex can be dropped entirely. The code currently has a race condition between try_lock and lock().await, but this is acknowledged as an interim state during the performance optimization process.

🧰 Additional context used
🧠 Learnings (1)
lib/engines/mistralrs/Cargo.toml (3)

Learnt from: kthui
PR: #1424
File: lib/runtime/src/pipeline/network/egress/push_router.rs:204-209
Timestamp: 2025-06-13T22:07:24.843Z
Learning: The codebase uses async-nats version 0.40, not the older nats crate. Error handling should use async_nats::error::Error variants, not nats::Error variants.

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.

Learnt from: grahamking
PR: #1962
File: lib/runtime/src/component/client.rs:270-273
Timestamp: 2025-07-16T12:41:12.543Z
Learning: In lib/runtime/src/component/client.rs, the current mutex usage in get_or_create_dynamic_instance_source is temporary while evaluating whether the mutex can be dropped entirely. The code currently has a race condition between try_lock and lock().await, but this is acknowledged as an interim state during the performance optimization process.

⏰ 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). (2)
  • GitHub Check: Build and Test - vllm
  • GitHub Check: pre-merge-rust (.)
🔇 Additional comments (3)
lib/engines/mistralrs/Cargo.toml (1)

42-42: Pinning both version and rev can lead to subtle mismatches

When a git source is specified Cargo ignores the version field for resolution, but still checks that the crate inside the repo advertises at least that version.
If the commit 8a4faf3 no longer reports version = "0.6.0" in its own Cargo.toml, the build will fail with “package ID specification… does not match”.

Verify the commit’s internal version or drop the version key entirely:

-mistralrs = { git = "https://github.com/EricLBuehler/mistral.rs.git", version = "0.6.0", rev = "8a4faf3" }
+mistralrs = { git = "https://github.com/EricLBuehler/mistral.rs.git", rev = "8a4faf3" }

(or update the version string if the crate evolved).

lib/llm/Cargo.toml (1)

130-130: Check for duplicate ahash in the workspace

ahash is already a transitive dependency via toktrie; adding an explicit top-level entry is fine, but you might want to enable the same serde/std feature set everywhere to avoid duplicate crate instances.

lib/llm/src/gguf/gguf_tokenizer.rs (1)

30-30: Explicit import of AHashMap looks good

The replacement is clean and keeps the diff minimal.

@paulhendricks paulhendricks enabled auto-merge (squash) July 23, 2025 19:28
@paulhendricks paulhendricks merged commit 66b7d2c into main Jul 23, 2025
9 checks passed
@paulhendricks paulhendricks deleted the phendricks/fix-toktrie-hf-tokenizers-issue branch July 23, 2025 20:27
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.

3 participants