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 / src / bin / bench_orig3_judge.rs

196 lines · 6762 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//! ORIG-3 judge: applies the preregistered `orig3_selector.json` decision rule to selmain E output.
17//!
18//! Reads the per-record lines that the aien-train `selmain` evaluator (mode E) writes on fd 4.
19//! Native twin of `docs/orig3/judge.sh`: same input, byte-identical output, so either can be
20//! rerun over `evidence/ORIG3-SELECTOR/`.
21//!
22//! Usage: `bench_orig3_judge MLP AFFINE SHUFFLED UNTRAINED` (four `.records` files).
23//! Columns per line: `seq fam core M N model rule ref static near oracle c_model c_oracle
24//! c_rule c_ref c_static c_near`. Gated families: 2 (H1) and 3 (H2); core classes 0 and 1.
25//! Exit 0 after printing the verdict; exit 2 on unreadable or malformed input. Reads files
26//! only: no network, no GPU, no live server.
27
28use clap::Parser;
29use std::fs;
30use std::path::PathBuf;
31
32#[derive(Parser)]
33#[command(name = "bench_orig3_judge")]
34#[command(about = "Apply the ORIG-3 preregistered decision rule to selmain E per-record files")]
35struct Args {
36 /// Candidate (mlp_scratch) per-record file
37 mlp: PathBuf,
38 /// affine baseline per-record file
39 affine: PathBuf,
40 /// shuffled_control per-record file
41 shuffled: PathBuf,
42 /// untrained_control per-record file
43 untrained: PathBuf,
44}
45
46const CORES: usize = 2;
47const CRIT_60: u64 = 37;
48const CRIT_120: u64 = 70;
49
50/// Totals of one arm's file over the gated families, per core class.
51#[derive(Default, Clone, Copy)]
52struct Totals {
53 n: u64,
54 model: u64,
55 oracle: u64,
56 rule: u64,
57 reference: u64,
58 stat: u64,
59 near: u64,
60 win_rule: u64,
61 loss_rule: u64,
62 win_near: u64,
63 loss_near: u64,
64 win_stat: u64,
65 loss_stat: u64,
66}
67
68fn load(path: &PathBuf) -> Result<[Totals; CORES], String> {
69 let text = fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))?;
70 let mut t = [Totals::default(); CORES];
71 for (ln, line) in text.lines().enumerate() {
72 let w: Vec<u64> = line
73 .split_whitespace()
74 .map(|f| f.parse::<u64>())
75 .collect::<Result<_, _>>()
76 .map_err(|e| format!("{}:{}: {e}", path.display(), ln + 1))?;
77 if w.len() != 17 {
78 return Err(format!(
79 "{}:{}: {} columns, want 17",
80 path.display(),
81 ln + 1,
82 w.len()
83 ));
84 }
85 if w[1] != 2 && w[1] != 3 {
86 continue;
87 }
88 let core = w[2] as usize;
89 if core >= CORES {
90 continue;
91 }
92 let c = &mut t[core];
93 let (model, rule, reference, stat, near) = (w[11], w[13], w[14], w[15], w[16]);
94 c.n += 1;
95 c.model += model;
96 c.oracle += w[12];
97 c.rule += rule;
98 c.reference += reference;
99 c.stat += stat;
100 c.near += near;
101 c.win_rule += u64::from(model < rule);
102 c.loss_rule += u64::from(model > rule);
103 c.win_near += u64::from(model < near);
104 c.loss_near += u64::from(model > near);
105 c.win_stat += u64::from(model < stat);
106 c.loss_stat += u64::from(model > stat);
107 }
108 Ok(t)
109}
110
111fn ratio(a: u64, b: u64) -> f64 {
112 a as f64 / b as f64
113}
114
115fn main() {
116 let args = Args::parse();
117 let files = [args.mlp, args.affine, args.shuffled, args.untrained];
118 let mut arms = Vec::with_capacity(files.len());
119 for f in &files {
120 match load(f) {
121 Ok(t) => arms.push(t),
122 Err(e) => {
123 eprintln!("bench_orig3_judge: {e}");
124 std::process::exit(2);
125 }
126 }
127 }
128 let (mlp, aff, shuf, untr) = (arms[0], arms[1], arms[2], arms[3]);
129 let mut go = true;
130 let mut nogo = false;
131 for c in 0..CORES {
132 let m = mlp[c];
133 let crit = match m.n {
134 60 => Some(CRIT_60),
135 120 => Some(CRIT_120),
136 _ => None,
137 };
138 let best = m.stat.min(m.near);
139 let a = m.model as f64 <= 0.95 * m.rule as f64;
140 let b = m.model <= m.reference;
141 let cc = m.model <= aff[c].model;
142 let d = crit.is_some_and(|k| m.win_rule >= k);
143 let e = m.model <= best;
144 let shuf_a = shuf[c].model as f64 <= 0.95 * shuf[c].rule as f64;
145 let untr_a = untr[c].model as f64 <= 0.95 * untr[c].rule as f64;
146 let f = !(shuf_a || untr_a);
147 println!(
148 "core {c} n {} SEALED H1+H2: mlp/oracle {:.4} aff/oracle {:.4} rule/oracle {:.4} ref/oracle {:.4} static/oracle {:.4} retrieval/oracle {:.4} shuffled/oracle {:.4} untrained/oracle {:.4}",
149 m.n,
150 ratio(m.model, m.oracle),
151 ratio(aff[c].model, aff[c].oracle),
152 ratio(m.rule, m.oracle),
153 ratio(m.reference, m.oracle),
154 ratio(m.stat, m.oracle),
155 ratio(m.near, m.oracle),
156 ratio(shuf[c].model, shuf[c].oracle),
157 ratio(untr[c].model, untr[c].oracle),
158 );
159 println!(
160 "core {c} A(<=0.95 rule)={} [{:.3}] B(<=ref)={} [{:.3}] C(<=affine)={} [{:.4}] D(sign vs rule {}/{} >= {})={} E(<=min(static,retrieval))={} [{:.4}] F(controls fail A: shuffled {:.3} untrained {:.3})={}",
161 u8::from(a),
162 ratio(m.model, m.rule),
163 u8::from(b),
164 ratio(m.model, m.reference),
165 u8::from(cc),
166 ratio(m.model, aff[c].model),
167 m.win_rule,
168 m.loss_rule,
169 crit.map_or(-1, |k| k as i64),
170 u8::from(d),
171 u8::from(e),
172 ratio(m.model, best),
173 ratio(shuf[c].model, shuf[c].rule),
174 ratio(untr[c].model, untr[c].rule),
175 u8::from(f),
176 );
177 println!(
178 "core {c} reported: sign vs retrieval +{}/-{}, vs static +{}/-{}",
179 m.win_near, m.loss_near, m.win_stat, m.loss_stat
180 );
181 if !(a && b && cc && d && e && f) {
182 go = false;
183 }
184 if m.model as f64 > 1.01 * best as f64 {
185 nogo = true;
186 }
187 }
188 let verdict = if go {
189 "GO"
190 } else if nogo {
191 "NO-GO"
192 } else {
193 "INCONCLUSIVE"
194 };
195 println!("ORIG3_VERDICT={verdict}");
196}