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/benchmarks-mv/blob/main/tests/prereg_manifest.rs # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `benchmarks-mv / tests / prereg_manifest.rs` 301 lines ยท 9962 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 committed preregistration passes `bench_verify_prereg`; mutated copies of it are refused with exact defect lines. 17 18 use aien_benchmarks::prereg::check_prereg; 19 use serde_json::{json, Value}; 20 use std::fs; 21 use std::path::Path; 22 use std::process::Command; 23 24 const ROOT: &str = env!("CARGO_MANIFEST_DIR"); 25 const MANIFEST: &str = "manifests/prereg/si_genesis_e2.json"; 26 27 fn committed() -> Value { 28 let text = fs::read_to_string(Path::new(ROOT).join(MANIFEST)).expect("read prereg manifest"); 29 serde_json::from_str(&text).expect("prereg manifest is JSON") 30 } 31 32 fn defects(v: &Value) -> Vec { 33 let mut out = Vec::new(); 34 check_prereg("m.json", v, &mut out); 35 out.sort(); 36 out.dedup(); 37 out.iter().map(ToString::to_string).collect() 38 } 39 40 fn expect(v: &Value, want: &[&str]) { 41 let want: Vec = want.iter().map(|l| format!("m.json: {l}")).collect(); 42 assert_eq!(defects(v), want); 43 } 44 45 fn arm_index(v: &Value, id: &str) -> usize { 46 v["arms"] 47 .as_array() 48 .unwrap() 49 .iter() 50 .position(|a| a["id"] == id) 51 .unwrap() 52 } 53 54 fn run_bin(root: &Path, args: &[&str]) -> (i32, Vec) { 55 let out = Command::new(env!("CARGO_BIN_EXE_bench_verify_prereg")) 56 .arg("--root") 57 .arg(root) 58 .args(args) 59 .output() 60 .expect("run bench_verify_prereg"); 61 let lines = String::from_utf8(out.stdout) 62 .expect("utf-8 output") 63 .lines() 64 .map(str::to_string) 65 .collect(); 66 (out.status.code().expect("exit code"), lines) 67 } 68 69 #[test] 70 fn committed_prereg_passes() { 71 assert_eq!(defects(&committed()), Vec::::new()); 72 let (code, lines) = run_bin(Path::new(ROOT), &[]); 73 assert_eq!(lines, Vec::::new()); 74 assert_eq!(code, 0); 75 } 76 77 #[test] 78 fn refuses_missing_baseline_before_eval() { 79 let mut v = committed(); 80 v.as_object_mut().unwrap().remove("baseline_before_eval"); 81 expect( 82 &v, 83 &["baseline_before_eval: missing: baselines must be run and frozen before any evaluation"], 84 ); 85 } 86 87 #[test] 88 fn refuses_baseline_not_required_or_incomplete() { 89 let mut v = committed(); 90 v["baseline_before_eval"]["required"] = json!(false); 91 v["baseline_before_eval"]["baseline_arms"] = json!(["rules_engine", "si_experience_only"]); 92 expect( 93 &v, 94 &[ 95 "baseline_before_eval.baseline_arms: baseline arm \"frozen_pretrained_small\" is not listed", 96 "baseline_before_eval.baseline_arms: baseline arm \"retrieval_only\" is not listed", 97 "baseline_before_eval.baseline_arms: baseline arm \"teacher_27b\" is not listed", 98 "baseline_before_eval.baseline_arms: baseline arm \"teacher_35b\" is not listed", 99 "baseline_before_eval.baseline_arms[1]: arm \"si_experience_only\" does not have role baseline", 100 "baseline_before_eval.required: must be true", 101 ], 102 ); 103 } 104 105 #[test] 106 fn refuses_eval_or_training_before_baseline() { 107 let mut v = committed(); 108 v["phases"] = json!([ 109 "preregistration_freeze", 110 "candidate_training", 111 "sealed_eval", 112 "baseline_run" 113 ]); 114 expect( 115 &v, 116 &[ 117 "phases: baseline_run must come before sealed_eval", 118 "phases: candidate_training must come after baseline_run", 119 ], 120 ); 121 v["phases"] = json!(["preregistration_freeze", "sealed_eval"]); 122 expect(&v, &["phases: missing baseline_run"]); 123 } 124 125 #[test] 126 fn refuses_missing_or_empty_g_background() { 127 let mut v = committed(); 128 v["turing_profile"]["G"] 129 .as_object_mut() 130 .unwrap() 131 .remove("background"); 132 expect( 133 &v, 134 &["turing_profile.G.background: missing: G must declare every adviser, model and toolchain"], 135 ); 136 v["turing_profile"].as_object_mut().unwrap().remove("G"); 137 expect( 138 &v, 139 &["turing_profile.G.background: missing: G must declare every adviser, model and toolchain"], 140 ); 141 v["turing_profile"]["G"] = json!({"version": "g/1", "background": []}); 142 expect( 143 &v, 144 &["turing_profile.G.background: empty: G must declare every adviser, model and toolchain"], 145 ); 146 } 147 148 #[test] 149 fn refuses_adviser_missing_from_g() { 150 let mut v = committed(); 151 let bg = v["turing_profile"]["G"]["background"] 152 .as_array_mut() 153 .unwrap(); 154 bg.retain(|e| e["id"] != "model_35b"); 155 let mut want: Vec = [ 156 "teacher_35b", 157 "multi_teacher_verified", 158 "fusion_distilled_student", 159 "si_plus_teacher", 160 ] 161 .iter() 162 .map(|id| { 163 format!( 164 "arms[{}].background_refs: \"model_35b\" is not declared in turing_profile.G.background", 165 arm_index(&v, id) 166 ) 167 }) 168 .collect(); 169 want.sort(); 170 let want: Vec<&str> = want.iter().map(String::as_str).collect(); 171 expect(&v, &want); 172 173 let mut v = committed(); 174 let i = arm_index(&v, "teacher_27b"); 175 v["arms"][i]["background_refs"] = json!([]); 176 let line = format!( 177 "arms[{i}].background_refs: arm \"teacher_27b\" is pretrained or uses a teacher but declares no background" 178 ); 179 expect(&v, &[line.as_str()]); 180 } 181 182 #[test] 183 fn refuses_tj_without_measured_energy() { 184 let mut v = committed(); 185 v["turing_profile"]["tj"]["allowed"] = json!(true); 186 expect( 187 &v, 188 &["turing_profile.tj.allowed: T/J requires turing_profile.energy.status MEASURED"], 189 ); 190 v["turing_profile"]["energy"]["status"] = json!("MEASURED"); 191 expect(&v, &[]); 192 } 193 194 #[test] 195 fn frozen_prereg_needs_pinned_background() { 196 let mut v = committed(); 197 v["status"] = json!("FROZEN"); 198 let pending: Vec = v["turing_profile"]["G"]["background"] 199 .as_array() 200 .unwrap() 201 .iter() 202 .enumerate() 203 .filter(|(_, e)| e["revision"] == "PENDING_PIN") 204 .map(|(i, _)| i) 205 .collect(); 206 assert!( 207 !pending.is_empty(), 208 "the SCOPED manifest still has unpinned entries" 209 ); 210 let lines: Vec = pending 211 .iter() 212 .map(|i| { 213 format!( 214 "turing_profile.G.background[{i}].revision: PENDING_PIN is allowed only while status is SCOPED" 215 ) 216 }) 217 .collect(); 218 let want: Vec<&str> = lines.iter().map(String::as_str).collect(); 219 expect(&v, &want); 220 for i in &pending { 221 v["turing_profile"]["G"]["background"][*i]["revision"] = 222 json!(format!("sha256:{}", "0".repeat(64))); 223 } 224 expect(&v, &[]); 225 v["turing_profile"]["G"]["background"][0]["revision"] = json!("main"); 226 expect( 227 &v, 228 &["turing_profile.G.background[0].revision: \"main\" is not a commit id or sha256:<64 hex>"], 229 ); 230 } 231 232 #[test] 233 fn refuses_underpowered_or_inconsistent_sample_size() { 234 let mut v = committed(); 235 let s = &mut v["sample_size"]["studies"][0]; 236 s["tasks_planned"] = json!(40); 237 s["units_planned"] = json!(480); 238 s["effective_n_planned"] = json!(309); 239 expect( 240 &v, 241 &["sample_size.studies[0].effective_n_planned: underpowered: 309 < exact_min_effective_n 381"], 242 ); 243 let s = &mut v["sample_size"]["studies"][0]; 244 s["design_effect"] = json!(1.0); 245 s["alpha_per_contrast"] = json!(0.05); 246 expect( 247 &v, 248 &[ 249 "sample_size.studies[0].alpha_per_contrast: 0.05 * 4 contrasts exceeds alpha_familywise 0.05", 250 "sample_size.studies[0].design_effect: 1 != 1 + (units_per_cluster - 1) * icc_assumed = 1.55", 251 "sample_size.studies[0].effective_n_planned: underpowered: 309 < exact_min_effective_n 381", 252 ], 253 ); 254 } 255 256 #[test] 257 fn refuses_unsealed_heldout_and_placeholders() { 258 let mut v = committed(); 259 v["heldout"]["sealing"]["prediction_commit_before_reveal"] = json!(false); 260 v["stopping_rules"] = json!([]); 261 v["arms"][0]["description"] = json!("TBD"); 262 expect( 263 &v, 264 &[ 265 "arms[0].description: placeholder value \"TBD\"", 266 "heldout.sealing.prediction_commit_before_reveal: must be true", 267 "stopping_rules: must be a non-empty array", 268 ], 269 ); 270 } 271 272 #[test] 273 fn binary_refuses_bad_manifest_file() { 274 let dir = std::env::temp_dir().join(format!("bench_verify_prereg_{}", std::process::id())); 275 fs::create_dir_all(&dir).unwrap(); 276 let mut v = committed(); 277 v.as_object_mut().unwrap().remove("baseline_before_eval"); 278 v["turing_profile"]["G"]["background"] = json!([]); 279 fs::write(dir.join("bad.json"), serde_json::to_string(&v).unwrap()).unwrap(); 280 let (code, lines) = run_bin(&dir, &["bad.json"]); 281 fs::remove_dir_all(&dir).unwrap(); 282 assert_eq!( 283 lines, 284 vec![ 285 "bad.json: baseline_before_eval: missing: baselines must be run and frozen before any evaluation", 286 "bad.json: turing_profile.G.background: empty: G must declare every adviser, model and toolchain", 287 ] 288 ); 289 assert_eq!(code, 1); 290 } 291 292 #[test] 293 fn binary_refuses_empty_target() { 294 let dir = 295 std::env::temp_dir().join(format!("bench_verify_prereg_empty_{}", std::process::id())); 296 fs::create_dir_all(&dir).unwrap(); 297 let (code, lines) = run_bin(&dir, &["."]); 298 fs::remove_dir_all(&dir).unwrap(); 299 assert_eq!(lines, Vec::::new()); 300 assert_eq!(code, 1, "no manifest checked is not a pass"); 301 }