Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-omega-dattn/build.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-omega-dattn / build.rs` 73 lines ยท 3144 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 //! Decides whether omega's one-launch decode attention (`src/omega_gpu_decode_attn_api.h`, 17 //! OWN-30B cut 8 on the omega side) is linked. 18 //! 19 //! The archive itself is linked by `aien-omega-gpu`'s build script (this crate only declares 20 //! the extra symbols), so the decision mirrors its inputs: 21 //! * `AIEN_FORCE_CPU_STUB=1`: stub. 22 //! * `AIEN_OMEGA_GPU_LIB=`: native when `nm` finds `omega_gpu_decode_attn` defined 23 //! in that archive. 24 //! * `AIEN_OMEGA_DIR=`: native when the checkout has `src/omega_gpu_decode_attn_api.h`. 25 //! * otherwise: stub (every call returns `Unavailable`). 26 //! 27 //! `cfg(has_omega_dattn)` is set only when native. A stub never fails the build: the engine 28 //! keeps its split attention path (host norm/rope, paged KV), and `is_native()` says which 29 //! one a binary carries. 30 use std::path::Path; 31 use std::process::Command; 32 33 fn main() { 34 println!("cargo:rustc-check-cfg=cfg(has_omega_dattn)"); 35 for v in [ 36 "AIEN_FORCE_CPU_STUB", 37 "AIEN_OMEGA_GPU_LIB", 38 "AIEN_OMEGA_DIR", 39 ] { 40 println!("cargo:rerun-if-env-changed={v}"); 41 } 42 if std::env::var("AIEN_FORCE_CPU_STUB").as_deref() == Ok("1") { 43 return; 44 } 45 if let Ok(lib) = std::env::var("AIEN_OMEGA_GPU_LIB") { 46 println!("cargo:rerun-if-changed={lib}"); 47 if archive_defines(Path::new(&lib), "omega_gpu_decode_attn") { 48 println!("cargo:rustc-cfg=has_omega_dattn"); 49 } else { 50 println!("cargo:warning=aien-omega-dattn: {lib} does not define the decode attention API; fused attention is stubbed"); 51 } 52 return; 53 } 54 if let Ok(dir) = std::env::var("AIEN_OMEGA_DIR") { 55 let header = Path::new(&dir).join("src/omega_gpu_decode_attn_api.h"); 56 println!("cargo:rerun-if-changed={}", header.display()); 57 if header.is_file() { 58 println!("cargo:rustc-cfg=has_omega_dattn"); 59 } else { 60 println!("cargo:warning=aien-omega-dattn: {dir} has no src/omega_gpu_decode_attn_api.h (omega before OWN-30B cut 8); fused attention is stubbed"); 61 } 62 } 63 } 64 65 fn archive_defines(lib: &Path, symbol: &str) -> bool { 66 let Ok(out) = Command::new("nm").arg(lib).output() else { 67 println!("cargo:warning=aien-omega-dattn: nm not available, assuming the archive lacks the decode attention API"); 68 return false; 69 }; 70 String::from_utf8_lossy(&out.stdout) 71 .lines() 72 .any(|l| l.ends_with(&format!(" T {symbol}"))) 73 }