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#278 (code only)
Apply it
git checkout -b patch-f12988f8d4741155 3c247abeaecc08c1cff91ea5f07af3b76e7a7975 curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/f12988f8d4741155.patch | git am
Provenance
github-import 1
aien-dev/aien-sovereign-core-mv
278
5f767f9baaab04109d98622526dadf818140943f
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":278,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/278","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:38Z","metadata":"unavailable","state_derived":true}
Changes
diff --git a/.crumb b/.crumb index d7053ee9..9924722e 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:c5269f93385287c09996ff41f0247f72de9237a2317f47c94c51273d6a0acef1", - "compiled_at": "2026-10-07T05:51:10Z", + "compiled_at": "2026-10-07T06:33:45Z", "compiler": "crumb-compile/1", - "digest": "sha256:126a21c4562d45f679f00d01fc1bed1efbfc632f025ebc4419b0d7c0162f982b", + "digest": "sha256:7a2221f68b38108757f8c15e90b48fca98fa0be8182f0e843eb1eb541339a77e", "evidence_files": 155, "evidence_root": "sha256:ff6dddfecfcc02cea55f46acaccc7eaecd27557209e98c3d5616ec02bdde31db", "files": 1133, - "generated_at_commit": "02e10da264f0ff8a27e559208616d6d8c14284a7", - "source_tree": "sha256:e0373fc57513028cf9323459427a1fd0c8131db9fd3d1d7f26b856faf96d7b6f" + "generated_at_commit": "a2ea81cbc1cb912824a97b872aa9f925a6cdca4f", + "source_tree": "sha256:19f3f9ddc9783030aa15e6b2ace896e5d2c12e5dbb1d6ddc14c66833906ebb13" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index db4518d7..9d7f1d91 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "15caa3d415f9f10512dd25198b13b4fcc452b67aa8a1f486265c98fa53df69aa", - "last_commit": "e167aab", + "digest": "8f29f12a3099815ea17cb7dacb96620597365b9d9fe37ff0c7f1add0c79270c4", + "last_commit": "a2ea81c", "name": "src", "purpose": "" } ], - "children_root": "sha256:5cabc59992345b4f04b69ed823dbcaf6b22529424e9fb771f2802bbeb948db53", - "compiled_at": "2026-10-07T04:56:45Z", + "children_root": "sha256:cf504ac20bf43b1a91aa07154f2faaaf217865a4f75e8a052f7e1cb2a7fe4ce8", + "compiled_at": "2026-10-07T06:33:45Z", "compiler": "crumb-compile/1", - "digest": "sha256:d35de04d713e3ea66db9904daa1ca356573768bcb74d267343d0cd9cc3230486", + "digest": "sha256:6d367aec712e344c913c264d1f36ea8de33e476f3a2147d422ca16c8963ec16e", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 28, - "generated_at_commit": "e167aab55b283151f2456ea5f3e79ffe72b48b93", - "source_tree": "sha256:07b3c1d97c67b881c22892f32d4d43e66bd95ebc1eb7f2fdbf7c3f04457787a1" + "generated_at_commit": "a2ea81cbc1cb912824a97b872aa9f925a6cdca4f", + "source_tree": "sha256:0107cf7821c14524b636c989ff69bb86aa199f5da31b6756066a9edf07fa2fdb" } }, "history": [ diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index c35e1a5b..eae5953e 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-07T04:56:45Z", + "compiled_at": "2026-10-07T06:33:45Z", "compiler": "crumb-compile/1", - "digest": "sha256:15caa3d415f9f10512dd25198b13b4fcc452b67aa8a1f486265c98fa53df69aa", + "digest": "sha256:8f29f12a3099815ea17cb7dacb96620597365b9d9fe37ff0c7f1add0c79270c4", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 25, - "generated_at_commit": "e167aab55b283151f2456ea5f3e79ffe72b48b93", - "source_tree": "sha256:a0395aab980b091dfca497dde69cce3fa790612782b696696e8428a83f5ad1fd" + "generated_at_commit": "a2ea81cbc1cb912824a97b872aa9f925a6cdca4f", + "source_tree": "sha256:01908eba83595c91d8519dd6e2d8802f2791874df39efb07eec695ed246b5f8a" } }, "history": [ diff --git a/crates/aien-cli/src/commands.rs b/crates/aien-cli/src/commands.rs index de95f95e..c3b6ffd4 100644 --- a/crates/aien-cli/src/commands.rs +++ b/crates/aien-cli/src/commands.rs @@ -1455,6 +1455,25 @@ pub async fn run_daemon_server() { watermark_blocks: 64, }; + // Open the GPU session before the weights load, with a bounded retry, so a + // failed channel open is a clear refusal with status and free memory per + // attempt instead of the strict-fallback panic at warm-up (#239, #236). It + // comes first because the channel open allocates the GPU context buffers, + // and after the f32 weight load those allocations fail with + // NV_ERR_NO_MEMORY while MemFree is low and the page cache is full + // (omega#327, sovereign-core#277). The session stays open for the process. + let gpu_native = aien_inference_abi::OmegaGb10Backend::new().is_available(); + if gpu_native { + if let Err(fatal) = aien_inference_abi::open_gpu_session_with_retry( + aien_inference_abi::GPU_SESSION_OPEN_ATTEMPTS, + aien_inference_abi::GPU_SESSION_RETRY_DELAY, + aien_inference_abi::GPU_SESSION_OPEN_DEADLINE, + &aien_runtime::shared_kv::read_mem_available, + ) { + eprintln!("Fatal: {}", fatal.red().bold()); + std::process::exit(1); + } + } let (weights, tensor_backend, backend_label, model_label, tokenizer) = match build_native_daemon_backend() { Ok(parts) => parts, @@ -1476,7 +1495,6 @@ pub async fn run_daemon_server() { std::process::exit(1); } }; - let gpu_native = aien_inference_abi::OmegaGb10Backend::new().is_available(); let (spine, backend, _kv_plan) = match aien_runtime::shared_kv::build_shared_kv_runtime_for_model( weights, @@ -1493,20 +1511,6 @@ pub async fn run_daemon_server() { std::process::exit(1); } }; - // Open the GPU session before serving, with a bounded retry, so a failed - // channel open is a clear refusal with status and free memory per attempt - // instead of the strict-fallback panic at warm-up (#239, #236). - if gpu_native { - if let Err(fatal) = aien_inference_abi::open_gpu_session_with_retry( - aien_inference_abi::GPU_SESSION_OPEN_ATTEMPTS, - aien_inference_abi::GPU_SESSION_RETRY_DELAY, - aien_inference_abi::GPU_SESSION_OPEN_DEADLINE, - &aien_runtime::shared_kv::read_mem_available, - ) { - eprintln!("Fatal: {}", fatal.red().bold()); - std::process::exit(1); - } - } let server = aien_runtime::server::AienRuntimeServer::new(spine, &socket_path); println!(" Backend: {}", backend_label.green()); diff --git a/crates/aien-inference-abi/tests/qwen3_forward_parity.rs b/crates/aien-inference-abi/tests/qwen3_forward_parity.rs index b361f4a5..0ddb6aac 100644 --- a/crates/aien-inference-abi/tests/qwen3_forward_parity.rs +++ b/crates/aien-inference-abi/tests/qwen3_forward_parity.rs @@ -571,6 +571,19 @@ fn real_qwen3_4b_instruct_2507_matches_transformers() { fn real_qwen3_4b_instruct_2507_on_gb10_matches_transformers() { let omega = Arc::new(aien_inference_abi::OmegaGb10Backend::new()); assert!(omega.is_available(), "native build required"); + // Open the GPU session before the f32 weight load (about 16 GB), in the daemon's + // order (aien-cli `start`, #277). The first declared attempt (#274) opened it lazily + // at the first op, right after the load, and the channel's GPU context buffer + // allocation failed with RM status 0x51 (NV_ERR_NO_MEMORY) while MemFree was low and + // the page cache full (omega#327); MemAvailable stays high then, so MemFree is logged. + eprintln!("QWEN3_GB10_MEM before session open: {}", meminfo_line()); + aien_inference_abi::open_gpu_session_with_retry( + 1, + std::time::Duration::ZERO, + std::time::Duration::from_secs(30), + &|| meminfo_kb("MemAvailable:").map(|kb| kb * 1024), + ) + .expect("the GPU session must open before the weights load"); let dir = PathBuf::from( std::env::var("AIEN_QWEN3_DIR").expect("AIEN_QWEN3_DIR must name the model directory"), ); @@ -608,6 +621,7 @@ fn real_qwen3_4b_instruct_2507_on_gb10_matches_transformers() { &config, ) .expect("weights"); + eprintln!("QWEN3_GB10_MEM after weight load: {}", meminfo_line()); let mut b = NativeTransformerBackend::with_backend(weights, omega.clone()); let got = b .prefill_sequence(1, &ids) @@ -682,3 +696,25 @@ fn qwen3_tiny_batch_decode_matches_transformers_and_single_sequence() { "third sequence must differ from the first" ); } + +/// One /proc/meminfo value in kB, or None when it cannot be read. +fn meminfo_kb(key: &str) -> Option<u64> { + std::fs::read_to_string("/proc/meminfo") + .ok()? + .lines() + .find(|l| l.starts_with(key))? + .split_whitespace() + .nth(1)? + .parse() + .ok() +} + +/// MemFree and MemAvailable in MiB, for the GB10 memory log lines. +fn meminfo_line() -> String { + let mib = |k: &str| meminfo_kb(k).map_or("UNKNOWN".to_string(), |kb| (kb / 1024).to_string()); + format!( + "MemFree={} MiB MemAvailable={} MiB", + mib("MemFree:"), + mib("MemAvailable:") + ) +}