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 / tests / orig3_judge_v2.rs

219 lines · 7701 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//! The ORIG-3 v2 judge on synthetic inputs: every verdict of the frozen rule (GO, NO-GO,
17//! INCONCLUSIVE, INVALID), the overhead arithmetic, and refusal of malformed or inconsistent
18//! input. Synthetic numbers only; no record of any collection is used here.
19
20use std::fs;
21use std::path::{Path, PathBuf};
22use std::process::Command;
23
24/// Choices of one synthetic file: ps per call of the model's arm on every line.
25struct Case {
26 dir: PathBuf,
27}
28
29/// seq fam core M N model rule ref static near oracle c_model c_oracle c_rule c_ref c_static
30/// c_near press calls split cell. Arms: rule 2 (900), ref 0 (1000), static 4 (800), near 4
31/// (800), oracle 1 (700).
32fn line(seq: usize, core: usize, split: u64, model_ps: u64) -> String {
33 let arm = match model_ps {
34 700 => 1,
35 800 => 4,
36 900 => 2,
37 _ => 0,
38 };
39 format!(
40 "{seq} 5 {core} 64 64 {arm} 2 0 4 4 1 {model_ps} 700 900 1000 800 800 0 100 {split} 102\n"
41 )
42}
43
44fn records(model_ps: u64) -> String {
45 let mut s = String::new();
46 let mut seq = 0;
47 for core in 0..2 {
48 for k in 0..170 {
49 let split = if k < 20 { 1 } else { 2 };
50 s.push_str(&line(seq, core, split, model_ps));
51 seq += 1;
52 }
53 }
54 s
55}
56
57impl Case {
58 fn new(tag: &str) -> Case {
59 let dir = std::env::temp_dir().join(format!("orig3-judge-v2-{tag}-{}", std::process::id()));
60 fs::create_dir_all(&dir).unwrap();
61 Case { dir }
62 }
63 fn write(&self, name: &str, text: &str) -> PathBuf {
64 let p = self.dir.join(name);
65 fs::write(&p, text).unwrap();
66 p
67 }
68 /// Overhead runs: wall_us medians disabled, mlp, near over 3 reps; 1000 scored each.
69 fn overhead(&self, dis: u64, mlp: u64, near: u64) {
70 let mut s = String::new();
71 for rep in 1..=3 {
72 let j = rep as u64;
73 s.push_str(&format!(
74 "OVERHEAD run=disabled rep={rep} wall_us={}\n",
75 dis + j
76 ));
77 s.push_str(&format!("OVERHEAD run=mlp rep={rep} wall_us={}\n", mlp + j));
78 s.push_str(&format!(
79 "OVERHEAD run=near rep={rep} wall_us={}\n",
80 near + j
81 ));
82 }
83 self.write("summary.txt", &s);
84 let cost =
85 "COST records=1000 scored=1000 fallback=0 adv_cost=1 oracle_cost=1 incumbent_cost=1\n";
86 self.write("ovh_mlp_1.stdout", cost);
87 self.write("ovh_near_1.stdout", cost);
88 }
89 fn run(&self, mlp: &Path, shuf: &Path, untr: &Path) -> (i32, String, String) {
90 let out = Command::new(env!("CARGO_BIN_EXE_bench_orig3_judge_v2"))
91 .arg("--mlp")
92 .arg(mlp)
93 .arg("--shuffled")
94 .arg(shuf)
95 .arg("--untrained")
96 .arg(untr)
97 .arg("--overhead-dir")
98 .arg(&self.dir)
99 .args(["--train-wall-ms", "3000", "--collect-wall-ms", "120000"])
100 .output()
101 .expect("run bench_orig3_judge_v2");
102 (
103 out.status.code().expect("exit code"),
104 String::from_utf8(out.stdout).unwrap(),
105 String::from_utf8(out.stderr).unwrap(),
106 )
107 }
108}
109
110impl Drop for Case {
111 fn drop(&mut self) {
112 fs::remove_dir_all(&self.dir).ok();
113 }
114}
115
116#[test]
117fn better_choices_without_overhead_is_go() {
118 let c = Case::new("go");
119 c.overhead(1000, 1000, 1000);
120 let m = c.write("m", &records(700));
121 let bad = c.write("b", &records(1000));
122 let (code, out, _) = c.run(&m, &bad, &bad);
123 assert_eq!(code, 0, "{out}");
124 assert!(
125 out.contains("core=0 heldout_n=150 validation_n=20"),
126 "{out}"
127 );
128 assert!(out.contains("heuristic=best_static"), "{out}");
129 assert!(out.contains("per_decision_ps mlp=0 retrieval=0"), "{out}");
130 // (3000 + 120000) ms = 1.23e14 ps over a saving of 10000 ps per decision.
131 assert!(out.contains("break_even_decisions=12300000000 "), "{out}");
132 assert!(out.ends_with("ORIG3_V2_VERDICT=GO\n"), "{out}");
133}
134
135#[test]
136fn overhead_larger_than_the_saving_is_nogo() {
137 let c = Case::new("nogo");
138 // 100 ms over 1000 decisions = 100 us = 1e8 ps per decision for the scorer path.
139 c.overhead(1000, 101_000, 1000);
140 let m = c.write("m", &records(700));
141 let bad = c.write("b", &records(1000));
142 let (code, out, _) = c.run(&m, &bad, &bad);
143 assert_eq!(code, 0, "{out}");
144 assert!(
145 out.contains("per_decision_ps mlp=100000000 retrieval=0"),
146 "{out}"
147 );
148 assert!(
149 out.contains("break_even_calls_per_decision=1000000"),
150 "{out}"
151 );
152 assert!(out.ends_with("ORIG3_V2_VERDICT=NO-GO\n"), "{out}");
153}
154
155#[test]
156fn parity_with_retrieval_is_inconclusive() {
157 let c = Case::new("inc");
158 c.overhead(1000, 1000, 1000);
159 let m = c.write("m", &records(800));
160 let bad = c.write("b", &records(1000));
161 let (code, out, _) = c.run(&m, &bad, &bad);
162 assert_eq!(code, 0, "{out}");
163 assert!(out.contains("break_even_decisions=none"), "{out}");
164 assert!(out.ends_with("ORIG3_V2_VERDICT=INCONCLUSIVE\n"), "{out}");
165}
166
167#[test]
168fn a_control_meeting_the_primary_criterion_makes_the_run_invalid() {
169 let c = Case::new("invalid");
170 c.overhead(1000, 1000, 1000);
171 let m = c.write("m", &records(700));
172 let bad = c.write("b", &records(1000));
173 let (code, out, _) = c.run(&m, &m, &bad);
174 assert_eq!(code, 0, "{out}");
175 assert!(out.ends_with("ORIG3_V2_VERDICT=INVALID\n"), "{out}");
176}
177
178#[test]
179fn refuses_malformed_and_inconsistent_input() {
180 let c = Case::new("bad");
181 c.overhead(1000, 1000, 1000);
182 let m = c.write("m", &records(700));
183 let short = c.write(
184 "s",
185 "1 5 0 64 64 1 2 0 4 4 1 700 700 900 1000 800 800 0 100 2\n",
186 );
187 let (code, out, err) = c.run(&short, &m, &m);
188 assert_eq!(code, 2);
189 assert_eq!(out, "");
190 assert!(err.contains("20 columns, want 21"), "{err}");
191 let other = c.write(
192 "o",
193 &records(700).replacen(" 900 1000 800 800 ", " 901 1000 800 800 ", 1),
194 );
195 let (code, _, err) = c.run(&m, &other, &m);
196 assert_eq!(code, 2);
197 assert!(err.contains("differs between files"), "{err}");
198}
199
200#[test]
201fn committed_v2_evidence_reproduces_judge_out() {
202 let dir = Path::new(env!("CARGO_MANIFEST_DIR")).join("evidence/ORIG3-SELECTOR-v2");
203 let out = Command::new(env!("CARGO_BIN_EXE_bench_orig3_judge_v2"))
204 .arg("--mlp")
205 .arg(dir.join("v2-mlp.records"))
206 .arg("--shuffled")
207 .arg(dir.join("v2-shuffled.records"))
208 .arg("--untrained")
209 .arg(dir.join("v2-untrained.records"))
210 .arg("--overhead-dir")
211 .arg(dir.join("overhead"))
212 .args(["--train-wall-ms", "10017", "--collect-wall-ms", "70575"])
213 .output()
214 .expect("run bench_orig3_judge_v2");
215 let want = fs::read_to_string(dir.join("judge.out")).expect("judge.out");
216 assert_eq!(String::from_utf8(out.stdout).unwrap(), want);
217 assert_eq!(out.status.code(), Some(0));
218 assert!(want.ends_with("ORIG3_V2_VERDICT=NO-GO\n"));
219}