diff --git a/.crumb b/.crumb index 23909b77..25572278 100644 --- a/.crumb +++ b/.crumb @@ -64,8 +64,8 @@ "generated": { "children": [ { - "digest": "e8767d4b3fd08dac77adeaabdeff6a58bca1cc927c7c89db68bd5d2c6b49fead", - "last_commit": "91fba8f", + "digest": "56f591ac6ff77c0909109f9186e454416a9e90faf63499912ec060c4e121faa4", + "last_commit": "caa0c3f", "name": "scripts", "purpose": "" }, @@ -76,15 +76,15 @@ "purpose": "" } ], - "children_root": "sha256:dfcfd805db0c30c667bc5682364bd3acb3383d494967dcae39f2420739723d7d", - "compiled_at": "2026-10-05T04:05:30Z", + "children_root": "sha256:10d81c6270915316b54eee21734bb8e8f2716ffdc567100fb347a5f22ed95e24", + "compiled_at": "2026-10-05T04:24:29Z", "compiler": "crumb-compile/1", - "digest": "sha256:5885c8a87b87a313cfaf67fd901db946c28f5ec684cbe3ef3956f33748646da1", + "digest": "sha256:a5d35f497e150e0f1d110f9e8d13e5013771b3eec8307de4a58c046772cfe29a", "evidence_files": 20, "evidence_root": "sha256:1ef4526f6fe1ba0cee21a89c3313d37bf2e94e1aa2e9bd1a364225e52882d170", - "files": 683, - "generated_at_commit": "3dd2cb36eaac27c74964b4a47c9bb4a990353311", - "source_tree": "sha256:a0c99f76c9c4f23b156bcc2320e91aebb77b300943b0db92505e57eecae42693" + "files": 684, + "generated_at_commit": "caa0c3f333f85a409601b3bf51fc004ae6ccc1c4", + "source_tree": "sha256:59407e79b67b9b3b41e9500742aeb687f1537d59e08082e5f425a0444406ebc8" } }, "history": [], diff --git a/README.md b/README.md index 2fc5980f..349d0e42 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ Needs a Rust toolchain (1.85 or newer) on the DGX Spark or another Linux machine git clone https://github.com/aien-dev/aien-sovereign-core cd aien-sovereign-core cargo test --workspace -cargo run -p aien-scheduler --bin bench_inference_stack # measurement binary +scripts/repro-build.sh -p aien-cli # release build with machine-local paths removed (same digest on any machine/directory) +# Comparison yardstick only (Modular MAX bridge, needs `mojo`); not part of any default or qualified build: +cargo run -p aien-scheduler --features max-yardstick --bin bench_inference_stack ``` `install.sh` builds release binaries from source but performs no signature verification; signed releases are not yet available, so prefer building from a clone. diff --git a/crates/aien-scheduler/Cargo.toml b/crates/aien-scheduler/Cargo.toml index f5c6a5b1..578f9d56 100644 --- a/crates/aien-scheduler/Cargo.toml +++ b/crates/aien-scheduler/Cargo.toml @@ -11,7 +11,7 @@ aien-platform = { path = "../aien-platform" } aien-abi-core = { path = "../aien-abi-core" } aien-inference-abi = { path = "../aien-inference-abi" } aien-kv-cache = { path = "../aien-kv-cache" } -spark-max-rs = { path = "../spark-max-rs" } +spark-max-rs = { path = "../spark-max-rs", optional = true } tokio = { version = "1.37", features = ["full"] } parking_lot = "0.12" serde = { version = "1.0", features = ["derive"] } @@ -26,6 +26,7 @@ sha2 = "0.10" [[bin]] name = "bench_inference_stack" path = "src/bin/bench_inference_stack.rs" +required-features = ["max-yardstick"] [[bin]] name = "stress_aien_live" @@ -42,3 +43,7 @@ prefill_mutant_no_check = [] # decision differs with the tap on. tests/dual_observer_parity.rs must FAIL # with this feature on (negative control for the read-only tap). dual_observer_mutant_changes_decision = [] +# OFF by default. Pulls in the Modular MAX comparison bridge (spark-max-rs, spark-max-cabi) and +# builds the `bench_inference_stack` yardstick binary. MAX is a comparison tool only +# (Drake 2026-10-02); no production or qualification build may enable this. +max-yardstick = ["dep:spark-max-rs", "spark-max-rs/mojo-bridge"] diff --git a/crates/spark-aegis/Cargo.toml b/crates/spark-aegis/Cargo.toml index 88035ee8..6c3164f1 100644 --- a/crates/spark-aegis/Cargo.toml +++ b/crates/spark-aegis/Cargo.toml @@ -21,3 +21,8 @@ libc = "0.2" [dev-dependencies] tempfile = "3.17" + +[features] +# OFF by default. Builds the optional Mojo matcher library with `mojo build` and records its +# build path in the binary. The pure Rust engine is the default and the fallback. +mojo-bridge = [] diff --git a/crates/spark-aegis/build.rs b/crates/spark-aegis/build.rs index 79c8b3dc..0e4af52c 100644 --- a/crates/spark-aegis/build.rs +++ b/crates/spark-aegis/build.rs @@ -1,8 +1,17 @@ +//! Builds the optional Mojo `libsimd_matcher.so`, but ONLY when the `mojo-bridge` feature is on. +//! +//! A default build does not run `mojo`, does not copy into the source tree and does not export a +//! build-directory path (`SPARK_AEGIS_SO_BUILT`), so the same sources give the same binaries in +//! any directory. The pure Rust engine is the default and the fallback. use std::path::Path; use std::process::Command; fn main() { println!("cargo:rerun-if-changed=mojo/simd_matcher.mojo"); + println!("cargo:rerun-if-changed=build.rs"); + if std::env::var_os("CARGO_FEATURE_MOJO_BRIDGE").is_none() { + return; + } let out_dir = match std::env::var("OUT_DIR") { Ok(d) => d, Err(_) => return, diff --git a/crates/spark-max-cabi/Cargo.toml b/crates/spark-max-cabi/Cargo.toml index 5d1e0b1d..47f4cac5 100644 --- a/crates/spark-max-cabi/Cargo.toml +++ b/crates/spark-max-cabi/Cargo.toml @@ -12,3 +12,8 @@ tracing = "0.1" [dev-dependencies] tempfile = "3.17" + +[features] +# OFF by default. Runs `mojo build` for libspark_max.so (the Modular MAX comparison bridge) and +# records its build path in the binary. Never enable in a production or qualification build. +mojo-bridge = [] diff --git a/crates/spark-max-cabi/build.rs b/crates/spark-max-cabi/build.rs index f578e80b..25d2f122 100644 --- a/crates/spark-max-cabi/build.rs +++ b/crates/spark-max-cabi/build.rs @@ -1,8 +1,19 @@ +//! Builds `libspark_max.so` with Mojo, but ONLY when the `mojo-bridge` feature is on. +//! +//! The Modular MAX bridge is a comparison yardstick (Drake 2026-10-02: NVIDIA and MAX tools +//! are for comparison runs only, never baked into AIEN). A default build therefore does not +//! look for `mojo` on PATH, does not run it, does not copy anything into the source tree and +//! does not export a build-directory path (`SPARK_MAX_SO_BUILT`) into the compiled code, so +//! the same sources give the same binaries on any machine and in any directory. use std::path::Path; use std::process::Command; fn main() { println!("cargo:rerun-if-changed=mojo/spark_max_bridge.mojo"); + println!("cargo:rerun-if-changed=build.rs"); + if std::env::var_os("CARGO_FEATURE_MOJO_BRIDGE").is_none() { + return; + } let out_dir = std::env::var("OUT_DIR").unwrap(); let dest_path = Path::new(&out_dir).join("libspark_max.so"); diff --git a/crates/spark-max-rs/Cargo.toml b/crates/spark-max-rs/Cargo.toml index cae059a7..ecbf447e 100644 --- a/crates/spark-max-rs/Cargo.toml +++ b/crates/spark-max-rs/Cargo.toml @@ -15,3 +15,7 @@ tracing = "0.1" [dev-dependencies] tempfile = "3.17" tokio = { version = "1.37", features = ["full"] } + +[features] +# OFF by default; see spark-max-cabi. Comparison runs only. +mojo-bridge = ["spark-max-cabi/mojo-bridge"] diff --git a/docs/AIEN_INFERENCE_ABI_SPEC.md b/docs/AIEN_INFERENCE_ABI_SPEC.md index 85ced481..8989d4a1 100644 --- a/docs/AIEN_INFERENCE_ABI_SPEC.md +++ b/docs/AIEN_INFERENCE_ABI_SPEC.md @@ -169,7 +169,7 @@ When a subagent forks from a parent agent: Execution Substrate: NVIDIA DGX Spark (NVIDIA Grace Blackwell GB10, aarch64, 121 GB Unified LPDDR5X Memory, Linux 7.0.0-1019-nvidia). ### 5.1 Paged KV Cache Block-Table Allocator Throughput (Control Plane) -Benchmark binary: `target/release/bench_inference_stack` +Benchmark binary: `target/release/bench_inference_stack` (built only with `--features max-yardstick`; a comparison yardstick, not part of a default build) - Workload: 10,000 sequence allocations (160,000 block-table indices managed, block size = 16 tokens). | Metric | Result | Sub-unit Latency | diff --git a/docs/STATE_OF_AIEN.md b/docs/STATE_OF_AIEN.md index c9d0f81c..4e4516d5 100644 --- a/docs/STATE_OF_AIEN.md +++ b/docs/STATE_OF_AIEN.md @@ -25,7 +25,7 @@ Standard: Brutally Factual Systems Audit. Zero Marketing Language. | **atlas-vault** | Active | **Working Locally** | TPM-bound secret resolution, systemd-creds integration | Requires sudo credentials or TPM access during test runs. | | **aien-kv-cache** | Active | **Benchmarked** | 1.44M blocks/sec allocation, 0.69 µs alloc latency, 8.88 ns CoW append, physical unified pool mmap | Radix tree eviction across memory pressure under heavy fragmentation needs long-duration soak test. | | **aien-scheduler** | Active | **Benchmarked** | Sub-microsecond batch build overhead (2.2 µs at B=1 to 49.1 µs at B=256), chunked prefill validated | Priority queues currently hold 5 static priority tiers. | -| **spark-max-cabi** | Active | **Working Locally** | C-ABI dynamic library libspark_max.so compiled via Mojo 1.0.0, FFI tests passing | Shared object path must be present in LD_LIBRARY_PATH or binary build dir. | +| **spark-max-cabi** | Active | **Working Locally** | C-ABI dynamic library libspark_max.so compiled via Mojo 1.0.0, FFI tests passing | Opt-in `mojo-bridge` feature, comparison yardstick only: a default build never runs `mojo`. Shared object path must be present in LD_LIBRARY_PATH or binary build dir. | | **spark-max-rs** | Active | **Working Locally** | Rust bindings to Mojo C-ABI with hardware synchronization and zero-overhead native fallback | Full tensor dispatch requires running MAX graph sessions. | | **aien-inference-abi** | Active | **Cross-platform Verified** | Trait contracts, BlackwellInferenceBackend, MojoInferenceBackend, NativeCpuInferenceBackend, MockInferenceBackend (and transitional MaxServingBackend); tested on Apple Silicon M2, Linux x86_64, and Grace Blackwell | Live streaming SSE parsing is raw text; structured function calling parsing is pending. | | **Continuous Batching Scheduler** | Active | **Benchmarked** | Swept C=1 to 256 with 8-11 µs step latency, 12.3k steps/sec dispatch throughput, live power telemetry (11.5W-12.0W), 1,000 child zero-copy forks | Multi-stream continuous prefill pipeline verified against live MAX endpoints. | diff --git a/scripts/.crumb b/scripts/.crumb index 6853f5bc..4e461035 100644 --- a/scripts/.crumb +++ b/scripts/.crumb @@ -4,14 +4,14 @@ "generated": { "children": [], "children_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "compiled_at": "2026-10-04T16:48:07Z", + "compiled_at": "2026-10-05T04:17:52Z", "compiler": "crumb-compile/1", - "digest": "sha256:e8767d4b3fd08dac77adeaabdeff6a58bca1cc927c7c89db68bd5d2c6b49fead", + "digest": "sha256:56f591ac6ff77c0909109f9186e454416a9e90faf63499912ec060c4e121faa4", "evidence_files": 0, "evidence_root": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", - "files": 15, - "generated_at_commit": "ef3b4df17102183771e617bb6909dda085a2aba5", - "source_tree": "sha256:4e4dcf41a2c344a181ad77b414640814a4bf27e8231e327ba3f125e312700ef0" + "files": 16, + "generated_at_commit": "f4460c7943025f806f60839d36584546f28404c1", + "source_tree": "sha256:a683f6d347163245e0f2100543c424c01795592f3b24414e5848c35a4dd2319c" } }, "parent": { diff --git a/scripts/package-release.sh b/scripts/package-release.sh index dfcce660..cc38b8d4 100755 --- a/scripts/package-release.sh +++ b/scripts/package-release.sh @@ -5,7 +5,7 @@ ARTIFACT="${1:?provide output archive path}" PACKAGE_DIR="$(mktemp -d)" trap 'rm -rf "$PACKAGE_DIR"' EXIT mkdir -p "$PACKAGE_DIR/bin" -for binary in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger bench_inference_stack; do +for binary in aien-cli spark-cockpit-rs spark-inquisitor cortex-encoder-rs cortex-rs spark-supervisor spark-debugger; do [[ -x "target/release/$binary" ]] || { echo "Missing release binary: $binary" >&2; exit 1; } name="$binary" [[ "$binary" != aien-cli ]] || name=aien diff --git a/scripts/repro-build.sh b/scripts/repro-build.sh new file mode 100755 index 00000000..8a02c0a2 --- /dev/null +++ b/scripts/repro-build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Release build with machine-local paths removed from the binaries (CAND-0 reproducibility gap G13). +# +# scripts/repro-build.sh [cargo build arguments] e.g. scripts/repro-build.sh -p aien-cli +# +# rustc writes the source path of every dependency into panic messages. Dependencies come from +# $CARGO_HOME/registry/src/..., so without this script the aien-cli digest depends on the home +# directory and on CARGO_HOME of whoever built it. The script maps those prefixes to fixed names +# (--remap-path-prefix) and builds with --release --locked. It does not set AIEN_OMEGA_DIR, +# AIEN_PHYSICS_DIR or CARGO_TARGET_DIR: pass them as for any other build. +set -euo pipefail +root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P) +cargo_home=${CARGO_HOME:-$HOME/.cargo} +remap="--remap-path-prefix=$cargo_home=/cargo --remap-path-prefix=$root=/aien" +export RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }$remap" +exec cargo build --release --locked "$@"