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
GitHub aien-dev/aien-sovereign-core-mv#247 (code only)
Fetch it
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/f980ac0fc63ed0a8.bundle -o f980ac0fc63ed0a8.bundle git fetch f980ac0fc63ed0a8.bundle refs/pull/247/head
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
247
bf21efcdaad60c537df3a55e96f9351ff6e675e2
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":247,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/247","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:31Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 135260a8..1ecb0d4c 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:009593670dc7accc2b442a6a8c6f3b848ab73de4d6e61df57401bf4bf00b294a", - "compiled_at": "2026-10-06T23:04:15Z", + "compiled_at": "2026-10-06T23:16:27Z", "compiler": "crumb-compile/1", - "digest": "sha256:5fcc1a2013d7d54bf2fc775cb6872255c96ca2de9a53c6e60ed26fec29a38e8c", - "evidence_files": 80, - "evidence_root": "sha256:8920c1b8b9d7bddb4f92b61c3855179967991bed932999d2ba8cc98ef32f7837", - "files": 935, - "generated_at_commit": "5b9ccdf99848b455930f364705cd7464d556335c", - "source_tree": "sha256:984a6f9788c923cd57aad1577e5a870b6ba2c7a9e7a6256c2e3336c4c948f86f" + "digest": "sha256:93a0643a652866abd03be0400a2aa6afe25da7d85663559b5c06fd0ae67d0ebb", + "evidence_files": 90, + "evidence_root": "sha256:913405b594470a9dfda6998ea0386eba372f438bce4e9d05c062369a9f7b1e22", + "files": 947, + "generated_at_commit": "0dee0dc6ebbeddf60b9b69a9fcf2c363eb552814", + "source_tree": "sha256:5e454af3e4525e2235ca3ebb75db74ac59c69d70450ad34f31e007f8e3226845" } }, "history": [], diff --git a/Cargo.lock b/Cargo.lock index e0136450..97f31a93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,6 +57,7 @@ version = "0.1.0" dependencies = [ "aien-inference-abi", "aien-kv-cache", + "aien-omega-gpu", "aien-runtime", "aien-scheduler", "async-trait", diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index 44464248..2cbeab06 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "3062b8985e319718022104992c0d01ef7f31900a3e24a29613e901c679b2f649", - "last_commit": "aec763c", + "digest": "b51d47ac56083a63aa043fdbaaeaee6a65e87485d4b40a179b3fbc9726ab94db", + "last_commit": "8c5294c", "name": "src", "purpose": "" } ], - "children_root": "sha256:29019a0a594a2f7d9cdb902777848df5fa77da996e754c842934fd9f4cc74817", - "compiled_at": "2026-10-06T17:31:20Z", + "children_root": "sha256:0bcda6a58f2ed2c6bdaae3923cf34932c6ee003d18a72a4259afc6cd9998dbf7", + "compiled_at": "2026-10-06T23:10:12Z", "compiler": "crumb-compile/1", - "digest": "sha256:e820f5a2c20acccef8b7b31e55a5481d4db44307d631ae0b2414a046c49ebd6d", + "digest": "sha256:0309f5ed1dae40099bd9ce71d11c3fc07cd18b48d7ac1672e52e1e79562ac4e9", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 28, - "generated_at_commit": "ff21694b8cc8d19a41b7ed2d13eb9af76d17dd25", - "source_tree": "sha256:72421f7c45f6772df6a85c2ec1fd7830dad5bed2fcd4d70397f1e5d7a9fa536e" + "generated_at_commit": "f6cd19cfcd34e5b567e30307d70ee79c16b033fd", + "source_tree": "sha256:09f1b194fb0018c72cf64fb2465a0e9b3b58412931dad5007dcab199a1b86974" } }, "history": [ diff --git a/crates/aien-cli/Cargo.toml b/crates/aien-cli/Cargo.toml index 3638d14f..cafa0175 100644 --- a/crates/aien-cli/Cargo.toml +++ b/crates/aien-cli/Cargo.toml @@ -25,6 +25,7 @@ aien-inference-abi = { path = "../aien-inference-abi" } aien-kv-cache = { path = "../aien-kv-cache" } aien-scheduler = { path = "../aien-scheduler" } aien-runtime = { path = "../aien-runtime" } +aien-omega-gpu = { path = "../aien-omega-gpu" } [features] # NEXT-PHASE-2 fault harness only: named hold points in `aien compose execute`. diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index 8ef17361..bf0d2c6e 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-06T15:58:15Z", + "compiled_at": "2026-10-06T23:10:12Z", "compiler": "crumb-compile/1", - "digest": "sha256:3062b8985e319718022104992c0d01ef7f31900a3e24a29613e901c679b2f649", + "digest": "sha256:b51d47ac56083a63aa043fdbaaeaee6a65e87485d4b40a179b3fbc9726ab94db", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 25, - "generated_at_commit": "743daed144fa5b7136202a3cf8c49134fba1c4b7", - "source_tree": "sha256:61f75a4cf4b8b5cf3895f1f2eba5905233a0909afe41543e47be0fd2e206b750" + "generated_at_commit": "f6cd19cfcd34e5b567e30307d70ee79c16b033fd", + "source_tree": "sha256:81bbf7425c009ba785b7af1be89d9db641acd73da7a05460f94f78d764eb96d1" } }, "history": [ diff --git a/crates/aien-cli/src/commands.rs b/crates/aien-cli/src/commands.rs index ca19ddab..22a3b6aa 100644 --- a/crates/aien-cli/src/commands.rs +++ b/crates/aien-cli/src/commands.rs @@ -1322,8 +1322,14 @@ fn build_native_daemon_backend() -> Result<DaemonBackendParts, String> { || std::env::var("AIEN_REQUIRE_BLACKWELL") .map(|v| v.trim() == "1" || v.trim().eq_ignore_ascii_case("true")) .unwrap_or(false); + // T4 launch budget: parsed before the backend is chosen, so a bad value is + // always fatal; applied before the first matmul (omega clears its kernel + // cache on a change). Unset means the AIEN default (256), not omega's 64. + let cta_setting = std::env::var(aien_omega_gpu::CTA_BUDGET_ENV).ok(); + let cta_budget = aien_omega_gpu::parse_cta_budget(cta_setting.as_deref())?; let omega = aien_inference_abi::OmegaGb10Backend::new(); if omega.is_available() { + println!(" {}", apply_omega_cta_budget(cta_budget)?); let name = aien_inference_abi::TensorBackend::name(&omega).to_string(); let tensor_backend: std::sync::Arc<dyn aien_inference_abi::TensorBackend> = std::sync::Arc::new(omega); @@ -1340,6 +1346,13 @@ fn build_native_daemon_backend() -> Result<DaemonBackendParts, String> { .to_string(), ) } else { + if let Some(budget) = cta_budget { + println!( + " Omega CTA budget: {}={} has no effect (CPU reference backend)", + aien_omega_gpu::CTA_BUDGET_ENV, + budget.get() + ); + } let tensor_backend: std::sync::Arc<dyn aien_inference_abi::TensorBackend> = std::sync::Arc::new(aien_inference_abi::ReferenceCpuBackend::new()); Ok(( @@ -1353,6 +1366,51 @@ fn build_native_daemon_backend() -> Result<DaemonBackendParts, String> { } } +/// The budget the daemon uses and where it came from: the explicit +/// `AIEN_OMEGA_CTA_BUDGET`, else the AIEN daemon default (256, sealed GB10 +/// evidence in `aien_omega_gpu::DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE`). Omega's +/// own library default (64) is never relied on by the daemon. +fn daemon_cta_budget( + budget: Option<aien_omega_gpu::CtaBudget>, +) -> (aien_omega_gpu::CtaBudget, String) { + let env = aien_omega_gpu::CTA_BUDGET_ENV; + match budget { + Some(b) => (b, format!("{env}={}", b.get())), + None => ( + aien_omega_gpu::DAEMON_DEFAULT_CTA_BUDGET, + format!( + "AIEN default, {env} unset; evidence {}; omega library default {} not used", + aien_omega_gpu::DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE, + aien_omega_gpu::ffi::OMEGA_GPU_MATMUL_MAX_CTAS + ), + ), + } +} + +/// Apply the daemon's CTA budget (always set explicitly at start) and return +/// the startup log line with the budget omega reports back +/// (`omega_gpu_matmul_cta_budget`). +fn apply_omega_cta_budget(budget: Option<aien_omega_gpu::CtaBudget>) -> Result<String, String> { + let (b, source) = daemon_cta_budget(budget); + aien_omega_gpu::set_cta_budget(b) + .map_err(|e| format!("Omega CTA budget {} ({source}): {e}", b.get()))?; + let active = aien_omega_gpu::cta_budget().ok_or_else(|| { + format!( + "Omega CTA budget {} ({source}): the Omega GPU engine is not linked (stub build)", + b.get() + ) + })?; + if active != b.get() { + return Err(format!( + "Omega CTA budget: set {} but omega reports {active}", + b.get() + )); + } + Ok(format!( + "Omega CTA budget: {active} CTAs per matmul launch ({source})" + )) +} + pub async fn run_daemon_server() { println!( "{}", @@ -1797,6 +1855,49 @@ pub async fn handle_aegis_command() { mod tests { use super::*; + /// 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. + #[test] + fn daemon_cta_budget_defaults_to_256_with_evidence() { + let (b, source) = daemon_cta_budget(None); + assert_eq!(b.get(), 256); + assert!(source.contains("AIEN default"), "{source}"); + assert!( + source.contains("docs/inference/evidence/t4fix-20261006T2254Z"), + "{source}" + ); + let explicit = aien_omega_gpu::parse_cta_budget(Some("64")) + .unwrap() + .unwrap(); + let (b, source) = daemon_cta_budget(Some(explicit)); + assert_eq!(b.get(), 64); + assert_eq!(source, "AIEN_OMEGA_CTA_BUDGET=64"); + } + + /// On the CPU stub the helper never claims a budget it could not set and + /// read back from omega, and names the value it tried. + #[test] + fn omega_cta_budget_helper_refuses_on_the_stub() { + if aien_omega_gpu::is_native() { + eprintln!( + "native build: stub refusal check skipped (chip calls not made in unit tests)" + ); + return; + } + let none = apply_omega_cta_budget(None).expect_err("stub cannot set the default"); + assert!( + none.contains("Omega CTA budget 256 (AIEN default"), + "{none}" + ); + assert!(none.contains("stub"), "{none}"); + let b = aien_omega_gpu::parse_cta_budget(Some("128")) + .unwrap() + .unwrap(); + let set = apply_omega_cta_budget(Some(b)).expect_err("stub cannot set a budget"); + assert!(set.contains("AIEN_OMEGA_CTA_BUDGET=128"), "{set}"); + } + #[tokio::test] async fn test_slash_command_adapter_suite() { // Test /adapter list diff --git a/crates/aien-omega-gpu/src/ffi.rs b/crates/aien-omega-gpu/src/ffi.rs index 7fcb0f86..2f781249 100644 --- a/crates/aien-omega-gpu/src/ffi.rs +++ b/crates/aien-omega-gpu/src/ffi.rs @@ -135,6 +135,10 @@ extern "C" { pub fn omega_gpu_matmul_last_error() -> *const c_char; pub fn omega_gpu_matmul_is_blocked() -> c_int; pub fn omega_gpu_device_close(); + // omega c0369e6 `src/omega_gpu_matmul_api.h:130-133`: CTA budget per launch + // (default OMEGA_GPU_MATMUL_MAX_CTAS; 0 restores it). Clears the kernel cache. + pub fn omega_gpu_matmul_set_cta_budget(ctas: u32); + pub fn omega_gpu_matmul_cta_budget() -> u32; } // ---- omega `src/omega_gpu_elementwise_api.h` (FB-1 cut 4, pinned 2636409) ---- diff --git a/crates/aien-omega-gpu/src/lib.rs b/crates/aien-omega-gpu/src/lib.rs index f621f1cc..78c59f2a 100644 --- a/crates/aien-omega-gpu/src/lib.rs +++ b/crates/aien-omega-gpu/src/lib.rs @@ -346,6 +346,89 @@ pub fn is_blocked() -> bool { false } +// ---- matmul launch budget (omega c0369e6 `omega_gpu_matmul_api.h:130-133`) ---- + +/// Daemon setting that picks the matmul CTA budget per launch. Unset or empty +/// means the AIEN daemon default ([`DAEMON_DEFAULT_CTA_BUDGET`], 256); omega's +/// own library default ([`ffi::OMEGA_GPU_MATMUL_MAX_CTAS`], 64) is not changed. +pub const CTA_BUDGET_ENV: &str = "AIEN_OMEGA_CTA_BUDGET"; + +/// Largest budget [`parse_cta_budget`] accepts. 64 (omega's default) and 256 are +/// the only budgets run on the GB10 (T4 measurement 2026-10-06 for the decode +/// shapes, t4fix verification for the prefill shapes; parity held at both); +/// 512 and 1024 were never chip-tested, so a larger value is refused. +pub const CTA_BUDGET_MAX_MEASURED: u32 = 256; + +/// A validated CTA budget (1..=[`CTA_BUDGET_MAX_MEASURED`]). Only +/// [`parse_cta_budget`] and [`DAEMON_DEFAULT_CTA_BUDGET`] build one, so +/// [`set_cta_budget`] never sees 0 (which omega reads as "restore the +/// default") or an unmeasured size. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct CtaBudget(u32); + +impl CtaBudget { + pub const fn get(self) -> u32 { + self.0 + } +} + +/// The AIEN daemon's budget when [`CTA_BUDGET_ENV`] is unset: 256. Sealed GB10 +/// evidence in [`DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE`]: decode 89.7 ms/token at +/// 256 vs 184.7 at 64, T4 S3 23 678 ms (< B = 29 000 ms), prefill shapes at 256 +/// parity ok (repeat_mismatch 0). +pub const DAEMON_DEFAULT_CTA_BUDGET: CtaBudget = CtaBudget(256); + +/// Repository path of the evidence behind [`DAEMON_DEFAULT_CTA_BUDGET`]. +pub const DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE: &str = "docs/inference/evidence/t4fix-20261006T2254Z"; + +/// Parse the [`CTA_BUDGET_ENV`] setting. `None` or blank: `Ok(None)` (the caller +/// picks its default). Otherwise a plain decimal integer in +/// 1..=[`CTA_BUDGET_MAX_MEASURED`]; anything else is an error naming the value. +pub fn parse_cta_budget(raw: Option<&str>) -> Result<Option<CtaBudget>, String> { + let Some(text) = raw.map(str::trim).filter(|t| !t.is_empty()) else { + return Ok(None); + }; + let refuse = |why: &str| { + Err(format!( + "{CTA_BUDGET_ENV}={text:?} refused: {why} (allowed 1..={CTA_BUDGET_MAX_MEASURED}; unset uses the AIEN daemon default {})", + DAEMON_DEFAULT_CTA_BUDGET.get() + )) + }; + if !text.bytes().all(|b| b.is_ascii_digit()) { + return refuse("not a plain decimal integer"); + } + match text.parse::<u32>() { + Ok(0) => refuse("0 would silently restore omega's default"), + Ok(v) if v <= CTA_BUDGET_MAX_MEASURED => Ok(Some(CtaBudget(v))), + Ok(_) | Err(_) => refuse("larger than any budget measured on the GB10"), + } +} + +/// Set omega's per-launch CTA budget. Omega clears its kernel cache (kernels +/// bake in the grid), so call it before the first matmul. Stub: `Unavailable`. +pub fn set_cta_budget(budget: CtaBudget) -> Result<(), OmegaGpuError> { + #[cfg(has_omega_gpu)] + { + // SAFETY: plain u32 argument; omega takes its session lock inside. + unsafe { ffi::omega_gpu_matmul_set_cta_budget(budget.0) }; + Ok(()) + } + #[cfg(not(has_omega_gpu))] + { + let _ = budget; + Err(OmegaGpuError::Unavailable) + } +} + +/// The CTA budget omega will use for the next launch; `None` in the stub. +pub fn cta_budget() -> Option<u32> { + #[cfg(has_omega_gpu)] + // SAFETY: no arguments; reads one u32 field, does not open the device. + return Some(unsafe { ffi::omega_gpu_matmul_cta_budget() }); + #[cfg(not(has_omega_gpu))] + None +} + // ---- native elementwise ops (omega FB-1 cut 4) ---- pub use ffi::OmegaGpuEwInfo; @@ -727,3 +810,76 @@ fn check_pool(pool: &[u8], layout: &OmegaGpuKvLayout) -> Result<(), OmegaGpuErro } Ok(()) } + +#[cfg(test)] +mod cta_budget_tests { + use super::*; + + #[test] + fn unset_or_blank_parses_to_none_caller_default() { + assert_eq!(parse_cta_budget(None), Ok(None)); + assert_eq!(parse_cta_budget(Some("")), Ok(None)); + assert_eq!(parse_cta_budget(Some(" ")), Ok(None)); + } + + #[test] + fn measured_budgets_parse() { + for (raw, v) in [("64", 64), ("256", 256), (" 256\n", 256), ("1", 1)] { + assert_eq!( + parse_cta_budget(Some(raw)).unwrap().map(CtaBudget::get), + Some(v) + ); + } + } + + #[test] + fn invalid_values_are_refused() { + for raw in [ + "0", + "-1", + "+64", + "abc", + "64.0", + "0x40", + "257", + "512", + "1024", + "99999999999", + ] { + let err = parse_cta_budget(Some(raw)).expect_err(raw); + assert!(err.contains(CTA_BUDGET_ENV), "{raw}: {err}"); + } + } + + #[test] + fn default_budget_is_omega_max_ctas() { + assert_eq!(ffi::OMEGA_GPU_MATMUL_MAX_CTAS, 64); + // Reading the budget never opens the device (omega_gpu_matmul_api.c:121). + if is_native() { + assert_eq!(cta_budget(), Some(ffi::OMEGA_GPU_MATMUL_MAX_CTAS)); + } else { + assert_eq!(cta_budget(), None); + let b = parse_cta_budget(Some("256")).unwrap().unwrap(); + assert_eq!(set_cta_budget(b), Err(OmegaGpuError::Unavailable)); + } + } + + #[test] + fn daemon_default_is_256_and_inside_the_measured_range() { + assert_eq!(DAEMON_DEFAULT_CTA_BUDGET.get(), 256); + assert!(DAEMON_DEFAULT_CTA_BUDGET.get() <= CTA_BUDGET_MAX_MEASURED); + // The same value as an explicit setting parses to the same budget. + assert_eq!( + parse_cta_budget(Some("256")), + Ok(Some(DAEMON_DEFAULT_CTA_BUDGET)) + ); + // Omega's own library default is untouched by the AIEN default. + assert_eq!(ffi::OMEGA_GPU_MATMUL_MAX_CTAS, 64); + assert!(DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE.starts_with("docs/inference/evidence/")); + let doc = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("../..") + .join(DAEMON_DEFAULT_CTA_BUDGET_EVIDENCE) + .join("FINDINGS.md"); + assert!(doc.is_file(), "evidence missing: {}", doc.display()); + } +} diff --git a/crates/aien-runtime/tests/warm_up_before_serving_test.rs b/crates/aien-runtime/tests/warm_up_before_serving_test.rs new file mode 100644 index 00000000..1a47af5e --- /dev/null +++ b/crates/aien-runtime/tests/warm_up_before_serving_test.rs @@ -0,0 +1,337 @@ +//! T4 fix cut, part (a): the declared warm-up (ACCEPTANCE-v4 Section 2(2), +//! `server.rs` `run_warm_up`) runs before the daemon serves anything, so the +//! skill budget B (started inside `propose_with_retries`, spine.rs) never pays +//! the first-use cost, and the warm-up does not change a later turn's tokens. +//! +//! 1. `warm_up_runs_before_a_waiting_request_is_served` (always runs, mock +//! backend): a client that connects while the warm-up is still running is +//! served only after the warm-up's step finished, and the warm-up prompt is +//! the first prefill the backend sees. +//! 2. `warm_up_does_not_change_the_served_reply` (always runs, mock backend): +//! the same turn gives the same reply with and without the warm-up. +//! 3. `cpu_reference_tokens_unchanged_by_warm_up` (real model, CPU reference +//! backend, only when `AIEN_LLAMA3_DIR` is set): the greedy tokens of the T4 +//! compose prompt are identical on a fresh runtime and on one that ran the +//! warm-up turn first (shared KV reuse after the warm-up leaks nothing). +use aien_inference_abi::{ + AienInferenceBackend, ChatTokenizer, DecodeOutput, MockInferenceBackend, ModelConfig, + SamplingParams, ScheduledBatch, StepMetrics, +}; +use aien_kv_cache::create_shared_kv_manager; +use aien_runtime::client::AienRuntimeClient; +use aien_runtime::server::AienRuntimeServer; +use aien_runtime::spine::AienRuntimeSpine; +use aien_runtime::{format_chat, ChatTurn, WARM_UP_TEXT}; +use aien_scheduler::SchedulerConfig; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +/// Simulated first-use cost (weight upload, kernel generation) paid by the +/// first step the backend runs. +const FIRST_STEP_COST: Duration = Duration::from_millis(600); + +/// Word-level tokenizer: the mock emits ids 100 and 101, decoded as x100/x101. +fn toy_tokenizer() -> ChatTokenizer { + let json = r#"{"version":"1.0","truncation":null,"padding":null,"added_tokens":[], + "normalizer":null,"pre_tokenizer":{"type":"Whitespace"},"post_processor":null, + "decoder":null,"model":{"type":"WordLevel","unk_token":"<unk>","vocab":{ + "<unk>":0,"<s>":1,"</s>":2,"Warm":3,"up":4,"turn":5,"hello":6,"x100":100,"x101":101}}}"#; + ChatTokenizer::from_bytes(json.as_bytes()).expect("toy tokenizer") +} + +#[derive(Debug, Clone)] +struct StepRecord { + prefill: Vec<(u64, usize)>, + decode: Vec<u64>, + started: Instant, + ended: Instant, +} + +/// The mock backend, recording every step; the first step costs FIRST_STEP_COST. +struct RecordingBackend { + inner: MockInferenceBackend, + log: Arc<Mutex<Vec<StepRecord>>>, +} + +#[async_trait::async_trait] +impl AienInferenceBackend for RecordingBackend { + async fn load_model(&mut self, config: &ModelConfig) -> Result<(), String> { + self.inner.load_model(config).await + } + + async fn execute_step( + &mut self, + batch: &ScheduledBatch, + ) -> Result<(Vec<DecodeOutput>, StepMetrics), String> { + let started = Instant::now(); + if self.log.lock().unwrap().is_empty() { + std::thread::sleep(FIRST_STEP_COST); + } + let out = self.inner.execute_step(batch).await; + self.log.lock().unwrap().push(StepRecord { + prefill: batch + .prefill_requests + .iter() + .map(|r| (r.request_id, r.prompt_tokens.len())) + .collect(), + decode: batch.decode_requests.clone(), + started, + ended: Instant::now(), + }); + out + } +} + +fn spine() -> AienRuntimeSpine { + // Small prefill chunks: the warm-up prompt spans several steps, so a + // request accepted during the warm-up would interleave with its chunks. + let cfg = SchedulerConfig { + max_batch_size: 8, + max_batch_tokens: 4096, + prefill_chunk_size: 8, + watermark_blocks: 4, + chunk_prefill: true, + max_prefill_tokens: 4096, + }; + AienRuntimeSpine::new(64, cfg, create_shared_kv_manager(1024, 16)) +} + +fn user(content: &str) -> Vec<ChatTurn> { + vec![ChatTurn { + role: "user".into(), + content: content.into(), + }] +} + +fn prompt_len(content: &str) -> usize { + let tok = toy_tokenizer(); + tok.encode(&format_chat(tok.template(), &user(content))) + .expect("encode") + .len() +} + +/// Start a server (warm-up on or off), send one turn as soon as the socket +/// exists, and return (reply, step log, instant the client connected). +async fn serve_one_turn(warm_up: bool, tag: &str) -> (String, Vec<StepRecord>, Instant) { + let tmp = tempfile::tempdir().unwrap(); + let socket = tmp.path().join(format!("{tag}.sock")); + let log = Arc::new(Mutex::new(Vec::new())); + let server = AienRuntimeServer::new(spine(), &socket); + server.set_tokenizer(toy_tokenizer()); + if warm_up { + server.enable_warm_up(); + } + let backend = RecordingBackend { + inner: MockInferenceBackend::new(1), + log: log.clone(), + }; + let handle = tokio::spawn(async move { server.run(backend).await }); + // The socket is bound before the warm-up runs; connect as soon as it exists. + let t_wait = Instant::now(); + while !socket.exists() { + assert!( + t_wait.elapsed() < Duration::from_secs(10), + "socket never bound" + ); + tokio::time::sleep(Duration::from_millis(2)).await; + } + let connected = Instant::now(); + let client = AienRuntimeClient::new(&socket); + let reply = client + .stream_turn(user("hello hello hello"), 4, 0.0) + .await + .expect("turn served"); + let _ = client.shutdown().await; + let _ = tokio::time::timeout(Duration::from_secs(5), handle).await; + let records = log.lock().unwrap().clone(); + (reply, records, connected) +} + +fn touches(r: &StepRecord, pred: impl Fn(u64) -> bool) -> bool { + r.prefill.iter().any(|&(id, _)| pred(id)) || r.decode.iter().any(|&id| pred(id)) +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn warm_up_runs_before_a_waiting_request_is_served() { + let (_reply, log, connected) = serve_one_turn(true, "warm").await; + let warm_len = prompt_len(WARM_UP_TEXT); + let turn_len = prompt_len("hello hello hello"); + assert!(warm_len > 8, "the warm-up must span several prefill chunks"); + + let first = log.first().expect("at least one step"); + assert_eq!( + first.prefill.len(), + 1, + "warm-up prefill runs alone: {first:?}" + ); + let warm_id = first.prefill[0].0; + let warm_steps: Vec<&StepRecord> = log + .iter() + .filter(|r| touches(r, |id| id == warm_id)) + .collect(); + let turn_steps: Vec<&StepRecord> = log + .iter() + .filter(|r| touches(r, |id| id != warm_id)) + .collect(); + let warm_prefilled: usize = warm_steps + .iter() + .flat_map(|r| { + r.prefill + .iter() + .filter(|&&(id, _)| id == warm_id) + .map(|&(_, n)| n) + }) + .sum(); + assert_eq!( + warm_prefilled, warm_len, + "the first sequence is the whole warm-up prompt" + ); + assert!( + warm_steps.len() > 1, + "warm-up spans several steps: {}", + warm_steps.len() + ); + let warm_end = warm_steps.last().unwrap().ended; + // Precondition: the client was already waiting while the warm-up ran. + assert!( + connected < warm_end, + "client connected after the warm-up ended; the test proves nothing" + ); + let turn_first = turn_steps + .first() + .expect("the client's turn reached the backend"); + assert!( + turn_first.started >= warm_end, + "the served turn reached the backend before the warm-up finished" + ); + let turn_prefilled: usize = turn_steps + .iter() + .flat_map(|r| { + r.prefill + .iter() + .filter(|&&(id, _)| id != warm_id) + .map(|&(_, n)| n) + }) + .sum(); + assert_eq!(turn_prefilled, turn_len, "turn prompt"); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn warm_up_does_not_change_the_served_reply() { + let (with_warm, log_w, _) = serve_one_turn(true, "with").await; + let (without, log_n, _) = serve_one_turn(false, "without").await; + assert_eq!(with_warm, without, "reply changed by the warm-up"); + assert!(!with_warm.is_empty()); + // With the warm-up, the first-use cost lands on a warm-up step; without + // it, the served turn's first step pays it (what the warm-up avoids). + let warm_id = log_w[0].prefill[0].0; + assert!(log_w[0].ended - log_w[0].started >= FIRST_STEP_COST); + let turn_w: Vec<&StepRecord> = log_w + .iter() + .filter(|r| touches(r, |id| id != warm_id)) + .collect(); + assert!(!turn_w.is_empty()); + assert!(turn_w.iter().all(|r| r.ended - r.started < FIRST_STEP_COST)); + assert!(log_n[0].ended - log_n[0].started >= FIRST_STEP_COST); +} + +/// One greedy turn on the daemon's path (as `examples/np1_reference.rs`). +async fn cpu_turn( + spine: &mut AienRuntimeSpine, + backend: &mut aien_inference_abi::NativeTransformerBackend, + ids: &[u32], + max_tokens: usize, + stop: &[u32], +) -> Vec<u32> { + use aien_scheduler::{ChannelCompletionSink, CompletionEvent}; + let (sink, mut ev) = ChannelCompletionSink::channel(); + let sid = spine.register_completion_sink(Arc::new(sink)); + let sampling = SamplingParams { + temperature: 0.0, + top_p: 0.95, + max_tokens, + stop_token_ids: stop.to_vec(), + }; + spine + .submit_work(Arc::from(ids), sampling, 2, Some(sid)) + .expect("submit"); + let mut out = Vec::new(); + loop { + if spine.scheduler.running_count() > 0 || spine.scheduler.waiting_count() > 0 { + spine.step(backend).await.expect("step"); + } + while let Ok(e) = ev.try_recv() { + match e { + CompletionEvent::Token { token, .. } => out.push(token), + CompletionEvent::Finished { .. } => return out, + CompletionEvent::Error { message, .. } => panic!("turn error: {message}"), + } + } + } +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn cpu_reference_tokens_unchanged_by_warm_up() { + let Ok(dir) = std::env::var("AIEN_LLAMA3_DIR") else { + eprintln!("AIEN_LLAMA3_DIR not set: CPU reference warm-up token check skipped"); + return; + }; + let dir = std::path::PathBuf::from(dir); + let tok = ChatTokenizer::from_model_dir(&dir, None).expect("tokenizer"); + let stop = tok.stop_token_ids().to_vec(); + let goal = "Create the file docs/GUIDE.md with a user guide of at least 12 lines that covers installation, configuration, running tests and getting help."; + let text = format!( + "{}{}", + format_chat( + tok.template(), + &user(&aien_runtime::spine::proposal_prompt(goal, "/tmp/ws")) + ), + aien_runtime::spine::COMPOSE_ASSISTANT_PREFIX + ); + let ids = tok.encode(&text).expect("encode"); + let warm = tok + .encode(&format_chat(tok.template(), &user(WARM_UP_TEXT))) + .expect("encode"); + const N: usize = 8; + + let mut runs = Vec::new(); + for with_warm_up in [false, true] { + let config = aien_inference_abi::load_model_config(&dir).expect("config.json"); + let weights = aien_inference_abi::TransformerWeights::load_from_safetensors(&dir, &config) + .expect("weights"); + let tb: Arc<dyn aien_inference_abi::TensorBackend> = + Arc::new(aien_inference_abi::ReferenceCpuBackend::new()); + // The daemon's scheduler config and KV sizing (aien-cli run_daemon_server). + let cfg = SchedulerConfig { + max_batch_size: 256, + max_batch_tokens: 16384, + max_prefill_tokens: 8192, + prefill_chunk_size: 128, + chunk_prefill: true, + watermark_blocks: 64, + }; + let sizing = aien_runtime::shared_kv::SharedKvSizing { + arena_capacity: 4096, + total_blocks: 8192, + }; + let (mut spine, mut backend) = + aien_runtime::shared_kv::build_shared_kv_runtime(weights, tb, cfg, sizing) + .expect("shared KV"); + if with_warm_up { + let w = cpu_turn(&mut spine, &mut backend, &warm, 1, &stop).await; + assert_eq!(w.len(), 1, "warm-up emits exactly one token"); + } + let t0 = Instant::now(); + let out = cpu_turn(&mut spine, &mut backend, &ids, N, &stop).await; + eprintln!( + "CPU reference turn (warm_up={with_warm_up}): {} prompt tokens, {} generated, {} ms, ids {:?}", + ids.len(), + out.len(), + t0.elapsed().as_millis(), + out + ); + runs.push(out); + } + assert!(!runs[0].is_empty()); + assert_eq!(runs[0], runs[1], "the warm-up changed the turn's tokens"); +} diff --git a/docs/inference/T4-DECODE-BUDGET.md b/docs/inference/T4-DECODE-BUDGET.md new file mode 100644 index 00000000..6c8afcd0 --- /dev/null +++ b/docs/inference/T4-DECODE-BUDGET.md @@ -0,0 +1,37 @@ +# T4 decode budget: measured result and optional follow-up (spec note, 2026-10-06) + +Evidence: t4-measure-20261006T2217Z (before) and `docs/inference/evidence/t4fix-20261006T2254Z/` (after, +sovereign-core 8c5294c, omega c0369e6, physics 6d7cf0d). Tags: [M] measured, [I] inferred, [C] read in code. + +What B covers [C]: `propose_with_retries` starts its clock at entry (`crates/aien-runtime/src/spine.rs:854`); +attempt 1 runs for what is left of B = 29 000 ms. The declared warm-up runs before the accept loop +(`crates/aien-runtime/src/server.rs:158-162`), so it is outside B. T4 needs 231 tokens = 1 from prefill ++ 230 decode steps (ACCEPTANCE-v6 Section 3.1): prefill + 230 x d < 29 000 ms, d < 117 ms at 2 075 ms prefill. + +Result, one T4 launch per budget, AIEN_STEP_LOG=1 [M] (FINDINGS.md there): +| | cta 64 (omega default) | cta 256 | +|---|---|---| +| warm-up (outside B) | 10 508 ms | 9 434 ms | +| T4 prefill | 2 102 ms | 1 660 ms | +| decode mean | 184.7 ms/token | 89.7 ms/token | +| S3 wall | 29 094 ms (timeout) | 23 678 ms, S4-S6 PASS, docs/GUIDE.md 24 lines | +Prefill shapes (106 rows) at 256: 100/100 calls each, repeat_mismatch 0, e2e bad 0/0 [M]. +The worker's estimate from m=1 matmul medians was 118 ms/token at 256 [I]; the measured 89.7 is faster, +reason UNKNOWN. Decision (orchestrator): the AIEN daemon default is 256 (`AIEN_OMEGA_CTA_BUDGET` unset); +omega's library default stays 64. Limits: one launch each; token identity 64 vs 256 not compared (64 timed +out); ACCEPTANCE-v7 row R1 (GB10 vs CPU reference ids) checks it. + +Margin at 256 [I]: 1 660 + 230 x 89.7 = 22 291 ms of backend time, about 6.7 s under B. + +Optional follow-up (no longer needed for T4; more margin, longer replies): +1. omega: single-row matmul (m = 1). Today m=1 pads to 16 rows (TILE_M 16, `omega_gpu_matmul_api.h:46`) + and every CTA is one warp (`threads_x = 32`, `omega_gpu_matmul_api.c:169`) walking column tiles of 8. + Wanted: a GEMV kernel with several warps per CTA and split-K (each warp reduces a K slice, then a CTA + reduction) for q/o, k/v, gate/up, down and logits; parity against the host oracle, repeat_mismatch 0. +2. physics: spin wait. `m16/m16_native.c:105` (physics 6d7cf0d) sleeps `usleep(50)` inside + `m16_native_wait_marker_ge` (line 98) on every marker poll; omega waits through it + (`src/omega_gpu_session.c:52`). About 113 matmul launches per token [I], each can overshoot by up to + one sleep (size UNKNOWN). Wanted: spin with `yield` for a bounded first window, then the sleep; timeout + unchanged. Measure the per-launch wait before and after. +Acceptance for either: a sealed GB10 T4 step log on the frozen path plus the parity receipt. +No change to B, A or max_tokens 256. diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/FINDINGS.md b/docs/inference/evidence/t4fix-20261006T2254Z/FINDINGS.md new file mode 100644 index 00000000..75606e2c --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/FINDINGS.md @@ -0,0 +1,21 @@ +# T4 fix verification on GB10, 2026-10-06 ~22:54-23:20Z (quietlock owner t4fix-verify) + +Build: sovereign-core sc#247 head 8c5294c (AIEN_OMEGA_CTA_BUDGET setting), omega c0369e6, physics 6d7cf0d, aienos lock b84c0a6; has_omega_gpu + has_omega_compose linked. Script: gb10-t4fix-verify.sh in this dir (P0 parity gate added by orchestrator review). + +## P0: prefill-sized shapes at cta 256 (never chip-run before) +106x2048x2048, 106x2048x512, 106x2048x8192, 106x8192x2048: ok_calls 100/100 each, e2e bad 0/0, repeat_mismatch 0 -> parity ok: true. Two rows are marked FAIL only by the test's median < 5 ms speed ceiling (medians 5.989 and 7.222 ms). + +## T4, one launch per budget, AIEN_STEP_LOG=1 +| | cta 64 (default) | cta 256 | +|---|---|---| +| warm-up (outside B) | 10 508 ms | 9 434 ms | +| T4 prefill | 2 102 ms | 1 660 ms | +| decode mean | 184.7 ms/token (148 steps) | 89.7 ms/token (244 steps) | +| S3 wall (skill, B = 29 000 ms) | 29 094 ms (timeout) | 23 678 ms | +| S4-S6 (commit/check) | FAIL | PASS | +| docs/GUIDE.md | not written | 24 lines, 936 bytes (goal: >= 12 lines) | + +## Limits +- One launch each; this is a measurement, not the frozen NP1 v7 run; rows not scored. +- Token identity between cta 64 and 256 not compared (64 timed out); v7 row R1 (GB10 vs CPU reference ids) will check it. UNVERIFIED until then. +- Faster than the worker's 118 ms estimate; why (beyond the matmul medians) UNKNOWN. diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.json b/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.json new file mode 100644 index 00000000..6fbf3ae5 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.json @@ -0,0 +1 @@ +{"schema":"OMEGA_GPU_MATMUL_API_TIMING_V1","cta_budget":256,"calls":100,"shapes":[{"m":106,"k":2048,"n":2048,"pass":true,"upload_ms":159.345,"ok_calls":100,"median_ms":3.2790,"p90_ms":4.8463,"min_ms":1.5135,"max_ms":6.0345,"chip_ns_mean":3247062,"grid_x":36,"grid_y":7,"e2e_first":3.19949e-07,"e2e_last":3.19949e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0},{"m":106,"k":2048,"n":512,"pass":true,"upload_ms":6.060,"ok_calls":100,"median_ms":0.8651,"p90_ms":0.9764,"min_ms":0.8149,"max_ms":1.1659,"chip_ns_mean":871729,"grid_x":36,"grid_y":7,"e2e_first":2.87371e-07,"e2e_last":2.87371e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0},{"m":106,"k":2048,"n":8192,"pass":false,"upload_ms":99.355,"ok_calls":100,"median_ms":5.9892,"p90_ms":14.0382,"min_ms":5.0485,"max_ms":15.3386,"chip_ns_mean":7632663,"grid_x":36,"grid_y":7,"e2e_first":3.21233e-07,"e2e_last":3.21233e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0},{"m":106,"k":8192,"n":2048,"pass":false,"upload_ms":98.099,"ok_calls":100,"median_ms":7.2220,"p90_ms":19.0370,"min_ms":5.0721,"max_ms":22.1280,"chip_ns_mean":8868430,"grid_x":36,"grid_y":7,"e2e_first":6.09668e-07,"e2e_last":6.09668e-07,"e2e_bad_first":0,"e2e_bad_last":0,"repeat_mismatch":0}],"blocked":false,"checks":8,"failed":2,"verdict":"OMEGA_GPU_MATMUL_TIMING_FAIL"} diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.log b/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.log new file mode 100644 index 00000000..0b078848 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/P0-cta256.log @@ -0,0 +1,7 @@ +PASS timing 106x2048x2048 upload_ms=159.3 ok_calls=100 median_ms=3.279 p90_ms=4.846 min_ms=1.514 max_ms=6.035 chip_ns_mean=3247062 grid=36x7 e2e_first=3.19949e-07 e2e_last=3.19949e-07 repeat_mismatch=0 +PASS timing 106x2048x512 upload_ms=6.1 ok_calls=100 median_ms=0.865 p90_ms=0.976 min_ms=0.815 max_ms=1.166 chip_ns_mean=871729 grid=36x7 e2e_first=2.87371e-07 e2e_last=2.87371e-07 repeat_mismatch=0 +FAIL: timing 106x2048x8192 ok_calls=100 median_ms=5.989 e2e_first=3.21233e-07 e2e_last=3.21233e-07 bad=0/0 repeat_mismatch=0 +FAIL timing 106x2048x8192 upload_ms=99.4 ok_calls=100 median_ms=5.989 p90_ms=14.038 min_ms=5.048 max_ms=15.339 chip_ns_mean=7632663 grid=36x7 e2e_first=3.21233e-07 e2e_last=3.21233e-07 repeat_mismatch=0 +FAIL: timing 106x8192x2048 ok_calls=100 median_ms=7.222 e2e_first=6.09668e-07 e2e_last=6.09668e-07 bad=0/0 repeat_mismatch=0 +FAIL timing 106x8192x2048 upload_ms=98.1 ok_calls=100 median_ms=7.222 p90_ms=19.037 min_ms=5.072 max_ms=22.128 chip_ns_mean=8868430 grid=36x7 e2e_first=6.09668e-07 e2e_last=6.09668e-07 repeat_mismatch=0 +FAIL: 8 checks, 2 failed diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/SHA256SUMS b/docs/inference/evidence/t4fix-20261006T2254Z/SHA256SUMS new file mode 100644 index 00000000..32949bba --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/SHA256SUMS @@ -0,0 +1,9 @@ +5965da5ecddb3b9ef46b91c68511c61e571228ae746714bac31b0d0a6f2d2253 FINDINGS.md +2953351036feff118e115efa0da2f0b66c12a867c2f52096b6ea53f2fb3faed3 gb10-t4fix-verify.sh +ce2328703f4cd801a2d9c2bc6bb9155bdac60af8e3e057416ec9dacbf258081e P0-cta256.json +f120515e4b928c211144196bf4e33cb5284e978ec0712677a185fc823d3f2c16 P0-cta256.log +18111a0767c46389407df4cc2ba4f78ccc4ef60ad0b7ba6831d6ad5c530ad4fd run.out +352aa2888149bcee7eff1e96ad2b5f31e02781e848905c8edfd503551c4bad41 T4-cta256.driver.out +da7d494b83a35f87b59eaa5116a21d521dac88c885d861824e75bc1af1b2b7cf T4-cta256.run.json +dc685dae97159d98f211278a2d728d152ab104c70001b9ab0a977c665ff5d42f T4-cta64.driver.out +dbeaf7102d455081139cdb77df7eed7d6be034256386e678d3462e4d1884d0a4 T4-cta64.run.json diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.driver.out b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.driver.out new file mode 100644 index 00000000..aa93bb54 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.driver.out @@ -0,0 +1,8 @@ +{"step":"S1","ok":true,"wall_ms":28} +{"step":"S2","ok":true,"wall_ms":18} +{"step":"S3","ok":true,"wall_ms":23678} +{"step":"S4","ok":true,"wall_ms":15} +{"step":"S5","ok":true,"wall_ms":25} +{"step":"S6","ok":true,"wall_ms":7} +{"step":"S7","ok":true,"wall_ms":29161} +{"step":"S8","ok":true,"wall_ms":10} diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.run.json b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.run.json new file mode 100644 index 00000000..0630c11f --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta256.run.json @@ -0,0 +1,139 @@ +{ + "root": "/home/drakestapleton/workspace/evidence-out/t4fix-20261006T2254Z/T4-cta256", + "uname": "Linux 7.0.0-1019-nvidia aarch64", + "goal": "Create the file docs/GUIDE.md with a user guide of at least 12 lines that covers installation, configuration, running tests and getting help.", + "constraint_text": "Project constraints: every change stays inside the authorized workspace; one file per change; plain text only; no network.", + "steps": [ + { + "step": "S1", + "name": "remember", + "rc": 0, + "wall_ms": 28, + "boottime_ms": 30, + "ok": true + }, + { + "step": "S2", + "name": "inspect", + "rc": 0, + "wall_ms": 18, + "boottime_ms": 10, + "ok": true + }, + { + "step": "S3", + "name": "propose", + "rc": 0, + "wall_ms": 23678, + "boottime_ms": 23680, + "ok": true + }, + { + "step": "S4", + "name": "authorize", + "rc": 0, + "wall_ms": 15, + "boottime_ms": 10, + "ok": true + }, + { + "step": "S5", + "name": "execute", + "rc": 0, + "wall_ms": 25, + "boottime_ms": 20, + "ok": true + }, + { + "step": "S6", + "name": "explain", + "rc": 0, + "wall_ms": 7, + "boottime_ms": 10, + "ok": true + }, + { + "step": "S7", + "name": "restart", + "rc": 0, + "wall_ms": 29161, + "boottime_ms": 29170, + "ok": true, + "old_pid": 1905946, + "old_process": "exited", + "new_pid": 1909605 + }, + { + "step": "S8", + "name": "recall", + "rc": 0, + "wall_ms": 10, + "boottime_ms": 10, + "ok": true + } + ], + "daemon": [ + { + "pid": 1905946, + "backend": "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)", + "model": " Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b)", + "vmhwm_kb": 17387536, + "warm_up_ms": 9471 + }, + { + "pid": 1909605, + "backend": "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)", + "model": " Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b)", + "vmhwm_kb": 17387212, + "warm_up_ms": 9368 + } + ], + "cited": [ + 8, + 13, + 14, + 15, + 16, + 6, + 7, + 18, + 20 + ], + "prefix_records": 20, + "containment": { + "workspace_before": "9e8bd69d192384aff4eb3efb39cd813f42ee362a301dc2f58e726a7d7941a789", + "workspace_after": "2497da7192c2d6818a54c254236e000734467479bd312000d298ddc7404e8908", + "workspace_changed": [ + "docs/GUIDE.md" + ], + "outside_sentinel_before": "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134", + "outside_sentinel_after": "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134", + "outside_new_files": [ + "./compose.cortex-mark" + ], + "daemon_state_files": [ + "./state/processed_operations.json" + ], + "cortex_mark": { + "present": true, + "size": 128, + "magic_hex": "4149454e43584d31", + "head96_sha256": "7fc8c7c08af26e3b2b5655fa160d11cab438276078e2fb8286d9807d23ea5f03", + "tail_hex": "7fc8c7c08af26e3b2b5655fa160d11cab438276078e2fb8286d9807d23ea5f03", + "sha256": "b8d3bdedf213b37428209853483b1d6021ec10a75bfd7ed2437a0d3e8e9f5d59", + "machine_id_hex": "3070d56e11dba291e5207f497fe5fe941531a0d80dd1895121554a6330b9e0c4", + "compose_machine_id_file_hex": "414d4944010100003070d56e11dba291e5207f497fe5fe941531a0d80dd1895121554a6330b9e0c4df6fe6d6" + } + }, + "compose_dir_files": [ + "./cortex.cx", + "./jspace", + "./jspace/jspace.data", + "./jspace/jspace.meta", + "./machine.id" + ], + "machine_id_file_sha256": [ + "ba5e3612323bc292e5207656a8c28c289b573e04b98f53c0696f7c63576173a1", + "ba5e3612323bc292e5207656a8c28c289b573e04b98f53c0696f7c63576173a1" + ] +} diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.driver.out b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.driver.out new file mode 100644 index 00000000..e6f5e647 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.driver.out @@ -0,0 +1,8 @@ +{"step":"S1","ok":true,"wall_ms":15} +{"step":"S2","ok":true,"wall_ms":19} +{"step":"S3","ok":true,"wall_ms":29094} +{"step":"S4","ok":false,"wall_ms":6} +{"step":"S5","ok":false,"wall_ms":9} +{"step":"S6","ok":false,"wall_ms":9} +{"step":"S7","ok":true,"wall_ms":30258} +{"step":"S8","ok":true,"wall_ms":10} diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.run.json b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.run.json new file mode 100644 index 00000000..d214dde1 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/T4-cta64.run.json @@ -0,0 +1,127 @@ +{ + "root": "/home/drakestapleton/workspace/evidence-out/t4fix-20261006T2254Z/T4-cta64", + "uname": "Linux 7.0.0-1019-nvidia aarch64", + "goal": "Create the file docs/GUIDE.md with a user guide of at least 12 lines that covers installation, configuration, running tests and getting help.", + "constraint_text": "Project constraints: every change stays inside the authorized workspace; one file per change; plain text only; no network.", + "steps": [ + { + "step": "S1", + "name": "remember", + "rc": 0, + "wall_ms": 15, + "boottime_ms": 10, + "ok": true + }, + { + "step": "S2", + "name": "inspect", + "rc": 0, + "wall_ms": 19, + "boottime_ms": 20, + "ok": true + }, + { + "step": "S3", + "name": "propose", + "rc": 0, + "wall_ms": 29094, + "boottime_ms": 29090, + "ok": true + }, + { + "step": "S4", + "name": "authorize", + "rc": 1, + "wall_ms": 6, + "boottime_ms": 10, + "ok": false + }, + { + "step": "S5", + "name": "execute", + "rc": 1, + "wall_ms": 9, + "boottime_ms": 0, + "ok": false + }, + { + "step": "S6", + "name": "explain", + "rc": 1, + "wall_ms": 9, + "boottime_ms": 10, + "ok": false + }, + { + "step": "S7", + "name": "restart", + "rc": 0, + "wall_ms": 30258, + "boottime_ms": 30260, + "ok": true, + "old_pid": 1900190, + "old_process": "exited", + "new_pid": 1903969 + }, + { + "step": "S8", + "name": "recall", + "rc": 0, + "wall_ms": 10, + "boottime_ms": 10, + "ok": true + } + ], + "daemon": [ + { + "pid": 1900190, + "backend": "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)", + "model": " Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b)", + "vmhwm_kb": 17387140, + "warm_up_ms": 10539 + }, + { + "pid": 1903969, + "backend": "NativeTransformerBackend/OmegaGb10Backend (native Omega engine, no CUDA, NVIDIA GB10 sm_121)", + "model": " Model: checkpoint loaded from /home/drakestapleton/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c/model.safetensors (tokenizer loaded, model_id=5a8abab4a5d6f164389b1079fb721cfab8d7126c, config=unsloth/Llama-3.2-1B-Instruct (config.json), model_sha256=1ff795ff6a07e6a68085d206fb84417da2f083f68391c2843cd2b8ac6df8538f, tokenizer_sha256=6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b)", + "vmhwm_kb": 17387336, + "warm_up_ms": 9883 + } + ], + "cited": [], + "prefix_records": 0, + "containment": { + "workspace_before": "9e8bd69d192384aff4eb3efb39cd813f42ee362a301dc2f58e726a7d7941a789", + "workspace_after": "9e8bd69d192384aff4eb3efb39cd813f42ee362a301dc2f58e726a7d7941a789", + "workspace_changed": [], + "outside_sentinel_before": "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134", + "outside_sentinel_after": "59a0ab4a64268e5066c04ab3a6bfa111b8336fe3c861c8452aff459564bc2134", + "outside_new_files": [ + "./compose.cortex-mark" + ], + "daemon_state_files": [ + "./state/processed_operations.json" + ], + "cortex_mark": { + "present": true, + "size": 128, + "magic_hex": "4149454e43584d31", + "head96_sha256": "6a869cbc977b607066001740bd167209a2b86b27a7e38f8302bf3420717d3641", + "tail_hex": "6a869cbc977b607066001740bd167209a2b86b27a7e38f8302bf3420717d3641", + "sha256": "4414143ba871beda78876d309e5fee3e830af93c4d1b63847935909c92c6c020", + "machine_id_hex": "284829bfac060ba1631624260401dafcc1a28a118d766c0e7960d2c050623f72", + "compose_machine_id_file_hex": "414d494401010000284829bfac060ba1631624260401dafcc1a28a118d766c0e7960d2c050623f72a985bfad" + } + }, + "compose_dir_files": [ + "./cortex.cx", + "./jspace", + "./jspace/jspace.data", + "./jspace/jspace.meta", + "./machine.id" + ], + "machine_id_file_sha256": [ + "9a9860adeca04ed54c16198cebbcedb594e661832fe84e412d897446ebe9296c", + "9a9860adeca04ed54c16198cebbcedb594e661832fe84e412d897446ebe9296c" + ] +} diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/gb10-t4fix-verify.sh b/docs/inference/evidence/t4fix-20261006T2254Z/gb10-t4fix-verify.sh new file mode 100755 index 00000000..b19bb334 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/gb10-t4fix-verify.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# GB10 verification for sovereign-core PR "T4 launch budget" (branch inference/t4-warmup-and-cta-budget). +# build: CPU only, outside the hold. run OUT: inside ONE quietlock hold (orchestrator owns it), ~3 min. +# Baseline first (budget 64 = unset), then one variable (AIEN_OMEGA_CTA_BUDGET=256). Same binary, same T4 goal. +set -u +SC=$HOME/.claude/jobs/665fb972/tmp/t4fix/sc # this PR's head +OMEGA=$HOME/.claude/jobs/665fb972/tmp/t4/om # clean omega c0369e6 (= omega.lock) +PHYS=$HOME/workspace/hive-worktrees/physics-6d7cf0d # physics 6d7cf0d +MODEL=$HOME/.cache/huggingface/hub/models--unsloth--Llama-3.2-1B-Instruct/snapshots/5a8abab4a5d6f164389b1079fb721cfab8d7126c +case "${1:?build|run}" in +build) + [ "$(git -C "$OMEGA" rev-parse HEAD)" = "$(cat "$SC/omega.lock")" ] || { echo "omega HEAD != omega.lock"; exit 1; } + (cd "$SC" && AIEN_OMEGA_DIR="$OMEGA" AIEN_OMEGA_COMPOSE_DIR="$OMEGA" AIEN_PHYSICS_DIR="$PHYS" \ + AIEN_AIENOS_LOCK_REPO="${AIEN_AIENOS_LOCK_REPO:?set to the aienos b84c0a6 checkout}" \ + cargo build --release -p aien-cli -vv 2>&1 | grep -E "has_omega_gpu|has_omega_compose|static=rx_compose|stub" | sort -u) + ;; +run) + OUT=${2:?OUT dir}; mkdir -p "$OUT" + GOAL="$(jq -r '.tasks[]|select(.id=="T4").goal' "$SC/docs/campaigns/next-phase-1/tasks-v6.json")" + # Phase 0 (orchestrator review): prefill-sized shapes at cta 256 never ran on the chip; parity gate before T4 at 256. + P0="106,2048,2048;106,2048,512;106,2048,8192;106,8192,2048" + OMEGA_GPU_MATMUL_SHAPES="$P0" "$OMEGA/build/gpu_matmul_api_test" --timing --cta-budget 256 --out "$OUT/P0-cta256.json" >"$OUT/P0-cta256.log" 2>&1; echo "P0 cta=256 exit $?" + grep -h "timing 106x" "$OUT/P0-cta256.log" + P0OK=$(jq -r "[.shapes[] | (.ok_calls == 100 and .e2e_bad_first == 0 and .e2e_bad_last == 0 and .repeat_mismatch == 0)] | all" "$OUT/P0-cta256.json" 2>/dev/null) + echo "P0 parity ok: $P0OK" + BUDGETS=64; [ "$P0OK" = true ] && BUDGETS="64 256" + for b in $BUDGETS; do + if [ $b = 64 ]; then unset AIEN_OMEGA_CTA_BUDGET; else export AIEN_OMEGA_CTA_BUDGET=$b; fi + AIEN_BIN="$SC/target/release/aien-cli" AIEN_MODEL_PATH="$MODEL/model.safetensors" \ + AIEN_TOKENIZER_PATH="$MODEL/tokenizer.json" AIEN_REQUIRE_BLACKWELL=1 AIEN_STEP_LOG=1 \ + AIEN_COMPOSE_MAX_TOKENS=256 NP1_GOAL="$GOAL" \ + bash "$SC/docs/campaigns/next-phase-1/run-campaign.sh" "$OUT/T4-cta$b" >"$OUT/T4-cta$b.driver.out" 2>&1 + echo "T4 cta=$b driver exit $?" + L="$OUT/T4-cta$b/daemon-1.log" + grep -h "Omega CTA budget\|Warm-up:" "$L" + jq -c '.. | objects | select(.step? == "S3") | {S3_wall_ms: .wall_ms}' "$OUT/T4-cta$b/run.json" 2>/dev/null | head -1 + # step 1 = warm-up (outside B); steps 2.. = the T4 attempt (inside B) + grep -h "^step:" "$L" | awk -F'backend_us=' '{split($2,a," "); n++; us=a[1]; + if(n==1) w=us; else if(n==2) p=us; else {d+=us; k++}} + END {printf "warmup_ms=%.0f t4_prefill_ms=%.0f decode_steps=%d decode_ms_mean=%.1f logged_t4_backend_ms=%.0f (can include steps after a timeout)\n", w/1e3, p/1e3, k, (k?d/k/1e3:0), (p+d)/1e3}' + done + unset AIEN_OMEGA_CTA_BUDGET + ;; +esac diff --git a/docs/inference/evidence/t4fix-20261006T2254Z/run.out b/docs/inference/evidence/t4fix-20261006T2254Z/run.out new file mode 100644 index 00000000..5e3cf954 --- /dev/null +++ b/docs/inference/evidence/t4fix-20261006T2254Z/run.out @@ -0,0 +1,18 @@ +P0 cta=256 exit 1 +PASS timing 106x2048x2048 upload_ms=159.3 ok_calls=100 median_ms=3.279 p90_ms=4.846 min_ms=1.514 max_ms=6.035 chip_ns_mean=3247062 grid=36x7 e2e_first=3.19949e-07 e2e_last=3.19949e-07 repeat_mismatch=0 +PASS timing 106x2048x512 upload_ms=6.1 ok_calls=100 median_ms=0.865 p90_ms=0.976 min_ms=0.815 max_ms=1.166 chip_ns_mean=871729 grid=36x7 e2e_first=2.87371e-07 e2e_last=2.87371e-07 repeat_mismatch=0 +FAIL: timing 106x2048x8192 ok_calls=100 median_ms=5.989 e2e_first=3.21233e-07 e2e_last=3.21233e-07 bad=0/0 repeat_mismatch=0 +FAIL timing 106x2048x8192 upload_ms=99.4 ok_calls=100 median_ms=5.989 p90_ms=14.038 min_ms=5.048 max_ms=15.339 chip_ns_mean=7632663 grid=36x7 e2e_first=3.21233e-07 e2e_last=3.21233e-07 repeat_mismatch=0 +FAIL: timing 106x8192x2048 ok_calls=100 median_ms=7.222 e2e_first=6.09668e-07 e2e_last=6.09668e-07 bad=0/0 repeat_mismatch=0 +FAIL timing 106x8192x2048 upload_ms=98.1 ok_calls=100 median_ms=7.222 p90_ms=19.037 min_ms=5.072 max_ms=22.128 chip_ns_mean=8868430 grid=36x7 e2e_first=6.09668e-07 e2e_last=6.09668e-07 repeat_mismatch=0 +P0 parity ok: true +T4 cta=64 driver exit 0 + Omega CTA budget: 64 CTAs per matmul launch (omega default, AIEN_OMEGA_CTA_BUDGET unset) + Warm-up: 1 token in 10539 ms over 124 prompt tokens (discarded) +{"S3_wall_ms":29094} +warmup_ms=10508 t4_prefill_ms=2102 decode_steps=148 decode_ms_mean=184.7 logged_t4_backend_ms=29432 (can include steps after a timeout) +T4 cta=256 driver exit 0 + Omega CTA budget: 256 CTAs per matmul launch (AIEN_OMEGA_CTA_BUDGET=256) + Warm-up: 1 token in 9471 ms over 124 prompt tokens (discarded) +{"S3_wall_ms":23678} +warmup_ms=9434 t4_prefill_ms=1660 decode_steps=244 decode_ms_mean=89.7 logged_t4_backend_ms=23557 (can include steps after a timeout)