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#405 (code only)
Apply it
git checkout -b patch-5103a037b5091210 de9c626ad9fd50652c1f767d273b4d63f118e342 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/5103a037b5091210.patch | git am
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
405
df8bae867b413fadd4dacc8352d614da512be9b5
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":405,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/405","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:37:05Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index 2205e5e2..9a4f4ef2 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:e5ff31069bcf711289819b6c09c3c96378cb1367e38f236992f113ca6a2dac23", - "compiled_at": "2026-10-10T17:04:40Z", + "compiled_at": "2026-10-11T01:03:21Z", "compiler": "crumb-compile/1", - "digest": "sha256:e097fde04915a02bd1dc024b33bd001f2af475f527fac582bf05f06c008d0a31", + "digest": "sha256:539c472e85d3e626de204df4e2db2bb9cccb14e7e6e5a9ee01af6203acc9e087", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", "files": 2396, - "generated_at_commit": "b27c73a512430ce23f512cb18fe7ef08a9b1a315", - "source_tree": "sha256:24c4bdbd170c67887034e1d7bd85f586bbb2347627de8dfe0b9e28ee0c412e92" + "generated_at_commit": "c51856dc2d58d383173f2ba01e34244c14acab2a", + "source_tree": "sha256:e7ade309ddd57368f17a403edce16501e82ab2fc3d8f9773efddd3ec8b622bde" } }, "history": [], diff --git a/crates/aien-abi-core/src/lib.rs b/crates/aien-abi-core/src/lib.rs index 837d63aa..26d3855f 100644 --- a/crates/aien-abi-core/src/lib.rs +++ b/crates/aien-abi-core/src/lib.rs @@ -515,6 +515,12 @@ pub struct OpEvidence { /// The full `OP_REPORT native=[..] reference=[..] native_fallbacks=[..] /// reference_runs=[..]` line. pub report: String, + /// Operations the backend ran on its chip, as a process total (sc#402: the + /// Omega GB10 engine's `chip_calls`). ABSENT, not zero, for a backend that + /// has no chip or does not count its chip calls; serialized only when present, + /// so records of such backends are unchanged. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub gpu_executions: Option<u64>, } impl DecodeObservation { diff --git a/crates/aien-inference-abi/src/backend.rs b/crates/aien-inference-abi/src/backend.rs index 3bb02024..472d1e9e 100644 --- a/crates/aien-inference-abi/src/backend.rs +++ b/crates/aien-inference-abi/src/backend.rs @@ -156,6 +156,13 @@ pub trait TensorBackend: Send + Sync { crate::native_ops::OpReport::all_native() } + /// Operations this backend has run on its chip so far (process total), for + /// receipts (sc#402). Default: None, for a backend with no chip or that does + /// not count chip calls: an absent claim, never zero. + fn gpu_executions(&self) -> Option<u64> { + None + } + /// In-place Root Mean Square Normalization: /// out[i] = x[i] * weight[i] / sqrt(mean(x^2) + eps) fn rmsnorm(&self, out: &mut [f32], x: &[f32], weight: &[f32], eps: f32); diff --git a/crates/aien-inference-abi/src/native_ops.rs b/crates/aien-inference-abi/src/native_ops.rs index ace3d286..8238fd22 100644 --- a/crates/aien-inference-abi/src/native_ops.rs +++ b/crates/aien-inference-abi/src/native_ops.rs @@ -135,6 +135,7 @@ impl OpReport { native_fallbacks: total(&self.native_fallbacks), reference_runs: total(&self.reference_runs), report: self.line(), + gpu_executions: None, } } diff --git a/crates/aien-inference-abi/src/omega_backend.rs b/crates/aien-inference-abi/src/omega_backend.rs index cc0f23fb..ec495989 100644 --- a/crates/aien-inference-abi/src/omega_backend.rs +++ b/crates/aien-inference-abi/src/omega_backend.rs @@ -699,6 +699,12 @@ impl TensorBackend for OmegaGb10Backend { self.acct.report() } + /// sc#402: the chip calls so far, only when the real engine is linked (the stub has + /// no chip, so it makes no claim). + fn gpu_executions(&self) -> Option<u64> { + self.is_available().then(|| self.chip_calls()) + } + fn rmsnorm(&self, out: &mut [f32], x: &[f32], weight: &[f32], eps: f32) { if !self.chip_rmsnorm(out, x, weight, eps) { self.reference_for(TensorOp::Rmsnorm); @@ -1408,6 +1414,19 @@ mod tests { assert!(Arc::ptr_eq(&t, &b.rope_table(head_dim, theta, pos))); } + /// sc#402: the chip-call total is reported only when the real engine is linked; the + /// stub has no chip and makes no claim (None, never a zero that reads as "ran, no calls"). + #[test] + fn gpu_executions_is_the_chip_call_total_or_absent() { + let b = OmegaGb10Backend::new(); + let got = TensorBackend::gpu_executions(&b); + if b.is_available() { + assert_eq!(got, Some(b.chip_calls())); + } else { + assert_eq!(got, None); + } + } + /// Stub build only: each newly native elementwise op is a counted fallback with the /// reference result when the chip is unavailable, never silent. #[test] diff --git a/crates/aien-inference-abi/src/transformer_backend.rs b/crates/aien-inference-abi/src/transformer_backend.rs index 1d8de911..702aa7e2 100644 --- a/crates/aien-inference-abi/src/transformer_backend.rs +++ b/crates/aien-inference-abi/src/transformer_backend.rs @@ -1881,11 +1881,12 @@ impl AienInferenceBackend for NativeTransformerBackend { /// sc#337: the tensor backend's name and op counters so far. fn op_evidence(&self) -> Option<crate::OpEvidence> { - Some( - self.tensor_backend - .op_report() - .evidence(self.tensor_backend.name()), - ) + let mut e = self + .tensor_backend + .op_report() + .evidence(self.tensor_backend.name()); + e.gpu_executions = self.tensor_backend.gpu_executions(); // sc#402 + Some(e) } async fn execute_step( diff --git a/crates/aien-runtime/src/generation.rs b/crates/aien-runtime/src/generation.rs index 50b9a639..db09e2fa 100644 --- a/crates/aien-runtime/src/generation.rs +++ b/crates/aien-runtime/src/generation.rs @@ -112,13 +112,20 @@ fn with_ops(record: &mut Value, o: Option<&aien_abi_core::OpEvidence>) { "scope": "process", "report": o.report, }); + if let Some(n) = o.gpu_executions { + record["ops"]["gpu_executions"] = json!(n); // sc#402, process total like the rest + } } /// The line the daemon logs at the end of every model call (sc#337): the -/// backend's `OP_REPORT ...` line with ` backend=<name>` appended. None when -/// the backend does not account its ops. +/// backend's `OP_REPORT ...` line with ` backend=<name>` appended (and, before +/// it, ` gpu_executions=<n>` when the backend counts chip calls, sc#402). None +/// when the backend does not account its ops. pub fn op_report_line(o: Option<&aien_abi_core::OpEvidence>) -> Option<String> { - o.map(|o| format!("{} backend={}", o.report, o.backend)) + o.map(|o| match o.gpu_executions { + Some(n) => format!("{} gpu_executions={n} backend={}", o.report, o.backend), + None => format!("{} backend={}", o.report, o.backend), + }) } /// The record's JSON body (field list is documented in docs/DAEMON_GENERATION_RECORD.md). diff --git a/crates/aien-runtime/tests/ops_evidence_test.rs b/crates/aien-runtime/tests/ops_evidence_test.rs index 656f5d72..f0aa24ae 100644 --- a/crates/aien-runtime/tests/ops_evidence_test.rs +++ b/crates/aien-runtime/tests/ops_evidence_test.rs @@ -105,6 +105,9 @@ fn native_with( struct ForcedFallback { cpu: ReferenceCpuBackend, acct: OpAccounting, + /// sc#402: when Some, every `matmul_vec` counts as one chip call, the way the + /// Omega GB10 backend counts `chip_calls`; None is a backend with no chip. + chip_calls: Option<std::sync::atomic::AtomicU64>, } impl TensorBackend for ForcedFallback { @@ -114,6 +117,11 @@ impl TensorBackend for ForcedFallback { fn op_report(&self) -> aien_inference_abi::native_ops::OpReport { self.acct.report() } + fn gpu_executions(&self) -> Option<u64> { + self.chip_calls + .as_ref() + .map(|c| c.load(std::sync::atomic::Ordering::Relaxed)) + } fn rmsnorm(&self, out: &mut [f32], x: &[f32], weight: &[f32], eps: f32) { self.acct.record_reference(TensorOp::Rmsnorm); self.cpu.rmsnorm(out, x, weight, eps) @@ -143,6 +151,9 @@ impl TensorBackend for ForcedFallback { out_dim: usize, in_dim: usize, ) { + if let Some(c) = &self.chip_calls { + c.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + } self.cpu.matmul_vec(out, x, weight, out_dim, in_dim) } fn swiglu(&self, out: &mut [f32], gate: &[f32], up: &[f32]) { @@ -202,6 +213,7 @@ async fn a_forced_fallback_shows_a_non_zero_count() { let tensors = Arc::new(ForcedFallback { cpu: ReferenceCpuBackend::new(), acct: OpAccounting::new(NativeOpMask::ALL), + chip_calls: None, }); let ops = run(native_with(tensors)) .await @@ -242,6 +254,7 @@ fn record_field_matches_the_evidence_and_is_absent_without_it() { native_fallbacks: 0, reference_runs: 7, report: "OP_REPORT native=[matmul_vec] reference=[rmsnorm] native_fallbacks=[] reference_runs=[rmsnorm:7]".into(), + gpu_executions: None, }; let ev = |o| aien_runtime::generation::TurnEvidence { prompt_ids: &[1, 2], @@ -269,3 +282,76 @@ fn record_field_matches_the_evidence_and_is_absent_without_it() { let without = aien_runtime::generation::build_record(&id, &ev(None), start); assert!(without.get("ops").is_none(), "{without}"); } + +/// sc#402: a backend that counts chip calls reports them with the call +/// (`gpu_executions`, process total), in the record and in the log line; the +/// CPU reference backend has no chip and makes no claim (None, never zero). +#[tokio::test] +async fn chip_calls_are_reported_and_absent_without_a_chip() { + let tensors = Arc::new(ForcedFallback { + cpu: ReferenceCpuBackend::new(), + acct: OpAccounting::new(NativeOpMask::from_ops(&[TensorOp::MatmulVec])), + chip_calls: Some(std::sync::atomic::AtomicU64::new(0)), + }); + let ops = run(native_with(tensors.clone())) + .await + .expect("the native backend reports its op evidence"); + let counted = tensors.gpu_executions().unwrap(); + assert!(counted > 0, "the micro model runs matmul_vec"); + assert_eq!(ops.gpu_executions, Some(counted), "{ops:?}"); + assert_eq!(ops.native_fallbacks, 0, "{ops:?}"); + let line = aien_runtime::generation::op_report_line(Some(&ops)).unwrap(); + assert!( + line.ends_with(&format!( + " gpu_executions={counted} backend=forced-fallback" + )), + "{line}" + ); + let json = serde_json::to_value(&ops).unwrap(); + assert_eq!(json["gpu_executions"], serde_json::json!(counted)); + + let cpu = run(native_with(Arc::new(ReferenceCpuBackend::new()))) + .await + .expect("the native backend reports its op evidence"); + assert_eq!(cpu.gpu_executions, None); + let cpu_json = serde_json::to_value(&cpu).unwrap(); + assert!(cpu_json.get("gpu_executions").is_none(), "{cpu_json}"); + assert!(!aien_runtime::generation::op_report_line(Some(&cpu)) + .unwrap() + .contains("gpu_executions")); +} + +/// sc#402: the record carries `ops.gpu_executions` only when the evidence has it. +#[test] +fn record_carries_gpu_executions_only_when_counted() { + let id = aien_runtime::generation::ModelIdentity { + model_sha256: "m".repeat(64), + model_digest_kind: "file".into(), + model_path: "/m".into(), + tokenizer_sha256: "t".repeat(64), + tokenizer_path: "/t".into(), + }; + let ops = OpEvidence { + backend: "omega-gb10".into(), + native_fallbacks: 0, + reference_runs: 0, + report: "OP_REPORT native=[matmul_vec] reference=[] native_fallbacks=[] reference_runs=[]" + .into(), + gpu_executions: Some(156), + }; + let ev = aien_runtime::generation::TurnEvidence { + prompt_ids: &[1, 2], + output_ids: &[3, 4, 5], + text: "abc", + total_tokens: 5, + finish_reason: "eos", + request_id: 1, + operation_id: 1, + decoding: None, + ops: Some(&ops), + }; + let start = aien_runtime::generation::DaemonStart(1); + let rec = aien_runtime::generation::build_record(&id, &ev, start); + assert_eq!(rec["ops"]["gpu_executions"], serde_json::json!(156)); + assert_eq!(rec["ops"]["scope"], serde_json::json!("process")); +} diff --git a/crates/aien-runtime/tests/provenance_link_test.rs b/crates/aien-runtime/tests/provenance_link_test.rs index ef57d29d..d65dcfcb 100644 --- a/crates/aien-runtime/tests/provenance_link_test.rs +++ b/crates/aien-runtime/tests/provenance_link_test.rs @@ -78,6 +78,7 @@ fn cpu_ops() -> aien_inference_abi::OpEvidence { native_fallbacks: 0, reference_runs: 0, report: "OP_REPORT native=[] reference=[] native_fallbacks=[] reference_runs=[]".into(), + gpu_executions: None, } } diff --git a/docs/DAEMON_GENERATION_RECORD.md b/docs/DAEMON_GENERATION_RECORD.md index f5b71f3c..fe5ba7f8 100644 --- a/docs/DAEMON_GENERATION_RECORD.md +++ b/docs/DAEMON_GENERATION_RECORD.md @@ -132,6 +132,7 @@ counters (`TensorBackend::op_report`) when a sequence finishes | `reference_runs` | runs of ops on the reference CPU path by design (outside the backend's native mask) | | `scope` | always `process`: the counts are totals since the daemon built the backend, NOT per call | | `report` | the full `OP_REPORT native=[..] reference=[..] native_fallbacks=[..] reference_runs=[..]` line | +| `gpu_executions` | sc#402: operations the backend ran on its chip (the Omega GB10 engine's `chip_calls`), process total like the rest; ABSENT, not zero, for a backend with no chip (the CPU reference backend, the Omega stub). The `OP_REPORT` log line then carries ` gpu_executions=<n>` before ` backend=` | Because the counts are process totals, a later record's counts include every earlier call's; a per-call figure is the difference between two records of the