diff --git a/.crumb b/.crumb index 810fba00..cfb92961 100644 --- a/.crumb +++ b/.crumb @@ -65,7 +65,7 @@ "children": [ { "digest": "f95432625ccdd27c1732e380e4ddb227483bdce00f37fb0effd5a5fddfea149b", - "last_commit": "a86b662", + "last_commit": "296c4ac", "name": "scripts", "purpose": "" }, @@ -77,14 +77,14 @@ } ], "children_root": "sha256:4ff1a56b7c8ac606ad5709f2ba1141f16055c34f5f242ac491233dca20d5153e", - "compiled_at": "2026-10-07T02:08:27Z", + "compiled_at": "2026-10-07T02:28:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:01f422a3e3d03da594195ea4f970d9ab245a50fa03e9e27a6b8b6c27d254a56a", + "digest": "sha256:c88267011968f9cb535404f2ef822ab1b45d9bb8ba4e6fe675f41fe556f5ef1a", "evidence_files": 155, "evidence_root": "sha256:ff6dddfecfcc02cea55f46acaccc7eaecd27557209e98c3d5616ec02bdde31db", "files": 1085, - "generated_at_commit": "f2edef8dd82fa6f9a8f8c650b8f1d1f75fed13e6", - "source_tree": "sha256:5b976101df6c4525eebf6a9ab11dbe29718f4b8fb70d172a2b1cba616fd48fdc" + "generated_at_commit": "9119485e6358f70ba463997290e0f3be51aecb24", + "source_tree": "sha256:82e81635d7499a85183325c1968485dbdfb9a2c805869de9fdba13a8317e5239" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index a394907c..9bac57ff 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "58d4b12884ad334297e89d1f6f8b54c819d2e8052f817c663efc2a18f9f7ca40", - "last_commit": "2e8cef9", + "digest": "1c1e7ea90bd280ec2616a754131b2315453b0a51a2d8cc8e3c2954e6e9b5f6e7", + "last_commit": "56ed257", "name": "src", "purpose": "" } ], - "children_root": "sha256:7e0badc2664cee1f72c3d411750f2a790da389780abfced7d864c8d24bee7b84", - "compiled_at": "2026-10-07T01:20:29Z", + "children_root": "sha256:8b286db0ae4f814fa398b7f3ffc0a487227759a0137797f3203c733ce88edf03", + "compiled_at": "2026-10-07T02:28:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:a4177f17aba850e2784044f3173943420b001467135ba3dcbddea4e80362e161", + "digest": "sha256:5c4ce8cc01bf96f38d988d9a09da42d86876cf40968a5cabcda3b69aa4a52b6a", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 28, - "generated_at_commit": "27b2e165316a3db44d27934bf0866758577933d1", - "source_tree": "sha256:dcbe92fd5d69cc80b76ffd7a05e43950545e801027e5dabc1a9d6400d69ae609" + "generated_at_commit": "9119485e6358f70ba463997290e0f3be51aecb24", + "source_tree": "sha256:1c5b12e7c0e143ec1e1533e0f3e2e7306b6c7ab121e2fee412e6ce86cefe526f" } }, "history": [ diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index edfe2f80..f7b4e8b6 100644 --- a/crates/aien-cli/src/.crumb +++ b/crates/aien-cli/src/.crumb @@ -64,14 +64,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-07T01:20:29Z", + "compiled_at": "2026-10-07T02:28:51Z", "compiler": "crumb-compile/1", - "digest": "sha256:58d4b12884ad334297e89d1f6f8b54c819d2e8052f817c663efc2a18f9f7ca40", + "digest": "sha256:1c1e7ea90bd280ec2616a754131b2315453b0a51a2d8cc8e3c2954e6e9b5f6e7", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 25, - "generated_at_commit": "27b2e165316a3db44d27934bf0866758577933d1", - "source_tree": "sha256:da17730a7f9658b0f8009858396d5633ee85738b95ad24ba88c95ddf89591230" + "generated_at_commit": "9119485e6358f70ba463997290e0f3be51aecb24", + "source_tree": "sha256:63cc47424618d8c2adf61f08f6d8de6a50d09e2552e6392a8f93fe48de6886b4" } }, "history": [ diff --git a/crates/aien-cli/src/commands.rs b/crates/aien-cli/src/commands.rs index c1351ac6..5926e5ec 100644 --- a/crates/aien-cli/src/commands.rs +++ b/crates/aien-cli/src/commands.rs @@ -1269,20 +1269,12 @@ fn load_daemon_model( }, } - let label = format!( - "checkpoint loaded from {} ({}, model_id={}, config={}, model_sha256={}, tokenizer_sha256={})", - path.display(), - if tokenizer.is_some() { - "tokenizer loaded" - } else { - "tokenizer missing" - }, - manifest.model_id, - if has_config_json { - format!("{} (config.json)", config.model_id) - } else { - format!("{} (built in)", config.model_id) - }, + let label = checkpoint_loaded_label( + &path, + tokenizer.is_some(), + &manifest.model_id, + &config.model_id, + has_config_json, manifest.model_sha256.as_deref().unwrap_or("none"), manifest.tokenizer_sha256.as_deref().unwrap_or("none"), ); @@ -1295,6 +1287,36 @@ fn load_daemon_model( }) } +/// The one-line "checkpoint loaded" label. Its format is parsed by the interplane +/// verifier (interplane#76): keep it byte-identical (pinned by a test). +fn checkpoint_loaded_label( + path: &std::path::Path, + tokenizer_loaded: bool, + manifest_model_id: &str, + config_model_id: &str, + has_config_json: bool, + model_sha256: &str, + tokenizer_sha256: &str, +) -> String { + format!( + "checkpoint loaded from {} ({}, model_id={}, config={}, model_sha256={}, tokenizer_sha256={})", + path.display(), + if tokenizer_loaded { + "tokenizer loaded" + } else { + "tokenizer missing" + }, + manifest_model_id, + if has_config_json { + format!("{} (config.json)", config_model_id) + } else { + format!("{} (built in)", config_model_id) + }, + model_sha256, + tokenizer_sha256, + ) +} + /// Loaded daemon model parts: weights, tensor compute backend, backend label, /// model label, tokenizer. The KV manager is built from these by /// `aien_runtime::shared_kv::build_shared_kv_runtime` (one KV for spine and backend). @@ -1872,6 +1894,37 @@ pub async fn handle_aegis_command() { mod tests { use super::*; + #[test] + fn checkpoint_loaded_line_format_is_pinned() { + // interplane#76 parses this line; the text must not drift. + let line = checkpoint_loaded_label( + std::path::Path::new("/m/dir"), + true, + "mid", + "cfgid", + true, + "aaa", + "bbb", + ); + assert_eq!( + line, + "checkpoint loaded from /m/dir (tokenizer loaded, model_id=mid, config=cfgid (config.json), model_sha256=aaa, tokenizer_sha256=bbb)" + ); + let line = checkpoint_loaded_label( + std::path::Path::new("/m/dir"), + false, + "mid", + "cfgid", + false, + "none", + "none", + ); + assert_eq!( + line, + "checkpoint loaded from /m/dir (tokenizer missing, model_id=mid, config=cfgid (built in), model_sha256=none, tokenizer_sha256=none)" + ); + } + /// T4 launch budget: unset means the AIEN default 256 (not omega's 64), /// the log names it as the AIEN default with the evidence dir, and an /// explicit setting wins. diff --git a/crates/aien-inference-abi/src/tokenizer.rs b/crates/aien-inference-abi/src/tokenizer.rs index 2590bfb7..fa63e19f 100644 --- a/crates/aien-inference-abi/src/tokenizer.rs +++ b/crates/aien-inference-abi/src/tokenizer.rs @@ -10,15 +10,22 @@ use std::sync::Arc; #[derive(Debug, Clone, PartialEq, Eq)] pub enum TokenizerError { LoadError(String), + /// Chat rendering was asked of a plain (base) model that has no chat template. Not a + /// load failure: the tokenizer loaded fine. + NoChatTemplate(String), EncodeError(String), DecodeError(String), - ContextLengthExceeded { len: usize, max: usize }, + ContextLengthExceeded { + len: usize, + max: usize, + }, } impl fmt::Display for TokenizerError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::LoadError(e) => write!(f, "Failed to load tokenizer: {}", e), + Self::NoChatTemplate(e) => write!(f, "{}", e), Self::EncodeError(e) => write!(f, "Tokenization encoding failed: {}", e), Self::DecodeError(e) => write!(f, "Tokenization decoding failed: {}", e), Self::ContextLengthExceeded { len, max } => { @@ -144,7 +151,7 @@ fn ends_in_assistant(turns: &[(&str, &str)]) -> bool { } fn no_chat_template_error() -> TokenizerError { - TokenizerError::LoadError( + TokenizerError::NoChatTemplate( "no chat template: this is a plain (base) model, chat rendering is refused".to_string(), ) } diff --git a/crates/aien-inference-abi/tests/plain_model_load.rs b/crates/aien-inference-abi/tests/plain_model_load.rs index 27028534..fd339e38 100644 --- a/crates/aien-inference-abi/tests/plain_model_load.rs +++ b/crates/aien-inference-abi/tests/plain_model_load.rs @@ -99,3 +99,16 @@ fn non_string_template_key_is_refused_not_plain() { } let _ = std::fs::remove_dir_all(&dir); } + +#[test] +fn render_refusal_is_its_own_variant_not_a_load_failure() { + let tok = ChatTokenizer::from_model_dir(Path::new(DIR), None).unwrap(); + let err = tok.try_format_chat(&[("user", "hello")]).unwrap_err(); + assert!( + matches!(err, aien_inference_abi::TokenizerError::NoChatTemplate(_)), + "{err:?}" + ); + let text = err.to_string(); + assert!(text.contains("no chat template"), "{text}"); + assert!(!text.contains("Failed to load tokenizer"), "{text}"); +} diff --git a/crates/aien-runtime/src/server.rs b/crates/aien-runtime/src/server.rs index c2c337cf..c18c5ca8 100644 --- a/crates/aien-runtime/src/server.rs +++ b/crates/aien-runtime/src/server.rs @@ -33,6 +33,9 @@ pub struct AienRuntimeServer { /// NEXT-PHASE-1 v4 declared warm-up prompt (ACCEPTANCE-v4 Section 2(2)): /// fixed text, more than one 128-token prefill chunk once templated, so /// both the full-chunk and the remainder prefill paths run before serving. +/// Log line when the warm-up is skipped for a plain model (no chat template). +pub const WARM_UP_SKIPPED_PLAIN: &str = "Warm-up: skipped (plain model, no chat template)"; + pub const WARM_UP_TEXT: &str = "Warm-up turn before serving requests. This text is fixed and its one generated token is discarded. \ Warm-up turn before serving requests. This text is fixed and its one generated token is discarded. \ Warm-up turn before serving requests. This text is fixed and its one generated token is discarded. \ @@ -158,7 +161,7 @@ impl AienRuntimeServer { // NEXT-PHASE-1 v4: the declared warm-up, before the accept loop // serves anything (clients that connect meanwhile wait in the backlog). if self.warm_up.load(Ordering::SeqCst) { - self.run_warm_up().await; + println!(" {}", self.run_warm_up().await); } // NEXT-PHASE-1: the compose bridge (opened on the first RunComposeTask). @@ -270,9 +273,20 @@ fn text_suffix(previous: &str, decoded: &str) -> String { impl AienRuntimeServer { /// One greedy 1-token turn on `WARM_UP_TEXT`; the token is discarded. - /// Prints `Warm-up: 1 token in ms over prompt tokens (discarded)` - /// or `Warm-up: FAILED ...`; a failure does not stop the daemon. - async fn run_warm_up(&self) { + /// Returns the log line: `Warm-up: 1 token in ms over prompt tokens (discarded)`, + /// `Warm-up: FAILED ...` (a failure does not stop the daemon), or [`WARM_UP_SKIPPED_PLAIN`] + /// when the loaded tokenizer has no chat template (a plain model refuses chat turns by + /// design, so the chat warm-up is not attempted). + pub async fn run_warm_up(&self) -> String { + if self + .tokenizer + .read() + .expect("tokenizer lock") + .as_ref() + .is_some_and(|t| matches!(t.template(), aien_inference_abi::ChatTemplate::None)) + { + return WARM_UP_SKIPPED_PLAIN.to_string(); + } let messages = vec![crate::control::ChatTurn { role: "user".into(), content: WARM_UP_TEXT.into(), @@ -299,12 +313,12 @@ impl AienRuntimeServer { .await; let ms = t0.elapsed().as_millis(); match out { - Ok(g) => println!( - " Warm-up: {} token in {ms} ms over {} prompt tokens (discarded)", + Ok(g) => format!( + "Warm-up: {} token in {ms} ms over {} prompt tokens (discarded)", g.tokens, prompt_tokens.unwrap_or(0) ), - Err(e) => println!(" Warm-up: FAILED after {ms} ms: {e}"), + Err(e) => format!("Warm-up: FAILED after {ms} ms: {e}"), } } } diff --git a/crates/aien-runtime/tests/warm_up_before_serving_test.rs b/crates/aien-runtime/tests/warm_up_before_serving_test.rs index 1a47af5e..30141ddd 100644 --- a/crates/aien-runtime/tests/warm_up_before_serving_test.rs +++ b/crates/aien-runtime/tests/warm_up_before_serving_test.rs @@ -335,3 +335,20 @@ async fn cpu_reference_tokens_unchanged_by_warm_up() { assert!(!runs[0].is_empty()); assert_eq!(runs[0], runs[1], "the warm-up changed the turn's tokens"); } + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn plain_model_warm_up_is_skipped_not_failed() { + // A plain (base) model has no chat template; the chat warm-up is skipped. + let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../aien-inference-abi/fixtures/openwaldo-byte"); + let plain = ChatTokenizer::from_model_dir(&dir, None).expect("plain fixture loads"); + let tmp = tempfile::tempdir().unwrap(); + let server = AienRuntimeServer::new(spine(), tmp.path().join("plain.sock")); + server.set_tokenizer(plain); + // No step loop is running: an attempted warm-up would hang or fail, a skip returns at once. + let line = tokio::time::timeout(Duration::from_secs(5), server.run_warm_up()) + .await + .expect("a skipped warm-up returns immediately"); + assert_eq!(line, "Warm-up: skipped (plain model, no chat template)"); + assert!(!line.contains("FAILED"), "{line}"); +}