Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/core/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ impl BlockManager {
if self.prefix_cache.is_some() {
let mut prefix_cache = self.prefix_cache.take().unwrap();
let seed = seq.images.as_ref().map(Self::image_prefix_seed);
let prefix_match = prefix_cache.match_prefix_with_seed(&seq.token_ids, seed);

// Use relaxed matching with 5% tolerance for tokenization differences
let prefix_match = prefix_cache.match_prefix_relaxed(&seq.token_ids, seed, 0.05);

let matched_blocks = self.resolve_mamba_matched_blocks(
&prefix_cache,
seq.id,
Expand Down Expand Up @@ -325,7 +328,8 @@ impl BlockManager {

if prefix_cache.enabled() {
let seed = seq.images.as_ref().map(Self::image_prefix_seed);
let prefix_match = prefix_cache.match_prefix_with_seed(tokens, seed);
// Use relaxed matching to handle tokenization variations
let prefix_match = prefix_cache.match_prefix_relaxed(tokens, seed, 0.05);
last_hash = prefix_match.last_hash;
raw_matched_blocks =
self.adjusted_matched_blocks(tokens.len(), prefix_match.matched_blocks);
Expand Down
Loading