Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/patches/6fcbf9b8a94a6d43 # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aienux#253 (code only) closed derived `6fcbf9b8a94a6d43` #253 Imported from GitHub aien-dev/aienux#253 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `e375ee763d9d8155c1546aea93ff66f78665d6d7` · Head `9635a724c3d7b90b5cf5dcc4c14de8d69fa96de6` ### Apply it ``` git checkout -b patch-6fcbf9b8a94a6d43 e375ee763d9d8155c1546aea93ff66f78665d6d7 curl -fsSL https://interplane.io/drakestapleton/aienux/patches/6fcbf9b8a94a6d43.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aienux 253 9635a724c3d7b90b5cf5dcc4c14de8d69fa96de6 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aienux","number":253,"url":"https://github.com/aien-dev/aienux/pull/253","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:04Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index 5632db55..8bee6353 100644 --- a/.crumb +++ b/.crumb @@ -21,8 +21,8 @@ "generated": { "children": [ { - "digest": "21930fafd0e3f9797b75190d593e77cc310ee3c2469f87d0c73ac7d94e8fc61c", - "last_commit": "a863d5c", + "digest": "56d2cf6d9dd340a9df0a880d1fd9879cf3cd31eb1d827302662144b5f2bebe2d", + "last_commit": "4c94ce7", "name": "crates", "purpose": "Directory crates. Purpose not yet described by a human." }, @@ -39,21 +39,21 @@ "purpose": "Directory native. Purpose not yet described by a human." }, { - "digest": "8dfe82f4bd17de04fde576365e95a317d81b378c7f26928182d3656a124488c5", - "last_commit": "a863d5c", + "digest": "e7ab7a937d3d63828c4b3431a5f958217db1c03819f3a7d7532c86d648c85c98", + "last_commit": "91bfd45", "name": "scripts", "purpose": "Directory scripts. Purpose not yet described by a human." } ], - "children_root": "sha256:ca6b7190dfe4b206486c3d0c418a091f4b8582abe494ff03eb9d07df910111bc", - "compiled_at": "2026-10-04T14:06:45Z", + "children_root": "sha256:0c24eafb4f0e5a4e8c9e938f907e1a1449bed87a892953e9325175b24b48d1a0", + "compiled_at": "2026-10-04T15:04:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:ded769ff9d9b04bbc04af1c61784831b1373432d1274203c4c826ac4a3193663", - "evidence_files": 141, - "evidence_root": "sha256:9127a58b4599df77ed78130a9ebd0fd10c5e0d72ba1c118d475072001ccd6185", - "files": 2826, - "generated_at_commit": "ea240754b8adac440fbadcdfc3c1cd04c54f8e07", - "source_tree": "sha256:769c54939d03e17c9814136b14cb7566a62369d4bcac43cac8b5c564e94720b6" + "digest": "sha256:82262b0cb3a3b4612eb0482fa0baaa7378be761bfd5c1cc44c685f8acb5feead", + "evidence_files": 142, + "evidence_root": "sha256:3b8ecf493ee0e4513ffb21827d50f30092f361f8a9a66e5abe4791e94c1cc8ec", + "files": 2829, + "generated_at_commit": "4c94ce75a45f4467f55201581ccd59fdbbd58399", + "source_tree": "sha256:ffa23d565d0fce72aa21b0c287feb10893f6d9a1fb637cc3981fe007fe37d935" }, "owner_lane": "", "provenance": { diff --git a/crates/.crumb b/crates/.crumb index cb957bd2..68eab4f4 100644 --- a/crates/.crumb +++ b/crates/.crumb @@ -150,14 +150,14 @@ } ], "children_root": "sha256:b2cdd9368caf75a849d660b36a845142591375047c280ea7208dc529091d8b1a", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-04T15:04:07Z", "compiler": "crumb-compile/1", - "digest": "sha256:21930fafd0e3f9797b75190d593e77cc310ee3c2469f87d0c73ac7d94e8fc61c", + "digest": "sha256:56d2cf6d9dd340a9df0a880d1fd9879cf3cd31eb1d827302662144b5f2bebe2d", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 229, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:24bc0f4356e36822dda23cb38e7187527708eec4739c13e6b649a077e6a13457" + "files": 230, + "generated_at_commit": "4c94ce75a45f4467f55201581ccd59fdbbd58399", + "source_tree": "sha256:b241ed9dd40152af98fac8e02f289773b60926a146971f858d517f1c0c2bbf8a" }, "owner_lane": "", "provenance": { diff --git a/crates/aienos-infer/examples/l6_host.rs b/crates/aienos-infer/examples/l6_host.rs new file mode 100644 index 00000000..a2a3ddff --- /dev/null +++ b/crates/aienos-infer/examples/l6_host.rs @@ -0,0 +1,171 @@ +//! L6-A host-side tokens-per-second harness (aienos#34 lane 6). +//! +//! Runs the same code path as the kernel (`aienos-infer-kernel`) and the host +//! tests: `encode_chat` + `DecodeState::prefill` + greedy `argmax`/`forward`, +//! f32 activations, single thread. Part A checks the first 8 ids against the +//! golden reply; Part B keeps decoding (ignoring end-of-turn) to N tokens and +//! times each `forward` call in microseconds. +//! +//! Env: AIENOS_MODEL (default $HOME/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf), +//! AIENOS_N (default 64), AIENOS_COMMIT (printed as `commit`). +//! Output: one `key: value` line per fact. Exit 0 ok, 1 parity FAIL, 2 wrong model. + +use aienos_infer::{argmax, DecodeState, Gguf, Model, Tokenizer}; +use std::time::Instant; + +const PROMPT: &str = "What is the capital of France?"; +const MODEL_SHA256: &str = "3f5a22426976ab26cfe84dba63c1d08391717abb1af893e10f1b2968d862dcc1"; +const GOLDEN: [u32; 8] = [791, 6864, 315, 9822, 374, 12366, 13, 128009]; + +fn sha256_hex(data: &[u8]) -> String { + const K: [u32; 64] = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, + 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, + 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, + 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, + 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, + 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, + 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, + 0xc67178f2, + ]; + let mut h: [u32; 8] = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, + 0x5be0cd19, + ]; + let mut block = |b: &[u8]| { + let mut w = [0u32; 64]; + for i in 0..16 { + w[i] = u32::from_be_bytes([b[4 * i], b[4 * i + 1], b[4 * i + 2], b[4 * i + 3]]); + } + for i in 16..64 { + let s0 = w[i - 15].rotate_right(7) ^ w[i - 15].rotate_right(18) ^ (w[i - 15] >> 3); + let s1 = w[i - 2].rotate_right(17) ^ w[i - 2].rotate_right(19) ^ (w[i - 2] >> 10); + w[i] = w[i - 16] + .wrapping_add(s0) + .wrapping_add(w[i - 7]) + .wrapping_add(s1); + } + let mut v = h; + for i in 0..64 { + let s1 = v[4].rotate_right(6) ^ v[4].rotate_right(11) ^ v[4].rotate_right(25); + let ch = (v[4] & v[5]) ^ (!v[4] & v[6]); + let t1 = v[7] + .wrapping_add(s1) + .wrapping_add(ch) + .wrapping_add(K[i]) + .wrapping_add(w[i]); + let s0 = v[0].rotate_right(2) ^ v[0].rotate_right(13) ^ v[0].rotate_right(22); + let maj = (v[0] & v[1]) ^ (v[0] & v[2]) ^ (v[1] & v[2]); + let t2 = s0.wrapping_add(maj); + v = [ + t1.wrapping_add(t2), + v[0], + v[1], + v[2], + v[3].wrapping_add(t1), + v[4], + v[5], + v[6], + ]; + } + for i in 0..8 { + h[i] = h[i].wrapping_add(v[i]); + } + }; + let (blocks, rem) = data.as_chunks::<64>(); + for c in blocks { + block(c); + } + let mut tail = rem.to_vec(); + tail.push(0x80); + while tail.len() % 64 != 56 { + tail.push(0); + } + tail.extend_from_slice(&((data.len() as u64) * 8).to_be_bytes()); + for c in tail.as_chunks::<64>().0 { + block(c); + } + h.iter().map(|x| format!("{x:08x}")).collect() +} + +fn join(v: &[impl ToString]) -> String { + v.iter() + .map(|x| x.to_string()) + .collect::>() + .join(" ") +} + +fn main() { + let path = std::env::var("AIENOS_MODEL").unwrap_or_else(|_| { + format!( + "{}/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf", + std::env::var("HOME").unwrap_or_default() + ) + }); + let n: usize = std::env::var("AIENOS_N") + .ok() + .and_then(|s| s.parse().ok()) + .unwrap_or(64); + let bytes = std::fs::read(&path).unwrap_or_else(|e| { + eprintln!("cannot read model {path}: {e}"); + std::process::exit(2); + }); + let sha = sha256_hex(&bytes); + println!( + "commit: {}", + std::env::var("AIENOS_COMMIT").unwrap_or_else(|_| "unknown".into()) + ); + println!("model_path: {path}"); + println!("model_sha256: {sha}"); + println!("model_size_bytes: {}", bytes.len()); + if sha != MODEL_SHA256 { + eprintln!("model sha256 mismatch, want {MODEL_SHA256}"); + std::process::exit(2); + } + let g = Gguf::parse(&bytes).expect("gguf"); + let m = Model::new(&g).expect("model"); + let tok = Tokenizer::new(&g.tokenizer().expect("tokenizer data")).expect("tokenizer"); + let ids = tok.encode_chat(PROMPT).expect("encode"); + println!("prompt: {PROMPT}"); + println!("prompt_ids: {}", join(&ids)); + println!("threads: 1"); + + let mut st = DecodeState::new(&m, ids.len() + n + 8); + let t0 = Instant::now(); + st.prefill(&m, &ids).expect("prefill"); + let prefill_us = t0.elapsed().as_micros() as u64; + println!("prefill_us: {prefill_us}"); + + // Same loop as the kernel, except the end-of-turn stop is ignored. + let mut out: Vec = Vec::with_capacity(n); + let mut tok_us: Vec = Vec::with_capacity(n); + loop { + let t = argmax(&st.logits); + out.push(t); + if out.len() == n { + break; + } + let t1 = Instant::now(); + st.forward(&m, t, true).expect("forward"); + tok_us.push(t1.elapsed().as_micros() as u64); + } + println!("tokens: {}", join(&out)); + println!("tok_us: {}", join(&tok_us)); + let mean = tok_us.iter().sum::() as f64 / tok_us.len().max(1) as f64; + println!("decode_tokens: {}", tok_us.len()); + println!("mean_tok_us: {mean:.1}"); + println!("tok_per_s: {:.3}", 1e6 / mean); + println!( + "text: {}", + String::from_utf8_lossy(&tok.decode(&out).expect("decode")).escape_debug() + ); + + let pass = out.len() >= GOLDEN.len() && out[..GOLDEN.len()] == GOLDEN; + println!("golden_ids: {}", join(&GOLDEN)); + println!("PARITY: {}", if pass { "PASS" } else { "FAIL" }); + if !pass { + std::process::exit(1); + } +} diff --git a/evidence/l6_host_3f5a22426976.json b/evidence/l6_host_3f5a22426976.json new file mode 100644 index 00000000..4ec72e8f --- /dev/null +++ b/evidence/l6_host_3f5a22426976.json @@ -0,0 +1,396 @@ +{ + "commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", + "core_pinned": 0, + "cpu_part": "0xd85x10,0xd87x10", + "decode_tokens": 63, + "generated_at_utc": "2026-10-04T14:17:41Z", + "golden_ids": [ + 791, + 6864, + 315, + 9822, + 374, + 12366, + 13, + 128009 + ], + "governor": "performance", + "harness_command": "AIENOS_N=64 taskset -c cargo run --release -p aienos-infer --example l6_host", + "host": "spark-b87b", + "kernel": "7.0.0-1019-nvidia", + "legs": { + "core0": { + "core_pinned": 0, + "cpu_part": "0xd87", + "decode_tokens": 63, + "exit_code": 0, + "mean_tok_us": 2384096.9, + "parity": "PASS", + "prefill_us": 36193422, + "text": "The capital of France is Paris.assistant\\n\\nThat\\'s incorrect. The capital of France is actually Paris, not Rome (which is the capital of Italy). Rome is the capital of Italy.assistant\\n\\nYou are correct, the capital of France is Paris, not Rome. Paris is the largest", + "tok_per_s": 0.419, + "tok_us": [ + 2645993, + 2645861, + 2645765, + 2647295, + 2643568, + 2642450, + 2644655, + 2646127, + 2645611, + 2644015, + 2645888, + 2648054, + 2649105, + 2642911, + 2646731, + 2645476, + 2646050, + 2646991, + 2646152, + 2644233, + 2648091, + 2649439, + 2646815, + 2643643, + 2646156, + 2646576, + 2646583, + 2644265, + 2648092, + 2646326, + 2649575, + 2646539, + 2645658, + 2648465, + 2643875, + 2649899, + 2650318, + 2646451, + 2646171, + 2644762, + 2649609, + 2648418, + 2646782, + 2644604, + 2649835, + 2649027, + 2647252, + 2649351, + 2646215, + 2647329, + 2016664, + 1320574, + 1320430, + 1321246, + 1321021, + 1321093, + 1320499, + 1321239, + 1321250, + 1321435, + 1321229, + 1321415, + 1320959 + ], + "tokens": [ + 791, + 6864, + 315, + 9822, + 374, + 12366, + 13, + 128009, + 128006, + 78191, + 128007, + 271, + 4897, + 596, + 15465, + 13, + 578, + 6864, + 315, + 9822, + 374, + 3604, + 12366, + 11, + 539, + 22463, + 320, + 8370, + 374, + 279, + 6864, + 315, + 15704, + 570, + 22463, + 374, + 279, + 6864, + 315, + 15704, + 13, + 128009, + 128006, + 78191, + 128007, + 271, + 2675, + 527, + 4495, + 11, + 279, + 6864, + 315, + 9822, + 374, + 12366, + 11, + 539, + 22463, + 13, + 12366, + 374, + 279, + 7928 + ] + }, + "core19": { + "core_pinned": 19, + "cpu_part": "0xd85", + "decode_tokens": 63, + "exit_code": 0, + "mean_tok_us": 714774.7, + "parity": "PASS", + "prefill_us": 9747295, + "text": "The capital of France is Paris.assistant\\n\\nThat\\'s incorrect. The capital of France is actually Paris, not Rome (which is the capital of Italy). Rome is the capital of Italy.assistant\\n\\nYou are correct, the capital of France is Paris, not Rome. Paris is the largest", + "tok_per_s": 1.399, + "tok_us": [ + 714757, + 714874, + 713676, + 714618, + 714490, + 714389, + 713138, + 714388, + 714383, + 713981, + 714679, + 714501, + 714284, + 714271, + 715289, + 714549, + 714083, + 715168, + 714835, + 714358, + 714510, + 714883, + 714720, + 714546, + 714941, + 715261, + 714233, + 714603, + 715042, + 715073, + 714718, + 715464, + 715142, + 714669, + 714595, + 714970, + 714798, + 714832, + 715153, + 715068, + 714952, + 714435, + 715104, + 715234, + 714949, + 715569, + 714941, + 714689, + 714666, + 715289, + 715083, + 715230, + 715371, + 715173, + 715024, + 714647, + 715480, + 715046, + 714627, + 715158, + 715190, + 714569, + 714448 + ], + "tokens": [ + 791, + 6864, + 315, + 9822, + 374, + 12366, + 13, + 128009, + 128006, + 78191, + 128007, + 271, + 4897, + 596, + 15465, + 13, + 578, + 6864, + 315, + 9822, + 374, + 3604, + 12366, + 11, + 539, + 22463, + 320, + 8370, + 374, + 279, + 6864, + 315, + 15704, + 570, + 22463, + 374, + 279, + 6864, + 315, + 15704, + 13, + 128009, + 128006, + 78191, + 128007, + 271, + 2675, + 527, + 4495, + 11, + 279, + 6864, + 315, + 9822, + 374, + 12366, + 11, + 539, + 22463, + 13, + 12366, + 374, + 279, + 7928 + ] + } + }, + "llama_cpp": { + "build": "4a89937 1", + "command": "taskset -c 0 /home/drakestapleton/llama.cpp-build/build/bin/llama-bench -m /home/drakestapleton/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf -ngl 0 -t 1 -p 0 -n 64 -r 3 -o json", + "threads": 1, + "tok_per_s": 6.670207, + "tok_per_s_core19": 20.105553 + }, + "mean_tok_us": 2384096.9, + "model": { + "path": "/home/drakestapleton/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf", + "sha256": "3f5a22426976ab26cfe84dba63c1d08391717abb1af893e10f1b2968d862dcc1", + "size_bytes": 807694368 + }, + "nproc": 20, + "parity": "PASS", + "prefill_us": 36193422, + "prompt": "What is the capital of France?", + "reference": { + "file": "evidence/config_a_reference_bundle.json", + "note": "20 threads, server; not like for like", + "tok_per_s": 54.2 + }, + "threads": 1, + "tok_per_s": 0.419, + "tok_us": [ + 2645993, + 2645861, + 2645765, + 2647295, + 2643568, + 2642450, + 2644655, + 2646127, + 2645611, + 2644015, + 2645888, + 2648054, + 2649105, + 2642911, + 2646731, + 2645476, + 2646050, + 2646991, + 2646152, + 2644233, + 2648091, + 2649439, + 2646815, + 2643643, + 2646156, + 2646576, + 2646583, + 2644265, + 2648092, + 2646326, + 2649575, + 2646539, + 2645658, + 2648465, + 2643875, + 2649899, + 2650318, + 2646451, + 2646171, + 2644762, + 2649609, + 2648418, + 2646782, + 2644604, + 2649835, + 2649027, + 2647252, + 2649351, + 2646215, + 2647329, + 2016664, + 1320574, + 1320430, + 1321246, + 1321021, + 1321093, + 1320499, + 1321239, + 1321250, + 1321435, + 1321229, + 1321415, + 1320959 + ] +} diff --git a/scripts/.crumb b/scripts/.crumb index 5d01b17d..d7ae7223 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -7,14 +7,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T13:47:18Z", + "compiled_at": "2026-10-04T14:35:29Z", "compiler": "crumb-compile/1", - "digest": "sha256:8dfe82f4bd17de04fde576365e95a317d81b378c7f26928182d3656a124488c5", + "digest": "sha256:e7ab7a937d3d63828c4b3431a5f958217db1c03819f3a7d7532c86d648c85c98", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 59, - "generated_at_commit": "a863d5c1f5bd89c88c5f6671eecfd27b599ee512", - "source_tree": "sha256:66002fde44f13e4701cb10356a0acb85be6bc1c842ac5b148b4381fd7d520a97" + "files": 60, + "generated_at_commit": "91bfd45b6201152df26661469f2d984b8b123e1d", + "source_tree": "sha256:e17431f5154acc3d92284d341f75616bbc2c908fb3d0b28544de5223da21fb28" }, "owner_lane": "", "provenance": { diff --git a/scripts/l6_host_receipt.sh b/scripts/l6_host_receipt.sh new file mode 100755 index 00000000..6e2dc3e5 --- /dev/null +++ b/scripts/l6_host_receipt.sh @@ -0,0 +1,76 @@ +#!/usr/bin/env bash +# L6-A: host-side tokens-per-second receipt (aienos#34 lane 6). +# Runs the l6_host example pinned to cores 0 and 19 (core types are read from /proc/cpuinfo, not assumed; +# on this machine they interleave: cpu0=0xd87 A725, cpu19=0xd85 X925), +# runs llama.cpp single-thread on the same model, writes evidence/l6_host_.json. +# Reproduce: scripts/l6_host_receipt.sh (env: AIENOS_MODEL, AIENOS_N, LLAMA_BENCH) +set -euo pipefail +cd "$(dirname "$0")/.." +MODEL="${AIENOS_MODEL:-$HOME/models/aien-mail/Llama-3.2-1B-Instruct-Q4_K_M.gguf}" +N="${AIENOS_N:-64}" +LB="${LLAMA_BENCH:-$HOME/llama.cpp-build/bin/llama-bench}" +[ -x "$LB" ] || LB="$HOME/llama.cpp-build/build/bin/llama-bench" +COMMIT="$(git rev-parse HEAD)" +TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT +export AIENOS_MODEL="$MODEL" AIENOS_N="$N" AIENOS_COMMIT="$COMMIT" + +GOV="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null || echo unknown)" +NPROC="$(nproc)" +PARTS="$(grep -E '^CPU part' /proc/cpuinfo | awk '{print $4}' | sort | uniq -c | awk '{print $2 "x" $1}' | paste -sd, -)" +HOST="$(hostname)"; KERNEL="$(uname -r)" +echo "commit=$COMMIT governor=$GOV nproc=$NPROC cpu_part=$PARTS host=$HOST kernel=$KERNEL" + +CMD="cargo run --release -p aienos-infer --example l6_host" +cargo build --release -p aienos-infer --example l6_host +for core in 0 19; do + echo "RUN: AIENOS_MODEL=$MODEL AIENOS_N=$N taskset -c $core $CMD" + rc=0; taskset -c "$core" $CMD >"$TMP/run$core.txt" || rc=$? + echo "exit=$rc"; echo "$rc" >"$TMP/rc$core" + grep -E '^(prefill_us|decode_tokens|mean_tok_us|tok_per_s|PARITY):' "$TMP/run$core.txt" +done + +LLAMA_BUILD="NOT_RUN"; LLAMA_TPS="null"; LLAMA_TPS19="null" +LLCMD="taskset -c 0 $LB -m $MODEL -ngl 0 -t 1 -p 0 -n 64 -r 3 -o json" +if [ -x "$LB" ]; then + echo "RUN: $LLCMD" + taskset -c 0 "$LB" -m "$MODEL" -ngl 0 -t 1 -p 0 -n 64 -r 3 -o json >"$TMP/ll0.json" 2>"$TMP/ll0.err" || true + LLAMA_TPS="$(jq '[.[]|select(.n_gen==64)|.avg_ts][0] // null' "$TMP/ll0.json")" + LLAMA_BUILD="$(jq -r '.[0]|"\(.build_commit) \(.build_number)"' "$TMP/ll0.json")" + echo "RUN: ${LLCMD/taskset -c 0/taskset -c 19}" + taskset -c 19 "$LB" -m "$MODEL" -ngl 0 -t 1 -p 0 -n 64 -r 3 -o json >"$TMP/ll19.json" 2>/dev/null || true + LLAMA_TPS19="$(jq '[.[]|select(.n_gen==64)|.avg_ts][0] // null' "$TMP/ll19.json")" +else + echo "llama-bench not found: NOT_RUN" +fi + +cpart() { awk -v c="$1" '/^processor/{p=$3} /^CPU part/{if(p==c)print $4}' /proc/cpuinfo; } # 0xd85=Cortex-X925, 0xd87=Cortex-A725 +val() { sed -n "s/^$2: //p" "$TMP/run$1.txt"; } +leg() { # core -> JSON object + jq -n --arg core "$1" --arg parity "$(val "$1" PARITY)" --arg ids "$(val "$1" tokens)" \ + --arg us "$(val "$1" tok_us)" --arg text "$(val "$1" text)" \ + --argjson prefill "$(val "$1" prefill_us)" --argjson dt "$(val "$1" decode_tokens)" \ + --argjson mean "$(val "$1" mean_tok_us)" --argjson tps "$(val "$1" tok_per_s)" \ + --argjson rc "$(cat "$TMP/rc$1")" --arg part "$(cpart "$1")" \ + '{core_pinned:($core|tonumber), cpu_part:$part, exit_code:$rc, parity:$parity, prefill_us:$prefill, decode_tokens:$dt, + tokens:($ids|split(" ")|map(tonumber)), tok_us:($us|split(" ")|map(tonumber)), + mean_tok_us:$mean, tok_per_s:$tps, text:$text}' +} +SHA="$(val 0 model_sha256)" +OUT="evidence/l6_host_${SHA:0:12}.json" +jq -n --arg commit "$COMMIT" --arg path "$MODEL" --arg sha "$SHA" --argjson size "$(val 0 model_size_bytes)" \ + --arg prompt "$(val 0 prompt)" --arg golden "$(val 0 golden_ids)" \ + --argjson c0 "$(leg 0)" --argjson c19 "$(leg 19)" \ + --arg cpu_part "$PARTS" --arg gov "$GOV" --arg host "$HOST" --arg kernel "$KERNEL" --argjson nproc "$NPROC" \ + --arg lb "$LLAMA_BUILD" --arg llcmd "$LLCMD" --argjson lt0 "$LLAMA_TPS" --argjson lt19 "$LLAMA_TPS19" \ + --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg cmd "AIENOS_N=$N taskset -c $CMD" \ + '{commit:$commit, model:{path:$path, sha256:$sha, size_bytes:$size}, prompt:$prompt, + golden_ids:($golden|split(" ")|map(tonumber)), parity:($c0.parity), + prefill_us:$c0.prefill_us, decode_tokens:$c0.decode_tokens, tok_us:$c0.tok_us, + mean_tok_us:$c0.mean_tok_us, tok_per_s:$c0.tok_per_s, core_pinned:0, + cpu_part:$cpu_part, nproc:$nproc, governor:$gov, host:$host, kernel:$kernel, + legs:{core0:$c0, core19:$c19}, + harness_command:$cmd, threads:1, + llama_cpp:{build:$lb, threads:1, tok_per_s:$lt0, tok_per_s_core19:$lt19, command:$llcmd}, + reference:{file:"evidence/config_a_reference_bundle.json", tok_per_s:54.2, note:"20 threads, server; not like for like"}, + generated_at_utc:$now}' | jq -S . >"$OUT" +echo "wrote $OUT" ```