diff --git a/.crumb b/.crumb index 5e238f82..3f9e1009 100644 --- a/.crumb +++ b/.crumb @@ -77,14 +77,14 @@ } ], "children_root": "sha256:285ca7eafbe46d808ebe5e4fb533e464bfdf0fedaf3eef486ac2e2c8826baf6f", - "compiled_at": "2026-10-08T16:10:40Z", + "compiled_at": "2026-10-08T16:42:18Z", "compiler": "crumb-compile/1", - "digest": "sha256:96b4e798532e03d970a6d9b5f18d9b272a6f689bb7c0d50a4a28460e3fb3da9a", + "digest": "sha256:c19d4e1d63d69c2db8abf7a01ea690a85518b7edde8bb342641daf6a9e6c5124", "evidence_files": 187, "evidence_root": "sha256:27ee0353cb4d4aae2b7dbce2bfe0d9f4ef2a94cd7a4555b84684d59372503280", "files": 1606, - "generated_at_commit": "c1f301db4cb3d52b9a17d5ce323b52390566b343", - "source_tree": "sha256:de88ac42111c4c20085f33df04172875c10a308d5a56a33e649fff5d903ccdbb" + "generated_at_commit": "e6f78ef2d84b8580dac343ff4a1cc48d3ba103b0", + "source_tree": "sha256:d55884db02ccd2b18ddfa4cc3c99ebecfd06358282b52f4c1521a5dc04229e29" } }, "history": [], diff --git a/crates/aien-cli/.crumb b/crates/aien-cli/.crumb index 16de79c1..74b160da 100644 --- a/crates/aien-cli/.crumb +++ b/crates/aien-cli/.crumb @@ -34,21 +34,21 @@ "generated": { "children": [ { - "digest": "bda1cf3ea7725b89dcc8c0a6f9019ca8f8a98e9173b99f48c434a6ff7e7b857d", - "last_commit": "fe5a7d7", + "digest": "341c94dbe5bc51ebc0817b9d30d63574cb232a935be1d205722094b1b868f881", + "last_commit": "ac34ad7", "name": "src", "purpose": "" } ], - "children_root": "sha256:79480b7c03456483de758f44f99f3f3661cb24bf829761bf11b58a04e27d8d18", - "compiled_at": "2026-10-08T12:29:05Z", + "children_root": "sha256:8d67b9a3f053e35074684b398443f1a26c2be0d37a3b2dcf00e37ece860a4f4c", + "compiled_at": "2026-10-08T14:18:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:c650324d0a164c5625d2aeb7081ae8598b1042bf317bbb36336d895db71f95f4", + "digest": "sha256:25e3b61a1d6916362265b667214779ac27fa318a7004b518976b82726d14cffd", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 34, - "generated_at_commit": "2dfa118965e2210badb9755c2e5b64605c22279f", - "source_tree": "sha256:72cac1d2603642c03b04de42ef97f4dc65a2e37c5d97c24283a1538517891c11" + "generated_at_commit": "6255540f6f11b9b4b23c3a39627abd40c624eeec", + "source_tree": "sha256:91fce885e88b09d49babf8847053b2b6f7316ff79126c5be0c97e20dfcd18cf6" } }, "history": [ diff --git a/crates/aien-cli/src/.crumb b/crates/aien-cli/src/.crumb index 456d9467..1e209bde 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-08T04:50:36Z", + "compiled_at": "2026-10-08T14:18:06Z", "compiler": "crumb-compile/1", - "digest": "sha256:bda1cf3ea7725b89dcc8c0a6f9019ca8f8a98e9173b99f48c434a6ff7e7b857d", + "digest": "sha256:341c94dbe5bc51ebc0817b9d30d63574cb232a935be1d205722094b1b868f881", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "files": 26, - "generated_at_commit": "2010f3d7d0bbbff9a83bfa2e7990dfbc285cf1ab", - "source_tree": "sha256:99eb9e7c645d419b534a39fc490c26c671de6c3cb0cb999a3f643ab62e6a4ffa" + "generated_at_commit": "6255540f6f11b9b4b23c3a39627abd40c624eeec", + "source_tree": "sha256:3d48d1b160879a6b6fae8fbded303e439313bb8a9fb00762053fb09cffdfb194" } }, "history": [ diff --git a/crates/aien-cli/src/commands.rs b/crates/aien-cli/src/commands.rs index 6fb51064..4698f46c 100644 --- a/crates/aien-cli/src/commands.rs +++ b/crates/aien-cli/src/commands.rs @@ -1208,7 +1208,7 @@ fn reference_fallback( struct ResidentLoad<'a> { native_linked: bool, strict: bool, - qwen3_opted_in: bool, + qwen3_enabled: bool, uploader: &'a dyn aien_inference_abi::ResidentUploader, /// Opens the GPU session (bounded retry) so every driver allocation of the upload happens /// while the process holds almost no memory. @@ -1261,7 +1261,7 @@ fn load_daemon_model_with( aien_inference_abi::resident_load_wanted( r.native_linked, r.strict, - r.qwen3_opted_in, + r.qwen3_enabled, &config, ) }); @@ -1430,8 +1430,7 @@ fn build_native_daemon_backend() -> Result { let resident = ResidentLoad { native_linked: aien_omega_gpu::is_native(), strict: aien_inference_abi::strict::production_strict(), - qwen3_opted_in: std::env::var(aien_inference_abi::GB10_QWEN3_OPT_IN_ENV) - .is_ok_and(|v| v == "1"), + qwen3_enabled: aien_inference_abi::gb10_qwen3_enabled(), uploader: &aien_inference_abi::OmegaUploader, open_session: &open_session, }; @@ -1587,7 +1586,7 @@ fn daemon_serving_reservation( kv_context_tokens: usize, sched: &aien_scheduler::SchedulerConfig, gpu_native: bool, - qwen3_opted_in: bool, + qwen3_enabled: bool, ops: &dyn aien_inference_abi::gb10_serving::ServingOps, ) -> Result, String> { let limits = aien_inference_abi::gb10_serving::ServingLimits { @@ -1599,7 +1598,7 @@ fn daemon_serving_reservation( model_config, &limits, gpu_native, - qwen3_opted_in, + qwen3_enabled, ops, ) .map(|r| r.map(|r| r.log_line())) @@ -1673,7 +1672,7 @@ pub async fn run_daemon_server() { std::process::exit(1); } } - // GB10 Qwen3 (the opt-in path only): reserve the serving buffers once, from the declared + // GB10 Qwen3 (enabled by default, #277): reserve the serving buffers once, from the declared // bounds, before the first request. A refusal stops the daemon by name; there is no // on-demand fallback (sovereign-core#277, omega#327, omega#333). The outcome is logged // either way so a chip run can measure it. @@ -1685,7 +1684,7 @@ pub async fn run_daemon_server() { _kv_plan.context_tokens, &sched_for_reservation, gpu_native, - std::env::var(aien_inference_abi::GB10_QWEN3_OPT_IN_ENV).is_ok_and(|v| v == "1"), + aien_inference_abi::gb10_qwen3_enabled(), &aien_inference_abi::gb10_serving::OmegaServingOps, ) { Ok(Some(line)) => { @@ -2282,7 +2281,7 @@ mod tests { #[test] fn default_path_makes_no_omega_call() { - // Qwen3 without the declared-attempt opt-in (the default refusal path) + // Qwen3 switched off with AIEN_GB10_QWEN3_DECLARED_ATTEMPT=0 let rec = Recorder::new(); assert_eq!(run(&rec, 4096, true, false), Ok(None)); // CPU daemon (no GB10 engine linked) diff --git a/crates/aien-inference-abi/src/gb10_serving.rs b/crates/aien-inference-abi/src/gb10_serving.rs index 637a20f2..a0118652 100644 --- a/crates/aien-inference-abi/src/gb10_serving.rs +++ b/crates/aien-inference-abi/src/gb10_serving.rs @@ -4,17 +4,20 @@ //! Without it, omega grows the attention staging pool, the matmul activation/result buffers //! and the matmul kernel cache on demand while serving, and every growth is a driver (RM) //! allocation that can fail with NV_ERR_NO_MEMORY when MemFree is low (omega#327; omega#332 -//! measured 458 allocations and 456 frees over 428 tokens). omega#333 and omega#338 add an -//! opt-in reservation: allocate the buffers once for declared bounds, build and pin every +//! measured 458 allocations and 456 frees over 428 tokens). omega#333 and omega#338 add a +//! reservation: allocate the buffers once for declared bounds, build and pin every //! matmul kernel the model will run (`prepare`), then `seal`, after which serving makes no //! driver allocation inside the bounds and an unprepared kernel or a call past the bounds is //! refused `TOO_LARGE` by name. //! //! This module derives the bounds and the shapes from the model and the daemon's declared //! limits, and runs reserve, prepare, seal in that order through [`ServingOps`] (the real one -//! calls omega; tests record). It applies only on the path that is already opt-in (Qwen3 on -//! the GB10, `AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1`); the default Qwen3 refusal is untouched. It -//! does not claim to fix #277: it is not proven on the chip, and omega's header lists what is +//! calls omega; tests record). It applies only to Qwen3 on the GB10, which is enabled by +//! default since #277 on a production-strict run (`AIEN_GB10_QWEN3_DECLARED_ATTEMPT=0` refuses it; +//! `1` also enables it under `AIEN_DEV_FALLBACK=1`). Evidence: #277 attempt 3 passed +//! (https://github.com/aien-dev/aien-sovereign-core/issues/277#issuecomment-6059774846), limited to a +//! Linux-hosted GB10 (not native AIENOS), one prompt, context 4096, no endurance run and no +//! failing baseline. It does not claim to fix #277 beyond that, and omega's header lists what is //! still not covered (elementwise scratch, the attention kernel). use crate::omega_backend::omega_model_refusal_with; @@ -170,11 +173,10 @@ pub fn reserve_gb10_serving_with( config: &ModelConfig, limits: &ServingLimits, gpu_native: bool, - qwen3_opted_in: bool, + qwen3_enabled: bool, ops: &dyn ServingOps, ) -> Result, String> { - if !gpu_native || !config.qk_norm || omega_model_refusal_with(config, qwen3_opted_in).is_some() - { + if !gpu_native || !config.qk_norm || omega_model_refusal_with(config, qwen3_enabled).is_some() { return Ok(None); } let refuse = |why: String| { diff --git a/crates/aien-inference-abi/src/lib.rs b/crates/aien-inference-abi/src/lib.rs index 733cdf51..73876847 100644 --- a/crates/aien-inference-abi/src/lib.rs +++ b/crates/aien-inference-abi/src/lib.rs @@ -36,6 +36,7 @@ pub use model_dir::{load_model_config, model_config_from_hf_json, model_id_for_d pub use moe_plan::*; pub use mojo_backend::*; pub use omega_backend::{ + gb10_qwen3_enabled, gb10_qwen3_enabled_from, gb10_qwen3_enabled_from_os, omega_backend_selected, omega_model_refusal, omega_model_refusal_with, open_gpu_session_with_retry, retry_bounded, retry_bounded_within, OmegaGb10Backend, SessionAttemptError, GB10_QWEN3_OPT_IN_ENV, GPU_BACKEND_ENV, GPU_SESSION_OPEN_ATTEMPTS, diff --git a/crates/aien-inference-abi/src/omega_backend.rs b/crates/aien-inference-abi/src/omega_backend.rs index 3303eb71..cc0f23fb 100644 --- a/crates/aien-inference-abi/src/omega_backend.rs +++ b/crates/aien-inference-abi/src/omega_backend.rs @@ -7,9 +7,10 @@ //! (the model builds Fp32 pools) the sequence's K/V are gathered on the host into //! contiguous f32 exactly as the reference reads them, then run on the f32 gqa kernel. //! omega attention needs head_dim 64 (TinyLlama, Llama-3.2-1B) or 128 (Qwen3-4B, since omega -//! b564bf4; Qwen3 is refused by default while omega#327 is open and at any other head_dim -//! always, see `omega_model_refusal`). A chip -//! error in one of those is a fallback of a claimed-native op: it is counted, goes through +//! b564bf4). Qwen3 at any other head_dim is always refused; at 128 it is refused when the +//! switch is off (see `omega_model_refusal`). +//! +//! A chip error in one of those ops is a fallback of a claimed-native op: it is counted, goes through //! `OpAccounting::reference_path` (fatal in a production build, see `strict.rs`) //! and, in a dev build only, the reference result is computed so the run goes on. //! @@ -569,26 +570,59 @@ impl OmegaGb10Backend { /// only with `head_dim` 128 (Qwen3-4B) and is refused up front otherwise, before any chip work. /// Llama-architecture models are not touched by this check. /// -/// Qwen3 at `head_dim` 128 is also refused by default while omega#327 is open: in the -/// normal memory state (MemFree low, most memory in clean page cache) the driver's channel -/// and weight allocations fail with NV_ERR_NO_MEMORY after the f32 weight load -/// (sovereign-core #274, declared attempt 1). A declared chip attempt opts in with -/// [`GB10_QWEN3_OPT_IN_ENV`]` = 1`; see [`omega_model_refusal_with`]. +/// Evidence limits: the #277 attempt 3 pass (issue comment 6059774846) covers a Linux-hosted +/// GB10 only (not native AIENOS), one prompt, context 4096, no endurance run and no failing +/// baseline. So the default (switch unset) enables Qwen3 only on a production-strict run; under +/// `AIEN_DEV_FALLBACK=1` it is refused unless the switch is explicitly `1`. +/// +/// Qwen3 at `head_dim` 128 runs on the GB10 by default since the qualified path passed +/// (sovereign-core #277, declared attempt 3): the daemon streams the weights to the device +/// and reserves, prepares and seals the serving buffers once, and refuses by name with no +/// fallback if that fails. Before that, the driver's channel and weight allocations failed +/// with NV_ERR_NO_MEMORY when MemFree was low after the f32 weight load (omega#327). The +/// explicit refusal is [`GB10_QWEN3_OPT_IN_ENV`]` = 0`; see [`omega_model_refusal_with`]. pub fn omega_model_refusal(config: &ModelConfig) -> Option { - omega_model_refusal_with(config, gb10_qwen3_opted_in()) + omega_model_refusal_with(config, gb10_qwen3_enabled()) } -/// Environment switch for a declared GB10 attempt that runs Qwen3 although omega#327 is -/// open. Only the exact value `1` opts in; unset or anything else keeps the refusal. +/// Environment switch for the GB10 Qwen3 path (rule, one place): +/// - exactly `1`: enabled (the old declared-attempt opt-in, any build); +/// - unset: enabled only on the path the evidence covers, a production-strict run +/// ([`crate::strict::production_strict`], so no `AIEN_DEV_FALLBACK=1`); the native engine and +/// the streamed resident load that go with it are checked by `check_model` and +/// [`crate::resident::resident_load_wanted`]; +/// - `0`, or any other value including non-UTF8: refused by name (fail closed). pub const GB10_QWEN3_OPT_IN_ENV: &str = "AIEN_GB10_QWEN3_DECLARED_ATTEMPT"; -pub(crate) fn gb10_qwen3_opted_in() -> bool { - std::env::var(GB10_QWEN3_OPT_IN_ENV).is_ok_and(|v| v == "1") +/// Whether the GB10 Qwen3 path is enabled, read from [`GB10_QWEN3_OPT_IN_ENV`] and the +/// process strictness. +pub fn gb10_qwen3_enabled() -> bool { + gb10_qwen3_enabled_from_os( + std::env::var_os(GB10_QWEN3_OPT_IN_ENV).as_deref(), + crate::strict::production_strict(), + ) +} + +/// [`gb10_qwen3_enabled`] on an explicit value and strictness (`strict` is true when +/// fallbacks are not allowed). +pub fn gb10_qwen3_enabled_from(value: Option<&str>, strict: bool) -> bool { + match value { + None => strict, + Some(v) => v == "1", + } } -/// [`omega_model_refusal`] with the opt-in passed explicitly instead of read from the -/// environment. -pub fn omega_model_refusal_with(config: &ModelConfig, qwen3_opted_in: bool) -> Option { +/// Same rule on a raw OS value: non-UTF8 refuses. +pub fn gb10_qwen3_enabled_from_os(value: Option<&std::ffi::OsStr>, strict: bool) -> bool { + match value { + None => gb10_qwen3_enabled_from(None, strict), + Some(v) => gb10_qwen3_enabled_from(Some(v.to_str().unwrap_or("")), strict), + } +} + +/// [`omega_model_refusal`] with the switch passed explicitly instead of read from the +/// environment (`qwen3_enabled` is true when the Qwen3 path is enabled). +pub fn omega_model_refusal_with(config: &ModelConfig, qwen3_enabled: bool) -> Option { if !config.qk_norm { return None; } @@ -600,31 +634,50 @@ pub fn omega_model_refusal_with(config: &ModelConfig, qwen3_opted_in: bool) -> O config.model_id, config.head_dim )); } - (!qwen3_opted_in).then(|| { + (!qwen3_enabled).then(|| { format!( - "OmegaGb10Backend refuses model {:?}: the GB10 Qwen3 path is off by default while the \ - resident-weight memory issue omega#327 is open (the driver's channel and weight \ - allocations fail with NV_ERR_NO_MEMORY when MemFree is low after the f32 weight \ - load); run it on the CPU reference backend, or set {GB10_QWEN3_OPT_IN_ENV}=1 for a \ - declared chip attempt", + "OmegaGb10Backend refuses model {:?}: the GB10 Qwen3 path is switched off by \ + {GB10_QWEN3_OPT_IN_ENV} (only 1, or unset on a production-strict run, enables it); run it on the CPU \ + reference backend, or unset {GB10_QWEN3_OPT_IN_ENV} on a strict run (no \ + AIEN_DEV_FALLBACK) to use the qualified GB10 path (sovereign-core#277)", config.model_id ) }) } -impl TensorBackend for OmegaGb10Backend { - fn check_model(&self, config: &ModelConfig) -> Result<(), String> { - omega_model_refusal(config).map_or(Ok(()), Err)?; +impl OmegaGb10Backend { + /// [`TensorBackend::check_model`] with the Qwen3 switch passed explicitly (the real call reads + /// [`gb10_qwen3_enabled`]); refuses Qwen3 on a stub build whatever the switch says. + pub fn check_model_with( + &self, + config: &ModelConfig, + qwen3_enabled: bool, + ) -> Result<(), String> { + omega_model_refusal_with(config, qwen3_enabled).map_or(Ok(()), Err)?; + if config.qk_norm && !self.is_available() { + return Err(format!( + "OmegaGb10Backend refuses model {:?}: Qwen3 needs the linked GB10 engine for its \ + streamed weights and serving reservation, and this is a stub build (no chip); \ + run it on the CPU reference backend", + config.model_id + )); + } if config.qk_norm { eprintln!( - "OMEGA_BACKEND WARNING: {GB10_QWEN3_OPT_IN_ENV}=1, running Qwen3 {:?} on GB10 \ - although omega#327 (NV_ERR_NO_MEMORY on low MemFree) is open; for a declared \ - chip attempt only", + "OMEGA_BACKEND NOTE: running Qwen3 {:?} on GB10 via the qualified path \ + (streamed resident weights, reserve+prepare+seal once, no on-demand fallback; \ + sovereign-core#277). Set {GB10_QWEN3_OPT_IN_ENV}=0 to refuse it", config.model_id ); } Ok(()) } +} + +impl TensorBackend for OmegaGb10Backend { + fn check_model(&self, config: &ModelConfig) -> Result<(), String> { + self.check_model_with(config, gb10_qwen3_enabled()) + } fn name(&self) -> &'static str { if self.is_available() { @@ -1122,6 +1175,88 @@ pub fn open_gpu_session_with_retry( mod tests { use super::*; + fn qwen3_4b_shape() -> ModelConfig { + let mut c = ModelConfig::tinyllama_1_1b(); + c.model_id = "qwen3-shape-test".to_string(); + c.qk_norm = true; + c.head_dim = 128; + c + } + + #[test] + fn stub_backend_refuses_qwen3_with_switch_unset_or_one() { + let b = OmegaGb10Backend::new(); + if b.is_available() { + return; // chip build: the stub refusal does not apply + } + let q = qwen3_4b_shape(); + // Unset on a strict run is "enabled"; `1` is enabled. A stub build still refuses. + for enabled in [ + gb10_qwen3_enabled_from(None, true), + gb10_qwen3_enabled_from(Some("1"), true), + ] { + assert!(enabled); + let err = b.check_model_with(&q, enabled).unwrap_err(); + assert!(err.contains("stub build (no chip)"), "{err}"); + } + // Llama-architecture models are unchanged. + assert!(b + .check_model_with(&ModelConfig::tinyllama_1_1b(), false) + .is_ok()); + } + + #[test] + fn non_utf8_switch_value_refuses() { + use std::os::unix::ffi::OsStrExt; + let bad = std::ffi::OsStr::from_bytes(&[0x31, 0xff]); + for strict in [true, false] { + assert!(!gb10_qwen3_enabled_from_os(Some(bad), strict)); + } + assert!(gb10_qwen3_enabled_from_os( + Some(std::ffi::OsStr::new("1")), + false + )); + assert!(!gb10_qwen3_enabled_from_os( + Some(std::ffi::OsStr::new("0")), + true + )); + } + + #[test] + fn unset_switch_needs_a_strict_run_but_one_always_enables() { + // Rule: AIEN_DEV_FALLBACK=1 (non-strict) with the switch unset is refused by name. + assert!(!gb10_qwen3_enabled_from(None, false)); + let q = qwen3_4b_shape(); + let msg = omega_model_refusal_with(&q, gb10_qwen3_enabled_from(None, false)) + .expect("unset + non-strict must refuse"); + assert!(msg.contains(GB10_QWEN3_OPT_IN_ENV), "{msg}"); + let b = OmegaGb10Backend::new(); + assert!(b + .check_model_with(&q, gb10_qwen3_enabled_from(None, false)) + .unwrap_err() + .contains(GB10_QWEN3_OPT_IN_ENV)); + // Explicit 1 keeps the declared-attempt opt-in; no resident load without strict. + assert!(omega_model_refusal_with(&q, gb10_qwen3_enabled_from(Some("1"), false)).is_none()); + assert!(!crate::resident::resident_load_wanted( + true, + false, + gb10_qwen3_enabled_from(Some("1"), false), + &q + )); + assert!(!crate::resident::resident_load_wanted( + true, + false, + gb10_qwen3_enabled_from(None, false), + &q + )); + assert!(crate::resident::resident_load_wanted( + true, + true, + gb10_qwen3_enabled_from(None, true), + &q + )); + } + fn lcg(s: &mut u32) -> f32 { *s = s.wrapping_mul(1664525).wrapping_add(1013904223); ((*s >> 8) as f32 / (1u32 << 24) as f32) - 0.5 diff --git a/crates/aien-inference-abi/src/resident.rs b/crates/aien-inference-abi/src/resident.rs index 94b2ef4f..3dd1066d 100644 --- a/crates/aien-inference-abi/src/resident.rs +++ b/crates/aien-inference-abi/src/resident.rs @@ -182,18 +182,18 @@ impl ResidentUploader for OmegaUploader { } /// Whether the daemon loads weights resident: the native engine is linked, the build is -/// production-strict (no CPU fallback to need host values for), the declared GB10 Qwen3 attempt -/// is on, and the model is one the engine accepts. Anything else keeps the host f32 load. +/// production-strict (no CPU fallback to need host values for), the GB10 Qwen3 path +/// is enabled (see `gb10_qwen3_enabled`), and the model is one the engine accepts. Anything else keeps the host f32 load. pub fn resident_load_wanted( native_linked: bool, strict: bool, - qwen3_opted_in: bool, + qwen3_enabled: bool, config: &ModelConfig, ) -> bool { native_linked && strict && config.qk_norm - && crate::omega_backend::omega_model_refusal_with(config, qwen3_opted_in).is_none() + && crate::omega_backend::omega_model_refusal_with(config, qwen3_enabled).is_none() } /// Streams a checkpoint straight to the device. For each of the seven matmul weights of each diff --git a/crates/aien-inference-abi/tests/gb10_serving_reservation.rs b/crates/aien-inference-abi/tests/gb10_serving_reservation.rs index 2b755a01..cbd2a512 100644 --- a/crates/aien-inference-abi/tests/gb10_serving_reservation.rs +++ b/crates/aien-inference-abi/tests/gb10_serving_reservation.rs @@ -137,7 +137,7 @@ fn a_refusal_stops_serving_by_name_with_no_fallback() { } #[test] -fn nothing_changes_off_the_opt_in_qwen3_gb10_path() { +fn nothing_changes_off_the_enabled_qwen3_gb10_path() { let none = |native: bool, opted: bool, cfg: &aien_inference_abi::ModelConfig| { let ops = Ops::default(); let r = reserve_gb10_serving_with(cfg, &daemon_limits(), native, opted, &ops).unwrap(); @@ -147,7 +147,7 @@ fn nothing_changes_off_the_opt_in_qwen3_gb10_path() { ); }; none(false, true, &qwen3_4b()); // not native (CPU daemon) - none(true, false, &qwen3_4b()); // default refusal still in force (no opt-in) + none(true, false, &qwen3_4b()); // switched off (=0): the refusal still applies let mut llama = qwen3_4b(); llama.qk_norm = false; // a non-Qwen3 model on the GB10 is untouched none(true, true, &llama); diff --git a/crates/aien-inference-abi/tests/qwen3_forward_parity.rs b/crates/aien-inference-abi/tests/qwen3_forward_parity.rs index b361f4a5..408509e6 100644 --- a/crates/aien-inference-abi/tests/qwen3_forward_parity.rs +++ b/crates/aien-inference-abi/tests/qwen3_forward_parity.rs @@ -348,20 +348,39 @@ fn gb10_backend_refuses_qwen3_and_not_llama() { Some("{\"eos_token_id\":[151645]}"), ) .unwrap(); - // Qwen3-4B (head_dim 128): rmsnorm_heads and attention both run on the engine, but the - // path stays off by default while omega#327 (NV_ERR_NO_MEMORY on low MemFree) is open. + // Qwen3-4B (head_dim 128): rmsnorm_heads and attention both run on the engine, and since + // sovereign-core#277 (declared attempt 3) the qualified path is the default. Only an + // explicit switch-off refuses it, by name. assert_eq!(q.head_dim, 128); let msg = omega_model_refusal_with(&q, false) - .expect("Qwen3-4B must be refused on the GB10 engine by default"); + .expect("Qwen3-4B must be refused on the GB10 engine when switched off"); assert!( - msg.contains("omega#327") - && msg.contains("NV_ERR_NO_MEMORY") - && msg.contains("AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1"), + msg.contains("AIEN_GB10_QWEN3_DECLARED_ATTEMPT") && msg.contains("switched off"), "{msg}" ); assert_eq!(omega_model_refusal_with(&q, true), None); - if std::env::var(GB10_QWEN3_OPT_IN_ENV).is_err() { - assert_eq!(omega_model_refusal(&q), Some(msg)); + // The default is on: unset and 1 enable, 0 and any other value refuse (fail closed). + assert!(aien_inference_abi::gb10_qwen3_enabled_from(None, true)); + assert!(aien_inference_abi::gb10_qwen3_enabled_from(Some("1"), true)); + // Unset on a non-strict (AIEN_DEV_FALLBACK=1) run is outside the evidence: refused. + assert!(!aien_inference_abi::gb10_qwen3_enabled_from(None, false)); + assert!(aien_inference_abi::gb10_qwen3_enabled_from( + Some("1"), + false + )); + for v in ["0", "", "true", "yes", "2", " 1"] { + assert!( + !aien_inference_abi::gb10_qwen3_enabled_from(Some(v), true), + "{v:?}" + ); + } + match std::env::var(GB10_QWEN3_OPT_IN_ENV).ok().as_deref() { + None if aien_inference_abi::strict::production_strict() => { + assert_eq!(omega_model_refusal(&q), None) + } + None => assert_eq!(omega_model_refusal(&q), Some(msg)), + Some("1") => assert_eq!(omega_model_refusal(&q), None), + Some(_) => assert_eq!(omega_model_refusal(&q), Some(msg)), } // A Qwen3 shape with head_dim 64 cannot run rmsnorm_heads (head_dim % 128): refused up front. let q64 = model_config_from_hf_json( @@ -371,7 +390,7 @@ fn gb10_backend_refuses_qwen3_and_not_llama() { ) .unwrap(); assert_eq!(q64.head_dim, 64); - // The opt-in does not lift this one. + // Neither setting lifts this one. for opted_in in [false, true] { let msg = omega_model_refusal_with(&q64, opted_in) .expect("Qwen3 with head_dim 64 must be refused on the GB10 engine"); @@ -600,9 +619,9 @@ fn real_qwen3_4b_instruct_2507_on_gb10_matches_transformers() { .map(|v| v.as_f64().unwrap() as f32) .collect(); let config = load_model_config(&dir).expect("config"); - omega - .check_model(&config) - .expect("GB10 engine must accept Qwen3-4B (a declared attempt sets AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1)"); + omega.check_model(&config).expect( + "GB10 engine must accept Qwen3-4B (unset or AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1 enables it)", + ); let weights = TransformerWeights::load_from_safetensors( dir.join("model.safetensors.index.json"), &config, diff --git a/crates/aien-inference-abi/tests/resident_weights.rs b/crates/aien-inference-abi/tests/resident_weights.rs index 10c41918..24cb9a88 100644 --- a/crates/aien-inference-abi/tests/resident_weights.rs +++ b/crates/aien-inference-abi/tests/resident_weights.rs @@ -403,17 +403,17 @@ fn host_slice_access_to_a_resident_weight_is_refused_by_name() { } #[test] -fn resident_load_is_chosen_only_on_the_native_strict_opted_in_qwen3_path() { +fn resident_load_is_chosen_only_on_the_native_strict_enabled_qwen3_path() { let dir = tiny_dir(); let tiny = load_model_config(&dir).unwrap(); // qk_norm, head_dim 16 let mut q4b = tiny.clone(); q4b.head_dim = 128; // the head_dim the GB10 engine accepts for Qwen3 - // (native, strict, opted in, accepted Qwen3) -> resident + // (native, strict, enabled, accepted Qwen3) -> resident assert!(resident_load_wanted(true, true, true, &q4b)); // each condition off -> host f32 load, unchanged assert!(!resident_load_wanted(false, true, true, &q4b)); // stub build / no GB10 assert!(!resident_load_wanted(true, false, true, &q4b)); // dev-fallback needs host values - assert!(!resident_load_wanted(true, true, false, &q4b)); // default refusal of Qwen3 stays + assert!(!resident_load_wanted(true, true, false, &q4b)); // Qwen3 switched off (=0): refused assert!(!resident_load_wanted(true, true, true, &tiny)); // engine refuses head_dim 16 let mut llama = q4b.clone(); llama.qk_norm = false; // other models keep their path diff --git a/docs/design/gb10-weight-ownership.md b/docs/design/gb10-weight-ownership.md index eccd4223..71d65700 100644 --- a/docs/design/gb10-weight-ownership.md +++ b/docs/design/gb10-weight-ownership.md @@ -305,8 +305,14 @@ low-MemFree state where the unchanged baseline fails, without dropping the page - Limits to state in the verdict: one model, one hardware unit, one driver (580.173.02), batch size coverage as run, context only up to what the serving leg reached (and never above 4096 on this path). -- The default refusal in `omega_model_refusal_with` (omega_backend.rs:543-) stays until the verdict - is PASS and merged. Flipping it is a separate PR that cites the verdict. +- The default refusal in `omega_model_refusal_with` stayed until the verdict was PASS and merged. + Declared attempt 3 passed (sovereign-core#277), and the follow-up PR flipped the default: + `AIEN_GB10_QWEN3_DECLARED_ATTEMPT` set to `1` enables the path; unset enables it only on a + production-strict run (no `AIEN_DEV_FALLBACK=1`), with the native engine and streamed resident + weights; `0` (or any other value, including non-UTF8) refuses it by name. + Evidence limits: the pass is [#277 comment 6059774846](https://github.com/aien-dev/aien-sovereign-core/issues/277#issuecomment-6059774846), + on a Linux-hosted GB10 only (not native AIENOS), one prompt, context 4096, no endurance run, + no failing baseline, cache partly scripted. - Do not drop caches to qualify. If the organic state never recurs, the answer is "not qualified", not a staged state.