Skip to content

armgit / uzu

Public Imported from GitHub
0

A high-performance inference engine for AI models

fix for async on short prompts

LuckyIYI2991720d2258
diff --git a/crates/uzu/src/backends/metal/forward_pass/kv_cache_layer.rs b/crates/uzu/src/backends/metal/forward_pass/kv_cache_layer.rs
index 5ac083771..4b3b4c641 100644
--- a/crates/uzu/src/backends/metal/forward_pass/kv_cache_layer.rs
+++ b/crates/uzu/src/backends/metal/forward_pass/kv_cache_layer.rs
@@ -335,8 +335,12 @@ impl KVCacheLayer {
ring_length,
window_length,
} => {
- let newest_slot =
- (ring_offset + window_length - 1) % window_length;
+ let newest_slot = (ring_length > 0)
+ .then_some(
+ (ring_offset + ring_length + window_length - 1)
+ % window_length,
+ )
+ .unwrap_or(0);
let unmask_col = (ring_length > 0)
.then_some(newest_slot as i32)
.unwrap_or(-1);