diff --git a/Cargo.lock b/Cargo.lock index 9f29ef2e3a..a26ed6fe52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3595,6 +3595,16 @@ dependencies = [ "uuid", ] +[[package]] +name = "continuum-persona-llama" +version = "0.1.0" +dependencies = [ + "continuum-persona-engine", + "llama", + "thiserror 2.0.18", + "uuid", +] + [[package]] name = "continuum-positron" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 5431dfab2c..564ac48d22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ members = [ "core/continuum-sentinel", "core/continuum-kernel", "core/continuum-persona-engine", + "core/continuum-persona-llama", "core/continuum-store", "core/continuum-grid", "core/continuum-mind", diff --git a/core/continuum-persona-engine/src/residency.rs b/core/continuum-persona-engine/src/residency.rs index 69aaf368a1..43866e4024 100644 --- a/core/continuum-persona-engine/src/residency.rs +++ b/core/continuum-persona-engine/src/residency.rs @@ -4,4 +4,4 @@ mod fence; mod tier; pub use fence::{Direction, Fence, FenceTag}; -pub use tier::{Tier, TierRefusal}; +pub use tier::{Native, Tier, TierRefusal}; diff --git a/core/continuum-persona-engine/src/residency/tier.rs b/core/continuum-persona-engine/src/residency/tier.rs index 2b58330489..269d44ba08 100644 --- a/core/continuum-persona-engine/src/residency/tier.rs +++ b/core/continuum-persona-engine/src/residency/tier.rs @@ -7,11 +7,31 @@ use crate::persona::PersonaId; /// A tier could not take or give a persona's bytes: named, so the engine keeps her where she is. #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] -#[error("{tier}: {reason} for persona {persona:?}")] +#[error("{tier}: {reason} for persona {persona:?}{native}")] pub struct TierRefusal { pub tier: &'static str, pub persona: PersonaId, pub reason: &'static str, + /// The backend's own refusal, kept rather than erased. + pub native: Native, +} + +/// What the backend itself said when the tier refused. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Native { + /// The refusal is the tier's own (a precondition it checked); the backend was not asked. + NotAsked, + /// The backend refused, by its status and the name it gives that status. + Refused { status: i32, name: String }, +} + +impl std::fmt::Display for Native { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::NotAsked => Ok(()), + Self::Refused { status, name } => write!(f, " (backend status {status}: {name})"), + } + } } /// A residency tier. diff --git a/core/continuum-persona-llama/Cargo.toml b/core/continuum-persona-llama/Cargo.toml new file mode 100644 index 0000000000..07a228ae4c --- /dev/null +++ b/core/continuum-persona-llama/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "continuum-persona-llama" +version = "0.1.0" +edition = "2021" +description = "The persona engine's residency tier over the fork's native persona blocks (CONTINUUM-ENGINE 4.14): one context, two execution streams (the active mind decodes in one while the next binds into the other), every other mind's blocks in RAM. A switch is a native bind, never a serialize or a re-prefill." + +[features] +metal = ["llama/metal"] + +[dependencies] +continuum-persona-engine = { path = "../continuum-persona-engine" } +llama = { path = "../llama" } +thiserror.workspace = true +uuid.workspace = true + +[lints.clippy] +unwrap_used = "deny" +expect_used = "deny" +panic = "deny" diff --git a/core/continuum-persona-llama/examples/persona_switch.rs b/core/continuum-persona-llama/examples/persona_switch.rs new file mode 100644 index 0000000000..66c5438ec5 --- /dev/null +++ b/core/continuum-persona-llama/examples/persona_switch.rs @@ -0,0 +1,224 @@ +//! The persona engine on a real model: N minds take turns through `Roles` and the `UnifiedTier`, one +//! decoding at a time. Each turn stages the next mind (her copy-in), hands off, retires the previous +//! mind (her copy-out to RAM), then decodes. Reports the switch (handoff + copy-out + copy-in) and the +//! decode rate, separately and together. +//! +//! cargo run --release --features metal --example persona_switch -- + +use std::time::{Duration, Instant}; + +use continuum_persona_engine::persona::{Epoch, PersonaId}; +use continuum_persona_engine::pipeline::{Identified, Roles}; +use continuum_persona_engine::residency::{Direction, FenceTag, Tier}; +use continuum_persona_llama::{Landed, Rebind, UnifiedTier}; +use llama::{Batch, ContextParams, FlashAttn, Model, ModelParams}; + +/// One mind in the run: who she is, where her history ends, and her last sampled token. +struct Mind { + id: PersonaId, + epoch: Epoch, + prompt: Vec, + pos: i32, + last: i32, +} + +impl Identified for Mind { + fn persona(&self) -> PersonaId { + self.id + } + fn epoch(&self) -> Epoch { + self.epoch + } +} + +fn argmax(logits: &[f32]) -> i32 { + let mut best = (0usize, f32::MIN); + for (i, &v) in logits.iter().enumerate() { + if v > best.1 { + best = (i, v); + } + } + best.0 as i32 +} + +fn arg(args: &[String], i: usize, what: &str) -> Result { + args.get(i).ok_or(format!("missing {what}"))?.parse().map_err(|e| format!("{what}: {e}")) +} + +/// Codex on #6134: a tier wrapping a context already in use must not report a first bind over the +/// state another sequence holds there. One token is decoded into sequence 0 before the tier exists; a +/// new mind's move in must be refused with that state untouched, and succeed once the stream is empty. +fn adopted_context_is_refused(model: &Model, ctx: &mut llama::Context<'_>) -> Result<(), String> { + let token = *model.tokenize("held", true, false)?.first().ok_or("no token for the probe")?; + let mut batch = Batch::allocated(1, 1); + batch.push(token, 0, &[0], false); + ctx.decode(&batch)?; + let mind = FenceTag { persona: PersonaId(uuid::Uuid::new_v4()), epoch: Epoch(1), direction: Direction::In }; + { + let mut tier = UnifiedTier::new(ctx); + if tier.begin(mind).is_ok() { + return Err("adoption: a new mind was bound over sequence 0's state".into()); + } + } + if ctx.memory_seq_pos_max(0) != 0 { + return Err("adoption: the refused move changed sequence 0's state".into()); + } + ctx.memory_seq_rm(0, -1, -1); + if UnifiedTier::new(ctx).begin(mind).is_err() { + return Err("adoption: a new mind was refused an empty stream".into()); + } + ctx.memory_seq_rm(0, -1, -1); + println!("persona_switch: adoption: a new mind is refused over held state and bound on an empty stream"); + Ok(()) +} + +/// Codex on #6134 (de0e34a97): a refused move must not cost her the blocks she had. Epoch 1 decodes and +/// parks in RAM; another sequence's state lands on her stream; epoch 2's move in is refused there; once +/// the stream is clear epoch 1 binds back at the position she left (her byte-identical continuation +/// after a bind is the fork's own test, test-persona-blocks). +fn a_refused_newer_epoch_keeps_her_parked_blocks(model: &Model, ctx: &mut llama::Context<'_>) -> Result<(), String> { + let tokens = model.tokenize("She keeps her own notes.", true, false)?; + let her = PersonaId(uuid::Uuid::new_v4()); + let tag = |epoch, direction| FenceTag { persona: her, epoch: Epoch(epoch), direction }; + let mut tier = UnifiedTier::new(ctx); + tier.begin(tag(1, Direction::In)).map_err(|e| e.to_string())?; + let seq = tier.stream_of(her).ok_or("replay: she is not bound")?.seq(); + let mut batch = Batch::allocated(tokens.len() as i32, 1); + for (i, &t) in tokens.iter().enumerate() { + batch.push(t, i as i32, &[seq], false); + } + tier.context().decode(&batch)?; + let held_to = tier.context().memory_seq_pos_max(seq); + tier.begin(tag(1, Direction::Out)).map_err(|e| e.to_string())?; + let first = *tokens.first().ok_or("replay: no tokens")?; + let mut other = Batch::allocated(1, 1); + other.push(first, 0, &[seq], false); + tier.context().decode(&other)?; + if tier.begin(tag(2, Direction::In)).is_ok() { + return Err("replay: epoch 2 was bound over another sequence's state".into()); + } + tier.context().memory_seq_rm(seq, -1, -1); + tier.begin(tag(1, Direction::In)).map_err(|e| format!("replay: her parked epoch 1 was lost: {e}"))?; + let back = tier.stream_of(her).ok_or("replay: she is not bound again")?.seq(); + if tier.context().memory_seq_pos_max(back) != held_to { + return Err(format!("replay: epoch 1 came back holding {} instead of {held_to}", tier.context().memory_seq_pos_max(back))); + } + tier.begin(tag(1, Direction::Out)).map_err(|e| e.to_string())?; + println!("persona_switch: replay: a refused newer epoch kept her parked epoch 1, which bound back at position {held_to}"); + Ok(()) +} + +fn main() -> Result<(), String> { + let args: Vec = std::env::args().collect(); + let model_path = args.get(1).ok_or("usage: persona_switch ")?; + let (minds, prompt_tokens, decode_tokens, rounds) = + (arg(&args, 2, "minds")?, arg(&args, 3, "prompt_tokens")?, arg(&args, 4, "decode_tokens")?, arg(&args, 5, "rounds")?); + + llama::backend_init(); + let model = Model::load(model_path, ModelParams::default())?; + // two execution streams (active + next); each holds one mind's whole window + let window = (prompt_tokens + decode_tokens * rounds + 64) as u32; + let params = ContextParams { n_ctx: window * 2, n_batch: 2048, n_ubatch: 2048, n_seq_max: 2, flash_attn: FlashAttn::Enabled, ..ContextParams::default() }; + let mut ctx = model.new_context(params)?; + adopted_context_is_refused(&model, &mut ctx)?; + a_refused_newer_epoch_keeps_her_parked_blocks(&model, &mut ctx)?; + let mut tier = UnifiedTier::new(&mut ctx); + + let mut parked: Vec = (0..minds) + .map(|i| { + let text = format!("Mind {i} keeps her own notes. ").repeat(prompt_tokens / 6 + 1); + let mut prompt = model.tokenize(&text, true, false)?; + prompt.truncate(prompt_tokens); + Ok(Mind { id: PersonaId(uuid::Uuid::new_v4()), epoch: Epoch(1), prompt, pos: 0, last: 0 }) + }) + .collect::>()?; + + let mut roles: Roles = Roles::default(); + let (mut same_seq, mut other_seq) = (Vec::new(), Vec::new()); + let (mut switches, mut decode_time, mut decoded, mut prefill_time) = (Vec::new(), Duration::ZERO, 0usize, Duration::ZERO); + let run = Instant::now(); + for turn in 0..minds * rounds { + // the next mind in turn order (the scheduler's choice in the engine; round-robin here) + let next = parked.remove(0); + let t = Instant::now(); + let fence = tier.begin(FenceTag { persona: next.id, epoch: next.epoch, direction: Direction::In }).map_err(|e| e.to_string())?; + let rebind = tier.last_rebind(); + roles.stage(next, fence).map_err(|r| format!("{:?}", r.reason))?; + roles.handoff().map_err(|e| format!("{e:?}"))?; + if let Some(out) = roles.awaiting_copy_out() { + let fence = tier.begin(out).map_err(|e| e.to_string())?; + roles.begin_retire(fence).map_err(|r| format!("{:?}", r.reason))?; + parked.push(roles.release_retired().map_err(|e| format!("{e:?}"))?); + } + let switched = t.elapsed(); + if turn > 0 { + switches.push(switched); + match rebind { + Some(Rebind::SameSequence) => same_seq.push(switched), + Some(Rebind::OtherSequence) => other_seq.push(switched), + None => {} + } + } + + let mind = roles.active_mut().ok_or("no active mind after handoff")?; + let seq = tier.stream_of(mind.id).ok_or("the active mind is not bound")?.seq(); + let ctx = tier.context(); + if mind.pos == 0 { + let t = Instant::now(); + let mut last_index = 0; + for chunk in mind.prompt.chunks(2048) { + let mut batch = Batch::allocated(chunk.len() as i32, 1); + for (j, &tok) in chunk.iter().enumerate() { + batch.push(tok, mind.pos + j as i32, &[seq], j + 1 == chunk.len()); + } + ctx.decode(&batch)?; + mind.pos += chunk.len() as i32; + last_index = chunk.len() as i32 - 1; + } + mind.last = argmax(ctx.logits_ith(last_index)); + prefill_time += t.elapsed(); + } + let t = Instant::now(); + for _ in 0..decode_tokens { + let mut batch = Batch::allocated(1, 1); + batch.push(mind.last, mind.pos, &[seq], true); + ctx.decode(&batch)?; + mind.pos += 1; + mind.last = argmax(ctx.logits_ith(0)); + } + decode_time += t.elapsed(); + decoded += decode_tokens; + } + + // a stale request for an older epoch of a held mind is refused and leaves her blocks: she still binds + let probe = parked.first().ok_or("no parked mind to probe")?; + let stale = tier.begin(FenceTag { persona: probe.id, epoch: Epoch(0), direction: Direction::In }); + let kept = tier.begin(FenceTag { persona: probe.id, epoch: probe.epoch, direction: Direction::In }).is_ok(); + println!("persona_switch: stale epoch refused={} her blocks still bind={kept}", stale.is_err()); + switches.sort(); + same_seq.sort(); + other_seq.sort(); + let ms = |d: Duration| d.as_secs_f64() * 1e3; + let at = |v: &[Duration], q: f64| v.get(((v.len().max(1) as f64 - 1.0) * q) as usize).copied().map(ms).unwrap_or(0.0); // unwrap_or: an empty class prints 0 + let p = |q: f64| at(&switches, q); + let decode_tps = decoded as f64 / decode_time.as_secs_f64(); + let switch_total: Duration = switches.iter().sum(); + let sustained = decoded as f64 / (decode_time + switch_total).as_secs_f64(); + println!( + "persona_switch: minds={minds} prompt={prompt_tokens} decode/turn={decode_tokens} rounds={rounds} turns={} | switch p50 {:.2} ms p90 {:.2} ms max {:.2} ms | decode {decode_tps:.1} tok/s | sustained incl. switches {sustained:.1} tok/s | prefill {:.1} s total | wall {:.1} s", + minds * rounds, + p(0.5), + p(0.9), + p(1.0), + prefill_time.as_secs_f64(), + run.elapsed().as_secs_f64() + ); + println!( + "persona_switch: rebinds (binds of a mind saved before) same sequence n={} p50 {:.2} ms | other sequence (cells relabeled over her span) n={} p50 {:.2} ms; stage, handoff and copy-out run serially before her decode, not overlapped", + same_seq.len(), + at(&same_seq, 0.5), + other_seq.len(), + at(&other_seq, 0.5) + ); + Ok(()) +} diff --git a/core/continuum-persona-llama/src/lib.rs b/core/continuum-persona-llama/src/lib.rs new file mode 100644 index 0000000000..e32c587f05 --- /dev/null +++ b/core/continuum-persona-llama/src/lib.rs @@ -0,0 +1,9 @@ +//! The persona engine's [`Tier`](continuum_persona_engine::residency::Tier) over the fork's native +//! persona blocks: one libllama context, two execution streams, and every other mind's blocks held in +//! RAM as she left them. The pipeline ([`continuum_persona_engine::pipeline::Roles`]) decides when a +//! mind moves; this adapter only performs the move (a native save out, a native bind in) and reports +//! it landed. + +mod unified_tier; + +pub use unified_tier::{Landed, Rebind, Stream, UnifiedTier}; diff --git a/core/continuum-persona-llama/src/unified_tier.rs b/core/continuum-persona-llama/src/unified_tier.rs new file mode 100644 index 0000000000..36ae474950 --- /dev/null +++ b/core/continuum-persona-llama/src/unified_tier.rs @@ -0,0 +1,202 @@ +//! [`UnifiedTier`]: the persona engine's residency tier on one libllama context, as on the M5's unified +//! memory. Two execution streams: the active mind decodes in one while the next mind binds into the +//! other; every other mind's blocks stay in host memory exactly as she left them. A move out is the +//! fork's native save (her stream empties); a move in is its native bind (her blocks take an empty +//! stream, answering to the sequence she is bound as). Both are synchronous copies, so the fence a +//! move returns has already landed. + +use std::collections::HashMap; + +use continuum_persona_engine::persona::{Epoch, PersonaId}; +use continuum_persona_engine::residency::{Direction, Fence, FenceTag, Native, Tier, TierRefusal}; +use llama::{BindRefusal, Context, PersonaBlocks, PersonaOwner, PersonaRefusal}; + +/// One of the context's two execution streams, by the sequence id the context knows it as. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Stream(i32); + +impl Stream { + /// The sequence id to decode her tokens as. + pub fn seq(self) -> i32 { + self.0 + } +} + +/// A move this tier performed: the fork's copies are synchronous, so it has landed when it exists. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Landed(FenceTag); + +impl Fence for Landed { + fn tag(&self) -> FenceTag { + self.0 + } + + fn complete(&self) -> bool { + true + } +} + +/// How a mind's last bind met her blocks: on the sequence she was saved from (her cells keep their +/// label), or on the other one (the fork relabels her cells, a walk over her span; Codex on #6134). +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Rebind { + SameSequence, + OtherSequence, +} + +/// One mind this tier holds: her blocks (in RAM, or bound), the epoch they belong to, and the stream +/// she was last saved from. +struct Mind { + blocks: PersonaBlocks, + epoch: Epoch, + saved_from: Option, +} + +/// The persona engine's tier over one context's native persona blocks. +pub struct UnifiedTier<'c, 'm> { + ctx: &'c mut Context<'m>, + /// Who occupies each execution stream: occupancy is the streams', never a scan of every mind. + streams: [Option; 2], + minds: HashMap, + /// Each persona's owner stamp for the fork, issued once per persona by this tier: exact within the + /// process the RAM tier lives in (a persona is a 128-bit id; the fork stamps 64 bits). + handles: HashMap, + last_rebind: Option, +} + +impl<'c, 'm> UnifiedTier<'c, 'm> { + pub fn new(ctx: &'c mut Context<'m>) -> Self { + Self { ctx, streams: [None, None], minds: HashMap::new(), handles: HashMap::new(), last_rebind: None } + } + + /// The stream `persona` is bound to, if she is in the execution stream. + pub fn stream_of(&self, persona: PersonaId) -> Option { + self.streams.iter().position(|held| *held == Some(persona)).map(stream_at) + } + + /// The context, for the active mind's decode. + pub fn context(&mut self) -> &mut Context<'m> { + self.ctx + } + + /// How many minds this tier holds (bound or in RAM). + pub fn held(&self) -> usize { + self.minds.len() + } + + /// How the last move in met her blocks; `None` when she had never been saved. + pub fn last_rebind(&self) -> Option { + self.last_rebind + } + + fn move_in(&mut self, persona: PersonaId, epoch: Epoch) -> Result<(), TierRefusal> { + if self.stream_of(persona).is_some() { + return Err(refused(persona, "already bound")); + } + let slot = self.streams.iter().position(Option::is_none).ok_or_else(|| refused(persona, "both streams are bound"))?; + let stream = stream_at(slot); + // Every check runs before anything changes (Codex on #6134): a newer epoch replaces her older + // blocks only once the move is known to succeed, so a refusal keeps the blocks she had. + let rebind_from = match self.minds.get(&persona) { + Some(held) if epoch < held.epoch => return Err(refused(persona, "a stale epoch: her newer blocks are kept")), + Some(held) if epoch == held.epoch => held.saved_from, + // a mind never seen, or a newer epoch of her, starts over on this stream + _ => None, + }; + // A mind with nothing to bind starts on this stream as it is, so it must hold nothing (the + // context may have been in use before this tier wrapped it). The engine's own memory is the + // evidence, never this tier's bookkeeping. + if rebind_from.is_none() && self.ctx.memory_seq_pos_max(stream.seq()) >= 0 { + return Err(refused(persona, "her stream already holds another sequence's state")); + } + self.hold(persona, epoch)?; + let owner = self.owner_of(persona, epoch)?; + let mind = self.minds.get_mut(&persona).ok_or_else(|| refused(persona, "not held here"))?; + self.last_rebind = None; + if let Some(from) = rebind_from { + mind.blocks.bind(self.ctx, stream.seq(), owner).map_err(|e| bind_refused(persona, e))?; + self.last_rebind = Some(if from == stream { Rebind::SameSequence } else { Rebind::OtherSequence }); + } + self.streams[slot] = Some(persona); + Ok(()) + } + + /// The owner stamp issued to `persona`, at `epoch`: what her blocks must carry to bind. + fn owner_of(&self, persona: PersonaId, epoch: Epoch) -> Result { + let handle = *self.handles.get(&persona).ok_or_else(|| refused(persona, "no owner stamp issued to her"))?; + Ok(PersonaOwner { persona: handle, epoch: epoch.0 }) + } + + fn move_out(&mut self, persona: PersonaId, epoch: Epoch) -> Result<(), TierRefusal> { + let slot = self.streams.iter().position(|held| *held == Some(persona)).ok_or_else(|| refused(persona, "not bound"))?; + let stream = stream_at(slot); + let mind = self.minds.get_mut(&persona).ok_or_else(|| refused(persona, "not held here"))?; + if mind.epoch != epoch { + return Err(refused(persona, "another epoch of her is bound")); + } + mind.blocks.save(self.ctx, stream.seq()).map_err(|e| native(persona, "the fork refused her save", e))?; + mind.saved_from = Some(stream); + self.streams[slot] = None; + Ok(()) + } + + /// Her blocks at `epoch`, made with her owner on first sight. An older epoch than the one held is + /// stale and refused, leaving her blocks as they are. A newer epoch prepares its blocks first and + /// replaces the old ones only once they exist, so a refused allocation keeps her custody (Codex on + /// #6134). + fn hold(&mut self, persona: PersonaId, epoch: Epoch) -> Result<(), TierRefusal> { + if let Some(held) = self.minds.get(&persona) { + if epoch == held.epoch { + return Ok(()); + } + if epoch < held.epoch { + return Err(refused(persona, "a stale epoch: her newer blocks are kept")); + } + } + let next = self.handles.len() as u64 + 1; + let handle = *self.handles.entry(persona).or_insert(next); + let owner = PersonaOwner { persona: handle, epoch: epoch.0 }; + let blocks = PersonaBlocks::new(self.ctx, owner).ok_or_else(|| refused(persona, "this context's memory has no persona move"))?; + self.minds.insert(persona, Mind { blocks, epoch, saved_from: None }); + Ok(()) + } +} + +impl Tier for UnifiedTier<'_, '_> { + type Fence = Landed; + + fn name(&self) -> &'static str { + TIER + } + + fn begin(&mut self, what: FenceTag) -> Result { + match what.direction { + Direction::In => self.move_in(what.persona, what.epoch)?, + Direction::Out => self.move_out(what.persona, what.epoch)?, + } + Ok(Landed(what)) + } +} + +const TIER: &str = "unified"; + +fn stream_at(slot: usize) -> Stream { + Stream(slot as i32) +} + +fn refused(persona: PersonaId, reason: &'static str) -> TierRefusal { + TierRefusal { tier: TIER, persona, reason, native: Native::NotAsked } +} + +/// The fork refused: keep its status and name in the refusal. +fn native(persona: PersonaId, reason: &'static str, refusal: PersonaRefusal) -> TierRefusal { + TierRefusal { tier: TIER, persona, reason, native: Native::Refused { status: refusal.status, name: refusal.name } } +} + +/// A refused bind, by who refused: her blocks' stamp (another owner or a stale epoch) or the fork. +fn bind_refused(persona: PersonaId, refusal: BindRefusal) -> TierRefusal { + match refusal { + BindRefusal::WrongOwner { .. } => refused(persona, "her blocks are stamped for another owner or epoch"), + BindRefusal::Native(native_refusal) => native(persona, "the fork refused her bind", native_refusal), + } +} diff --git a/core/vendor/LLAMA_CPP_PIN b/core/vendor/LLAMA_CPP_PIN index c9106fca66..318b9d7db0 100644 --- a/core/vendor/LLAMA_CPP_PIN +++ b/core/vendor/LLAMA_CPP_PIN @@ -1 +1 @@ -37baf8c120e3455ec9ea9d81015b7c8bb60391d4 +a88f255cc7992589ff419f59b1ebc17e51ce4f1e diff --git a/core/vendor/llama.cpp b/core/vendor/llama.cpp index 37baf8c120..a88f255cc7 160000 --- a/core/vendor/llama.cpp +++ b/core/vendor/llama.cpp @@ -1 +1 @@ -Subproject commit 37baf8c120e3455ec9ea9d81015b7c8bb60391d4 +Subproject commit a88f255cc7992589ff419f59b1ebc17e51ce4f1e diff --git a/tools/scripts/tests/ci-change-scope.test.cjs b/tools/scripts/tests/ci-change-scope.test.cjs index 12d0cd6a73..c718d1e2d8 100644 --- a/tools/scripts/tests/ci-change-scope.test.cjs +++ b/tools/scripts/tests/ci-change-scope.test.cjs @@ -12,7 +12,7 @@ const select = (...paths) => { // Tested crates a kernel change does not reach: the floor (base, host, git, service, saved-state) and // the leaves that depend on nothing in the workspace (the codec continuum-context, the flow // continuum-flow, the proving ground's types continuum-proving-types). -const BELOW_KERNEL = ['continuum-base', 'continuum-host', 'continuum-git', 'continuum-service', 'continuum-saved-state', 'continuum-context', 'continuum-flow', 'continuum-proving-types', 'continuum-persona-engine']; +const BELOW_KERNEL = ['continuum-base', 'continuum-host', 'continuum-git', 'continuum-service', 'continuum-saved-state', 'continuum-context', 'continuum-flow', 'continuum-proving-types', 'continuum-persona-engine', 'continuum-persona-llama']; test('installer repairs run installer checks without unrelated Rust builds', () => { for (const file of ['install.ps1', 'tools/scripts/lib/install-common.ps1', 'tools/scripts/lib/win-modules.ps1', 'tools/scripts/lib/win-engine.ps1', 'tools/scripts/lib/windows-engine-receipt.ps1', 'tools/scripts/lib/windows-service.ps1', 'tools/scripts/lib/windows-media-reconciliation.ps1', 'tools/scripts/lib/windows-elevation.ps1', 'tools/scripts/tests/windows-process.test.ps1', 'tools/scripts/tests/windows-airc-download.test.ps1', 'tools/scripts/tests/windows-xz.test.ps1', 'tools/scripts/sync-windows-bootstrap.ps1']) @@ -148,15 +148,15 @@ test('a crate-local change runs that crate and every crate that depends on it', const belowMind = crates('continuum-engine', 'continuum-vitals', 'continuum-prompt', 'continuum-engram', 'continuum-capture', 'continuum-embedding', 'continuum-store', 'continuum-models', 'continuum-hands', 'continuum-live', 'continuum-perception', 'continuum-genome', 'continuum-memory', 'continuum-cognition', 'continuum-academy', 'continuum-sentinel', 'continuum-mind', 'continuum-dreaming', 'continuum-grid', 'continuum-serving', 'continuum-core', 'continuum-gateway'); assert.deepEqual(scope(['core/continuum-engine/src/lib.rs']), belowMind); // The floor crates (base, host, git) sit below the kernel: a kernel change runs everything above them. - assert.deepEqual(scope(['core/continuum-persona-engine/src/persona/unit.rs']), crates('continuum-persona-engine')); + assert.deepEqual(scope(['core/continuum-persona-engine/src/persona/unit.rs']), crates('continuum-persona-engine', 'continuum-persona-llama')); const aboveFloor = TESTED_CRATES.filter(n => !BELOW_KERNEL.includes(n)); assert.deepEqual(scope(['core/continuum-kernel/src/lib.rs']), { crates: aboveFloor, cli: false }); // A floor change runs the floor crate and every crate built on it. - assert.deepEqual(scope(['core/continuum-host/src/durable/mod.rs']), { crates: TESTED_CRATES.filter(n => !['continuum-base', 'continuum-service', 'continuum-context', 'continuum-flow', 'continuum-proving-types', 'continuum-persona-engine'].includes(n)), cli: true }); + assert.deepEqual(scope(['core/continuum-host/src/durable/mod.rs']), { crates: TESTED_CRATES.filter(n => !['continuum-base', 'continuum-service', 'continuum-context', 'continuum-flow', 'continuum-proving-types', 'continuum-persona-engine', 'continuum-persona-llama'].includes(n)), cli: true }); // continuum-git is used by hands (a citizen's git) and core (the deploy tree): both run, and every crate above hands. assert.deepEqual(scope(['core/continuum-git/src/index_lock.rs']), crates('continuum-git', 'continuum-hands', 'continuum-cognition', 'continuum-academy', 'continuum-mind', 'continuum-dreaming', 'continuum-grid', 'continuum-serving', 'continuum-core')); // Untested crates reach the tested ones through the graph: llama -> engine -> ... - assert.deepEqual(scope(['core/llama/src/lib.rs']), belowMind); + assert.deepEqual(scope(['core/llama/src/lib.rs']), crates(...belowMind.crates, 'continuum-persona-llama')); assert.deepEqual(scope(['core/continuum-mind/src/a.rs', 'core/continuum-live/src/b.rs']), crates('continuum-live', 'continuum-perception', 'continuum-cognition', 'continuum-academy', 'continuum-mind', 'continuum-dreaming', 'continuum-grid', 'continuum-serving', 'continuum-core')); // A crate's own manifest is that crate's change; a rename counts both ends. assert.deepEqual(scope(['core/continuum-hands/Cargo.toml']), crates('continuum-hands', 'continuum-cognition', 'continuum-academy', 'continuum-mind', 'continuum-dreaming', 'continuum-grid', 'continuum-serving', 'continuum-core'));