interplane.Get Omega
Read in your language

benchmarks-mv

Measurement harnesses and evidence bundles for AIEN on the NVIDIA DGX Spark GB10. Speed is reported against the machine's physical limit and my own previous run. Attachment of AienOS.

Brought by drakestapleton

branch main Branches Tags History

benchmarks-mv / prime-drag-race / src / main.rs

151 lines · 5601 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
16use prime_race::runner::{reference_count, run, verify, ImplSpec, RunArgs};
17use prime_race::sweep::{default_sweep, parse_limits};
18use prime_race::validate::Tags;
19use clap::{Parser, Subcommand};
20use std::collections::BTreeMap;
21use std::path::PathBuf;
22
23#[derive(Parser)]
24#[command(name = "prime_race", about = "AIEN Prime Drag Race suite runner (contract version 1)")]
25struct Cli {
26 #[command(subcommand)]
27 cmd: Cmd,
28}
29
30#[derive(Subcommand)]
31enum Cmd {
32 /// Correctness sweep of one implementation.
33 Verify {
34 #[arg(long = "impl")]
35 imp: PathBuf,
36 #[arg(long)]
37 name: String,
38 /// Declared tags, e.g. algorithm=base,faithful=yes,bits=1,threads=1
39 #[arg(long)]
40 declare: String,
41 /// Comma list with a..b ranges. Default: the contract sweep.
42 #[arg(long)]
43 limits: Option<String>,
44 #[arg(long, default_value_t = 3)]
45 audit_passes: u32,
46 },
47 /// Trial protocol with receipt.
48 Run {
49 /// NAME=PATH, repeatable
50 #[arg(long = "impl", required = true)]
51 imps: Vec<String>,
52 /// NAME=algorithm=..,faithful=..,bits=..[,threads=..], one per impl
53 #[arg(long = "declare", required = true)]
54 declares: Vec<String>,
55 /// NAME=REPO@COMMIT, repeatable
56 #[arg(long = "source")]
57 sources: Vec<String>,
58 /// NAME=build command and flags, repeatable
59 #[arg(long = "build")]
60 builds: Vec<String>,
61 #[arg(long, default_value_t = 10)]
62 trials: u32,
63 #[arg(long, default_value_t = 1)]
64 warmup: u32,
65 #[arg(long, default_value_t = 1_000_000)]
66 limit: u64,
67 #[arg(long, default_value_t = 5.0)]
68 min_seconds: f64,
69 #[arg(long, default_value_t = 5)]
70 audit_passes: u32,
71 #[arg(long)]
72 evidence_dir: PathBuf,
73 #[arg(long)]
74 runner_commit: Option<String>,
75 #[arg(long)]
76 quiet_flag_file: Option<PathBuf>,
77 },
78}
79
80fn kv(s: &str) -> Result<(String, String), String> {
81 s.split_once('=').map(|(a, b)| (a.to_string(), b.to_string())).ok_or_else(|| format!("expected NAME=VALUE, got {s}"))
82}
83
84fn main() {
85 let code = match real_main() {
86 Ok(c) => c,
87 Err(e) => {
88 eprintln!("error: {e}");
89 64
90 }
91 };
92 std::process::exit(code);
93}
94
95fn real_main() -> Result<i32, String> {
96 let argv: Vec<String> = std::env::args().collect();
97 match Cli::parse().cmd {
98 Cmd::Verify { imp, name, declare, limits, audit_passes } => {
99 let limits = match limits {
100 Some(t) => parse_limits(&t)?,
101 None => default_sweep(),
102 };
103 let spec = ImplSpec { name, path: imp, tags: Tags::parse(&declare)? };
104 let out = verify(&spec, &limits, audit_passes);
105 println!(
106 "verify {}: {} limits, audit passes {}, {} failures{}",
107 spec.name,
108 out.checked,
109 audit_passes,
110 out.failures.len(),
111 if out.failures.is_empty() { " -> PASS" } else { " -> FAIL" }
112 );
113 if let Some(l) = limits.iter().find(|&&l| l == 1_000_000) {
114 println!("reference pi({l}) = {}", reference_count(*l));
115 }
116 Ok(if out.failures.is_empty() { 0 } else { 1 })
117 }
118 Cmd::Run { imps, declares, sources, builds, trials, warmup, limit, min_seconds, audit_passes, evidence_dir, runner_commit, quiet_flag_file } => {
119 let decl: BTreeMap<String, String> = declares.iter().map(|s| kv(s)).collect::<Result<_, _>>()?;
120 let mut specs = vec![];
121 for s in &imps {
122 let (name, path) = kv(s)?;
123 let tags = Tags::parse(decl.get(&name).ok_or(format!("no --declare for {name}"))?)?;
124 specs.push(ImplSpec { name, path: path.into(), tags });
125 }
126 let home = std::env::var("HOME").unwrap_or_default();
127 let args = RunArgs {
128 impls: specs,
129 trials,
130 warmup,
131 limit,
132 min_seconds,
133 audit_passes,
134 evidence_dir,
135 sources: sources.iter().map(|s| kv(s)).collect::<Result<_, _>>()?,
136 builds: builds.iter().map(|s| kv(s)).collect::<Result<_, _>>()?,
137 runner_commit,
138 quiet_file: quiet_flag_file.unwrap_or_else(|| PathBuf::from(home).join("workspace/.spark-quiet")),
139 argv,
140 };
141 let r = run(&args)?;
142 for l in &r.upstream_lines {
143 println!("{l}");
144 }
145 println!("\n{}", r.summary);
146 println!("verdict: {}", if r.pass { "PASS" } else { "FAIL" });
147 println!("receipt: {} (sha256 {})", r.receipt_path.display(), r.receipt_sha);
148 Ok(if r.pass { 0 } else { 1 })
149 }
150 }
151}