interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-inference-abi / tests / chat_prompt_pin.rs

66 lines · 2652 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Pins the composed chat prompt token ids for a fixed chat input, so the plain-model
17//! change cannot alter how chat-template models build prompts. Ids were computed on
18//! origin/main (86841ba) before the change.
19
20use aien_inference_abi::tokenizer::{ChatTemplate, ChatTokenizer};
21use std::path::Path;
22
23const TURNS: &[(&str, &str)] = &[("system", "You are terse."), ("user", " What is 2+2?\n")];
24
25fn ids(dir: &Path) -> (ChatTemplate, String, Vec<u32>) {
26 let tok = ChatTokenizer::from_model_dir(dir, None).expect("load");
27 let text = tok.template().render(TURNS);
28 let ids = tok.encode(&text).expect("encode");
29 (tok.template(), text, ids)
30}
31
32#[test]
33fn pin_tinyllama_zephyr_fixture_prompt_ids() {
34 let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures");
35 let (t, text, ids) = ids(&dir);
36 println!("PIN zephyr text={text:?} ids={ids:?}");
37 assert_eq!(t, ChatTemplate::Zephyr);
38 assert_eq!(
39 text,
40 "<|system|>\nYou are terse.</s>\n<|user|>\nWhat is 2+2?</s>\n<|assistant|>\n"
41 );
42 assert_eq!(ids, PIN_ZEPHYR);
43}
44
45/// CAND-4 model (Llama-3.2-1B-Instruct): set `AIEN_LLAMA3_DIR` to its model directory.
46#[test]
47fn pin_llama32_1b_prompt_ids() {
48 let Ok(dir) = std::env::var("AIEN_LLAMA3_DIR") else {
49 eprintln!("AIEN_LLAMA3_DIR not set: Llama 3.2 pin skipped");
50 return;
51 };
52 let (t, text, ids) = ids(Path::new(&dir));
53 println!("PIN llama3 text={text:?} ids={ids:?}");
54 assert_eq!(t, ChatTemplate::Llama3);
55 assert_eq!(ids, PIN_LLAMA32);
56}
57
58const PIN_ZEPHYR: &[u32] = &[
59 1, 529, 29989, 5205, 29989, 29958, 13, 3492, 526, 1935, 344, 29889, 2, 29871, 13, 29966, 29989,
60 1792, 29989, 29958, 13, 5618, 338, 29871, 29906, 29974, 29906, 29973, 2, 29871, 13, 29966,
61 29989, 465, 22137, 29989, 29958, 13,
62];
63const PIN_LLAMA32: &[u32] = &[
64 128000, 128006, 9125, 128007, 271, 2675, 527, 51637, 13, 128009, 128006, 882, 128007, 271,
65 3923, 374, 220, 17, 10, 17, 30, 128009, 128006, 78191, 128007, 271,
66];