Skip to content

The 80B Qwen3-Coder-Next on a 16 GB Mac, about 13 tok/s, fully offline. A mixture-of-experts inference engine for Apple silicon.

Rust

lab: rolling drops a quarter of the space at once (writing at 16.8K context 11.5 -> 33.1 tok/s); prompt pieces sized by the reserved space, not the chat length

Picassoai5717e7cc1c86
diff --git a/crates/engine/src/model_next.rs b/crates/engine/src/model_next.rs
index ba01c89..ee42d6d 100644
--- a/crates/engine/src/model_next.rs
+++ b/crates/engine/src/model_next.rs
@@ -80,7 +80,8 @@ impl KvBuf {
if self.len + l > fixed {
// Roll: keep the opening and the newest, let the oldest middle go.
let sink = 256.min(self.len);
- let drop = self.len + l - fixed;
+ // Roll a quarter of the space at once, so the shift is rare, not once per word.
+ let drop = (self.len + l - fixed).max(fixed / 4).min(self.len.saturating_sub(256.min(self.len)));
let keep_from = (sink + drop).min(self.len);
if let (Some(kb), Some(vb)) = (&self.k, &self.v) {
if keep_from < self.len {
diff --git a/crates/server/src/chat.rs b/crates/server/src/chat.rs
index a4fac9c..53b60f9 100644
--- a/crates/server/src/chat.rs
+++ b/crates/server/src/chat.rs
@@ -532,7 +532,12 @@ fn answer(
fn read_prompt(model: &mut Model, device: &Device, pos: usize, tokens: &[u32], tell: &Option<Rc<RefCell<Progress>>>) -> Result<Tensor> {
// The pieces shrink as the chat grows, so the attention scores of a piece (piece x chat) never
// need more memory than a full piece at 4K of chat.
- let piece_at = |at: usize| -> usize { let full = prompt_chunk(); if at <= 4096 { full } else { (full * 4096 / at).max(32) } };
+ let space: Option<usize> = std::env::var("COACHWHIP_CONV_TOKENS").ok().and_then(|v| v.parse().ok()).filter(|&n: &usize| n > 0);
+ let piece_at = |at: usize| -> usize {
+ let full = prompt_chunk();
+ let at = space.map_or(at, |s| at.min(s));
+ if at <= 4096 { full } else { (full * 4096 / at).max(32) }
+ };
let mut bounds = Vec::new();
let mut at = 0usize;
while at < tokens.len() {