AntonioJun commited on
Commit
a30bb0a
·
verified ·
1 Parent(s): 8fe041c

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. harness/A/__init__.py +6 -0
  2. harness/A/__pycache__/__init__.cpython-311.pyc +0 -0
  3. harness/A/__pycache__/launch.cpython-311.pyc +0 -0
  4. harness/A/__pycache__/run.cpython-311.pyc +0 -0
  5. harness/A/__pycache__/sweep.cpython-311.pyc +0 -0
  6. harness/A/launch.py +3 -2
  7. harness/A/run.py +14 -6
  8. harness/A/sweep.py +16 -4
  9. harness/B/__pycache__/launch.cpython-311.pyc +0 -0
  10. harness/B/__pycache__/run.cpython-311.pyc +0 -0
  11. harness/B/__pycache__/sweep.cpython-311.pyc +0 -0
  12. harness/B/launch.py +17 -5
  13. harness/B/run.py +33 -13
  14. harness/B/sweep.py +11 -2
  15. harness/C/__pycache__/launch.cpython-311.pyc +0 -0
  16. harness/C/__pycache__/run.cpython-311.pyc +0 -0
  17. harness/C/__pycache__/sweep.cpython-311.pyc +0 -0
  18. harness/C/launch.py +17 -5
  19. harness/C/run.py +33 -12
  20. harness/D/__pycache__/launch.cpython-311.pyc +0 -0
  21. harness/D/__pycache__/run.cpython-311.pyc +0 -0
  22. harness/D/__pycache__/sweep.cpython-311.pyc +0 -0
  23. harness/D/run.py +36 -9
  24. harness/E/__pycache__/launch.cpython-311.pyc +0 -0
  25. harness/E/run.py +218 -0
  26. tests/test_C/test_run.py +9 -4
  27. tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc +0 -0
  28. tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323676 +0 -0
  29. tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807 +0 -0
  30. tests/test_D/test_run.py +41 -5
  31. tests/test_E/__init__.py +0 -0
  32. tests/test_E/__pycache__/__init__.cpython-311.pyc +0 -0
  33. tests/test_E/__pycache__/test_launch.cpython-311-pytest-8.3.5.pyc +0 -0
  34. tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc +0 -0
  35. tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc.323676 +0 -0
  36. tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc.323807 +0 -0
  37. tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc +0 -0
  38. tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323676 +0 -0
  39. tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807 +0 -0
  40. tests/test_E/__pycache__/test_sweep.cpython-311-pytest-8.3.5.pyc +0 -0
  41. tests/test_E/test_launch.py +53 -0
  42. tests/test_E/test_prompts.py +48 -0
  43. tests/test_E/test_run.py +84 -0
  44. tests/test_E/test_sweep.py +36 -0
  45. tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc +0 -0
  46. tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc +0 -0
  47. tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-8.3.5.pyc +0 -0
  48. tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-8.3.5.pyc +0 -0
  49. tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-8.3.5.pyc +0 -0
  50. tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-8.3.5.pyc +0 -0
harness/A/__init__.py CHANGED
@@ -47,6 +47,12 @@ DO_SAMPLE = False
47
  EXTENDED_MAX_NEW_TOKENS = 2048
48
  FORCE_ANSWER_PROMPT = "\nFinal answer:"
49
 
 
 
 
 
 
 
50
  MODEL_PATHS = {
51
  "qwen3.5-4b": MODELS_ROOT / "qwen3.5-4b",
52
  "qwen3.5-2b": MODELS_ROOT / "qwen3.5-2b",
 
47
  EXTENDED_MAX_NEW_TOKENS = 2048
48
  FORCE_ANSWER_PROMPT = "\nFinal answer:"
49
 
50
+ # The generation-protocol axis every harness sweeps: "base" is the paper's fixed
51
+ # 16-token protocol (plain answer()), "extended" is the 2048-token answer_extended
52
+ # protocol above. A results-path segment on every harness, so the two protocols'
53
+ # records can never collide on disk.
54
+ PROTOCOLS = ("base", "extended")
55
+
56
  MODEL_PATHS = {
57
  "qwen3.5-4b": MODELS_ROOT / "qwen3.5-4b",
58
  "qwen3.5-2b": MODELS_ROOT / "qwen3.5-2b",
harness/A/__pycache__/__init__.cpython-311.pyc CHANGED
Binary files a/harness/A/__pycache__/__init__.cpython-311.pyc and b/harness/A/__pycache__/__init__.cpython-311.pyc differ
 
harness/A/__pycache__/launch.cpython-311.pyc CHANGED
Binary files a/harness/A/__pycache__/launch.cpython-311.pyc and b/harness/A/__pycache__/launch.cpython-311.pyc differ
 
harness/A/__pycache__/run.cpython-311.pyc CHANGED
Binary files a/harness/A/__pycache__/run.cpython-311.pyc and b/harness/A/__pycache__/run.cpython-311.pyc differ
 
harness/A/__pycache__/sweep.cpython-311.pyc CHANGED
Binary files a/harness/A/__pycache__/sweep.cpython-311.pyc and b/harness/A/__pycache__/sweep.cpython-311.pyc differ
 
harness/A/launch.py CHANGED
@@ -103,9 +103,10 @@ def launch(
103
  extended=False, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
104
  ):
105
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
106
- condition = f"{model}/{frame_selection}/{frame_count}"
 
107
  run = _load_run_module()
108
- root = run.results_dir_for(model, frame_selection, frame_count, results_dir)
109
  pending = []
110
  completed = 0
111
  for scene in selected:
 
103
  extended=False, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
104
  ):
105
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
106
+ protocol = "extended" if extended else "base"
107
+ condition = f"{model}/{protocol}/{frame_selection}/{frame_count}"
108
  run = _load_run_module()
109
+ root = run.results_dir_for(model, protocol, frame_selection, frame_count, results_dir)
110
  pending = []
111
  completed = 0
112
  for scene in selected:
harness/A/run.py CHANGED
@@ -93,11 +93,13 @@ def load_questions(jsonl_path=None, scene=None, scenes=None, limit=None):
93
  return rows
94
 
95
 
96
- def results_dir_for(model, frame_selection, frame_count, results_dir=None):
97
- """Return the result root isolated by model + frame-selection + frame-count."""
 
 
98
  if results_dir is not None:
99
  return Path(results_dir)
100
- return RESULTS_DIR / model / frame_selection / str(frame_count)
101
 
102
 
103
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, frame_info):
@@ -108,7 +110,11 @@ def _build_record(row, prompt, answer, metric_name, score, model, model_path, fr
108
  "device": answer["device"],
109
  "dtype": answer["dtype"],
110
  "library_versions": answer["library_versions"],
111
- "condition": f"{frame_info['frame_selection']}:{frame_info['frame_count']}",
 
 
 
 
112
  "frame_selection": frame_info["frame_selection"],
113
  "frame_count": frame_info["frame_count"],
114
  "video_path": frame_info["video_path"],
@@ -153,7 +159,8 @@ def write_question_result(
153
  row, prompt, answer, metric_name, score, model, model_path, frame_info
154
  )
155
  root = results_dir_for(
156
- model, frame_info["frame_selection"], frame_info["frame_count"], results_dir
 
157
  )
158
  scene_dir = root / record["scene"]
159
  scene_dir.mkdir(parents=True, exist_ok=True)
@@ -239,6 +246,7 @@ def run(
239
  )["vsibench_score"]
240
  metric_name, score = _scalar_score(row["question_type"], score_doc)
241
  frame_info = {
 
242
  "video_path": cached["video_path"],
243
  "frame_timestamps": cached["frame_timestamps"],
244
  "frame_indices": cached["frame_indices"],
@@ -279,7 +287,7 @@ def main():
279
  parser.add_argument(
280
  "--results-dir",
281
  default=None,
282
- help="override the default results/A/<model>/<selection>/<frames> root",
283
  )
284
  parser.add_argument(
285
  "--no-write",
 
93
  return rows
94
 
95
 
96
+ def results_dir_for(model, protocol, frame_selection, frame_count, results_dir=None):
97
+ """Return the result root isolated by model + protocol + frame-selection +
98
+ frame-count. ``protocol`` is "base" (16-token) or "extended" (2048-token) -- a real
99
+ path segment, so the two protocols' records can never collide on disk."""
100
  if results_dir is not None:
101
  return Path(results_dir)
102
+ return RESULTS_DIR / model / protocol / frame_selection / str(frame_count)
103
 
104
 
105
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, frame_info):
 
110
  "device": answer["device"],
111
  "dtype": answer["dtype"],
112
  "library_versions": answer["library_versions"],
113
+ "condition": (
114
+ f"{frame_info['protocol']}:{frame_info['frame_selection']}:"
115
+ f"{frame_info['frame_count']}"
116
+ ),
117
+ "protocol": frame_info["protocol"],
118
  "frame_selection": frame_info["frame_selection"],
119
  "frame_count": frame_info["frame_count"],
120
  "video_path": frame_info["video_path"],
 
159
  row, prompt, answer, metric_name, score, model, model_path, frame_info
160
  )
161
  root = results_dir_for(
162
+ model, frame_info["protocol"], frame_info["frame_selection"],
163
+ frame_info["frame_count"], results_dir,
164
  )
165
  scene_dir = root / record["scene"]
166
  scene_dir.mkdir(parents=True, exist_ok=True)
 
246
  )["vsibench_score"]
247
  metric_name, score = _scalar_score(row["question_type"], score_doc)
248
  frame_info = {
249
+ "protocol": "extended" if extended else "base",
250
  "video_path": cached["video_path"],
251
  "frame_timestamps": cached["frame_timestamps"],
252
  "frame_indices": cached["frame_indices"],
 
287
  parser.add_argument(
288
  "--results-dir",
289
  default=None,
290
+ help="override the default results/A/<model>/<protocol>/<selection>/<frames> root",
291
  )
292
  parser.add_argument(
293
  "--no-write",
harness/A/sweep.py CHANGED
@@ -65,14 +65,21 @@ def build_plan(models, frame_selections, frame_counts):
65
  ]
66
 
67
 
68
- def sweep(models, frame_selections, frame_counts, selected_scenes, results_dir=None, rebuild=False):
 
 
 
69
  """Run every (model, frame_selection, frame_count) triple across all visible GPUs."""
70
  plan = build_plan(models, frame_selections, frame_counts)
 
71
  for index, (model, frame_selection, frame_count) in enumerate(plan, start=1):
72
- print(f"=== sweep {index}/{len(plan)}: {model}/{frame_selection}/{frame_count} ===", flush=True)
 
 
 
73
  harness_launch.launch(
74
  model, frame_selection, frame_count, selected_scenes,
75
- results_dir=results_dir, rebuild=rebuild,
76
  )
77
 
78
 
@@ -96,6 +103,11 @@ def main():
96
  )
97
  parser.add_argument("--results-dir", default=None)
98
  parser.add_argument("--rebuild", action="store_true")
 
 
 
 
 
99
  args = parser.parse_args()
100
  if args.scene and args.scenes:
101
  parser.error("positional scene and --scenes cannot be used together")
@@ -119,7 +131,7 @@ def main():
119
 
120
  sweep(
121
  models, frame_selections, frame_counts, selected,
122
- results_dir=args.results_dir, rebuild=args.rebuild,
123
  )
124
 
125
 
 
65
  ]
66
 
67
 
68
+ def sweep(
69
+ models, frame_selections, frame_counts, selected_scenes, results_dir=None, rebuild=False,
70
+ extended=False,
71
+ ):
72
  """Run every (model, frame_selection, frame_count) triple across all visible GPUs."""
73
  plan = build_plan(models, frame_selections, frame_counts)
74
+ protocol = "extended" if extended else "base"
75
  for index, (model, frame_selection, frame_count) in enumerate(plan, start=1):
76
+ print(
77
+ f"=== sweep {index}/{len(plan)}: {model}/{protocol}/{frame_selection}/{frame_count} ===",
78
+ flush=True,
79
+ )
80
  harness_launch.launch(
81
  model, frame_selection, frame_count, selected_scenes,
82
+ results_dir=results_dir, rebuild=rebuild, extended=extended,
83
  )
84
 
85
 
 
103
  )
104
  parser.add_argument("--results-dir", default=None)
105
  parser.add_argument("--rebuild", action="store_true")
106
+ parser.add_argument(
107
+ "--extended", action="store_true",
108
+ help="run the whole sweep under the extended 2048-token protocol instead of the "
109
+ "fixed 16-token VSI-Bench protocol (the same flag harness.A.run/launch take)",
110
+ )
111
  args = parser.parse_args()
112
  if args.scene and args.scenes:
113
  parser.error("positional scene and --scenes cannot be used together")
 
131
 
132
  sweep(
133
  models, frame_selections, frame_counts, selected,
134
+ results_dir=args.results_dir, rebuild=args.rebuild, extended=args.extended,
135
  )
136
 
137
 
harness/B/__pycache__/launch.cpython-311.pyc CHANGED
Binary files a/harness/B/__pycache__/launch.cpython-311.pyc and b/harness/B/__pycache__/launch.cpython-311.pyc differ
 
harness/B/__pycache__/run.cpython-311.pyc CHANGED
Binary files a/harness/B/__pycache__/run.cpython-311.pyc and b/harness/B/__pycache__/run.cpython-311.pyc differ
 
harness/B/__pycache__/sweep.cpython-311.pyc CHANGED
Binary files a/harness/B/__pycache__/sweep.cpython-311.pyc and b/harness/B/__pycache__/sweep.cpython-311.pyc differ
 
harness/B/launch.py CHANGED
@@ -50,7 +50,7 @@ def _load_run_module():
50
 
51
  def _worker(
52
  tasks, results, model, spatial_code_format, input_selection, frame_count, depth, tracking,
53
- results_dir, gpu, cpu_threads, reasoning_budget, force_budget,
54
  ):
55
  if gpu is not None:
56
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
@@ -82,6 +82,7 @@ def _worker(
82
  scene=scene,
83
  results_dir=results_dir,
84
  adapter=adapter,
 
85
  reasoning_budget=reasoning_budget,
86
  force_budget=force_budget,
87
  )
@@ -98,13 +99,18 @@ def _worker(
98
  def launch(
99
  model, spatial_code_format, input_selection, frame_count, selected,
100
  depth=DEFAULT_DEPTH, tracking=DEFAULT_TRACKING, results_dir=None, rebuild=False,
101
- reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
102
  ):
103
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
104
- condition = f"{model}/{spatial_code_format}/{depth}/{tracking}/{input_selection}/{frame_count}"
 
 
 
 
105
  run = _load_run_module()
106
  root = run.results_dir_for(
107
- model, spatial_code_format, depth, tracking, input_selection, frame_count, results_dir
 
108
  )
109
  pending = []
110
  completed = 0
@@ -142,7 +148,8 @@ def launch(
142
  target=_worker,
143
  args=(
144
  tasks, results, model, spatial_code_format, input_selection, frame_count,
145
- depth, tracking, results_dir, gpu, cpu_threads, reasoning_budget, force_budget,
 
146
  ),
147
  )
148
  for gpu in assignments
@@ -189,6 +196,10 @@ def main():
189
  parser.add_argument("--tracking", default=DEFAULT_TRACKING, choices=TRACKING_MODES)
190
  parser.add_argument("--results-dir", default=None)
191
  parser.add_argument("--rebuild", action="store_true")
 
 
 
 
192
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
193
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
194
  args = parser.parse_args()
@@ -210,6 +221,7 @@ def main():
210
  launch(
211
  args.model, args.spatial_code_format, args.input_selection, args.frames, selected,
212
  depth=args.depth, tracking=args.tracking, results_dir=args.results_dir, rebuild=args.rebuild,
 
213
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
214
  )
215
 
 
50
 
51
  def _worker(
52
  tasks, results, model, spatial_code_format, input_selection, frame_count, depth, tracking,
53
+ results_dir, gpu, cpu_threads, extended, reasoning_budget, force_budget,
54
  ):
55
  if gpu is not None:
56
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
 
82
  scene=scene,
83
  results_dir=results_dir,
84
  adapter=adapter,
85
+ extended=extended,
86
  reasoning_budget=reasoning_budget,
87
  force_budget=force_budget,
88
  )
 
99
  def launch(
100
  model, spatial_code_format, input_selection, frame_count, selected,
101
  depth=DEFAULT_DEPTH, tracking=DEFAULT_TRACKING, results_dir=None, rebuild=False,
102
+ extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
103
  ):
104
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
105
+ protocol = "extended" if extended else "base"
106
+ condition = (
107
+ f"{model}/{protocol}/{spatial_code_format}/{depth}/{tracking}"
108
+ f"/{input_selection}/{frame_count}"
109
+ )
110
  run = _load_run_module()
111
  root = run.results_dir_for(
112
+ model, protocol, spatial_code_format, depth, tracking, input_selection, frame_count,
113
+ results_dir,
114
  )
115
  pending = []
116
  completed = 0
 
148
  target=_worker,
149
  args=(
150
  tasks, results, model, spatial_code_format, input_selection, frame_count,
151
+ depth, tracking, results_dir, gpu, cpu_threads, extended, reasoning_budget,
152
+ force_budget,
153
  ),
154
  )
155
  for gpu in assignments
 
196
  parser.add_argument("--tracking", default=DEFAULT_TRACKING, choices=TRACKING_MODES)
197
  parser.add_argument("--results-dir", default=None)
198
  parser.add_argument("--rebuild", action="store_true")
199
+ parser.add_argument(
200
+ "--base-protocol", action="store_true",
201
+ help="run harness.A's exact fixed 16-token protocol instead of the extended default",
202
+ )
203
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
204
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
205
  args = parser.parse_args()
 
221
  launch(
222
  args.model, args.spatial_code_format, args.input_selection, args.frames, selected,
223
  depth=args.depth, tracking=args.tracking, results_dir=args.results_dir, rebuild=args.rebuild,
224
+ extended=not args.base_protocol,
225
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
226
  )
227
 
harness/B/run.py CHANGED
@@ -39,14 +39,17 @@ from harness.B import spatial_codes # noqa: E402
39
 
40
 
41
  def results_dir_for(
42
- model, spatial_code_format, depth, tracking, input_selection, frame_count, results_dir=None
 
43
  ):
44
- """Return the result root isolated by model + spatial-code-format + depth +
45
- tracking + input + frames."""
 
 
46
  if results_dir is not None:
47
  return Path(results_dir)
48
  return (
49
- RESULTS_DIR / model / spatial_code_format / depth / tracking
50
  / input_selection / str(frame_count)
51
  )
52
 
@@ -60,10 +63,11 @@ def _build_record(row, prompt, answer, metric_name, score, model, model_path, co
60
  "dtype": answer["dtype"],
61
  "library_versions": answer["library_versions"],
62
  "condition": (
63
- f"{code_info['spatial_code_format']}:{code_info['depth']}:"
64
- f"{code_info['tracking']}:{code_info['input_selection']}:"
65
- f"{code_info['frame_count']}"
66
  ),
 
67
  "spatial_code_format": code_info["spatial_code_format"],
68
  "input_selection": code_info["input_selection"],
69
  "frame_count": code_info["frame_count"],
@@ -108,6 +112,7 @@ def write_question_result(
108
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
109
  root = results_dir_for(
110
  model,
 
111
  code_info["spatial_code_format"],
112
  code_info["depth"],
113
  code_info["tracking"],
@@ -138,6 +143,7 @@ def run(
138
  results_dir=None,
139
  write_results=True,
140
  adapter=None,
 
141
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
142
  force_budget=MAX_NEW_TOKENS,
143
  ):
@@ -147,9 +153,11 @@ def run(
147
 
148
  Uses ``adapter.answer_extended`` (a large ``reasoning_budget`` first pass, with a
149
  short forced second call only if the model doesn't conclude within it) as the
150
- standing default protocol -- not harness.A's fixed 16-token budget -- since working
151
- through a full spatial-code JSON before answering benefits from more room than a
152
- short visual caption does.
 
 
153
 
154
  Pass a pre-loaded ``adapter`` (as harness.B.launch's persistent per-GPU workers do)
155
  to reuse one already-loaded model across many calls; the caller then owns unloading
@@ -176,8 +184,12 @@ def run(
176
  prompt = code_prompts.build_prompt(
177
  cached["code"], row["question_type"], row["question"], row.get("options")
178
  )
179
- answer = adapter.answer_extended(
180
- [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
 
 
 
 
181
  )
182
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
183
  score_doc = vsi_official_eval.vsibench_process_results(
@@ -185,6 +197,7 @@ def run(
185
  )["vsibench_score"]
186
  metric_name, score = _scalar_score(row["question_type"], score_doc)
187
  code_info = {
 
188
  "spatial_code_format": spatial_code_format,
189
  "input_selection": input_selection,
190
  "frame_count": frame_count,
@@ -229,12 +242,18 @@ def main():
229
  parser.add_argument("--device", default="cuda")
230
  parser.add_argument(
231
  "--results-dir", default=None,
232
- help="override the default results/B/<model>/<format>/<depth>/<tracking>/<input>/<frames> root",
 
233
  )
234
  parser.add_argument(
235
  "--no-write", action="store_true",
236
  help="skip writing per-question JSON files; print/score only",
237
  )
 
 
 
 
 
238
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
239
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
240
  args = parser.parse_args()
@@ -257,6 +276,7 @@ def main():
257
  device=args.device,
258
  results_dir=args.results_dir,
259
  write_results=not args.no_write,
 
260
  reasoning_budget=args.reasoning_budget,
261
  force_budget=args.force_budget,
262
  )
 
39
 
40
 
41
  def results_dir_for(
42
+ model, protocol, spatial_code_format, depth, tracking, input_selection, frame_count,
43
+ results_dir=None,
44
  ):
45
+ """Return the result root isolated by model + protocol + spatial-code-format +
46
+ depth + tracking + input + frames. ``protocol`` is "base" (16-token) or "extended"
47
+ (2048-token) -- a real path segment, so the two protocols' records can never collide
48
+ on disk."""
49
  if results_dir is not None:
50
  return Path(results_dir)
51
  return (
52
+ RESULTS_DIR / model / protocol / spatial_code_format / depth / tracking
53
  / input_selection / str(frame_count)
54
  )
55
 
 
63
  "dtype": answer["dtype"],
64
  "library_versions": answer["library_versions"],
65
  "condition": (
66
+ f"{code_info['protocol']}:{code_info['spatial_code_format']}:"
67
+ f"{code_info['depth']}:{code_info['tracking']}:"
68
+ f"{code_info['input_selection']}:{code_info['frame_count']}"
69
  ),
70
+ "protocol": code_info["protocol"],
71
  "spatial_code_format": code_info["spatial_code_format"],
72
  "input_selection": code_info["input_selection"],
73
  "frame_count": code_info["frame_count"],
 
112
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
113
  root = results_dir_for(
114
  model,
115
+ code_info["protocol"],
116
  code_info["spatial_code_format"],
117
  code_info["depth"],
118
  code_info["tracking"],
 
143
  results_dir=None,
144
  write_results=True,
145
  adapter=None,
146
+ extended=True,
147
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
148
  force_budget=MAX_NEW_TOKENS,
149
  ):
 
153
 
154
  Uses ``adapter.answer_extended`` (a large ``reasoning_budget`` first pass, with a
155
  short forced second call only if the model doesn't conclude within it) as the
156
+ standing default protocol -- since working through a full spatial-code JSON before
157
+ answering benefits from more room than a short visual caption does.
158
+ ``extended=False`` runs harness.A's exact fixed 16-token base protocol instead
159
+ (plain ``adapter.answer``), so the protocol x representation grid can be measured
160
+ with the identical generation mechanism in every cell.
161
 
162
  Pass a pre-loaded ``adapter`` (as harness.B.launch's persistent per-GPU workers do)
163
  to reuse one already-loaded model across many calls; the caller then owns unloading
 
184
  prompt = code_prompts.build_prompt(
185
  cached["code"], row["question_type"], row["question"], row.get("options")
186
  )
187
+ answer = (
188
+ adapter.answer_extended(
189
+ [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
190
+ )
191
+ if extended
192
+ else adapter.answer([], prompt)
193
  )
194
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
195
  score_doc = vsi_official_eval.vsibench_process_results(
 
197
  )["vsibench_score"]
198
  metric_name, score = _scalar_score(row["question_type"], score_doc)
199
  code_info = {
200
+ "protocol": "extended" if extended else "base",
201
  "spatial_code_format": spatial_code_format,
202
  "input_selection": input_selection,
203
  "frame_count": frame_count,
 
242
  parser.add_argument("--device", default="cuda")
243
  parser.add_argument(
244
  "--results-dir", default=None,
245
+ help="override the default results/B/<model>/<protocol>/<format>/"
246
+ "<depth>/<tracking>/<input>/<frames> root",
247
  )
248
  parser.add_argument(
249
  "--no-write", action="store_true",
250
  help="skip writing per-question JSON files; print/score only",
251
  )
252
+ parser.add_argument(
253
+ "--base-protocol", action="store_true",
254
+ help="run harness.A's exact fixed 16-token protocol (plain answer()) instead of "
255
+ "the extended 2048-token default",
256
+ )
257
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
258
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
259
  args = parser.parse_args()
 
276
  device=args.device,
277
  results_dir=args.results_dir,
278
  write_results=not args.no_write,
279
+ extended=not args.base_protocol,
280
  reasoning_budget=args.reasoning_budget,
281
  force_budget=args.force_budget,
282
  )
harness/B/sweep.py CHANGED
@@ -52,20 +52,23 @@ def build_plan(models, spatial_code_formats, input_selections, frame_counts, dep
52
  def sweep(
53
  models, spatial_code_formats, input_selections, frame_counts, selected_scenes,
54
  depths=(DEFAULT_DEPTH,), trackings=(DEFAULT_TRACKING,), results_dir=None, rebuild=False,
 
55
  ):
56
  """Run every sweep combination across all visible GPUs."""
57
  plan = build_plan(models, spatial_code_formats, input_selections, frame_counts, depths, trackings)
 
58
  for index, (model, spatial_code_format, depth, tracking, input_selection, frame_count) in enumerate(
59
  plan, start=1
60
  ):
61
  print(
62
- f"=== sweep {index}/{len(plan)}: "
63
- f"{model}/{spatial_code_format}/{depth}/{tracking}/{input_selection}/{frame_count} ===",
64
  flush=True,
65
  )
66
  harness_launch.launch(
67
  model, spatial_code_format, input_selection, frame_count, selected_scenes,
68
  depth=depth, tracking=tracking, results_dir=results_dir, rebuild=rebuild,
 
69
  )
70
 
71
 
@@ -100,6 +103,11 @@ def main():
100
  )
101
  parser.add_argument("--results-dir", default=None)
102
  parser.add_argument("--rebuild", action="store_true")
 
 
 
 
 
103
  args = parser.parse_args()
104
  if args.scene and args.scenes:
105
  parser.error("positional scene and --scenes cannot be used together")
@@ -132,6 +140,7 @@ def main():
132
  models, spatial_code_formats, input_selections, frame_counts, selected,
133
  depths=depths, trackings=trackings,
134
  results_dir=args.results_dir, rebuild=args.rebuild,
 
135
  )
136
 
137
 
 
52
  def sweep(
53
  models, spatial_code_formats, input_selections, frame_counts, selected_scenes,
54
  depths=(DEFAULT_DEPTH,), trackings=(DEFAULT_TRACKING,), results_dir=None, rebuild=False,
55
+ extended=True,
56
  ):
57
  """Run every sweep combination across all visible GPUs."""
58
  plan = build_plan(models, spatial_code_formats, input_selections, frame_counts, depths, trackings)
59
+ protocol = "extended" if extended else "base"
60
  for index, (model, spatial_code_format, depth, tracking, input_selection, frame_count) in enumerate(
61
  plan, start=1
62
  ):
63
  print(
64
+ f"=== sweep {index}/{len(plan)}: {model}/{protocol}/"
65
+ f"{spatial_code_format}/{depth}/{tracking}/{input_selection}/{frame_count} ===",
66
  flush=True,
67
  )
68
  harness_launch.launch(
69
  model, spatial_code_format, input_selection, frame_count, selected_scenes,
70
  depth=depth, tracking=tracking, results_dir=results_dir, rebuild=rebuild,
71
+ extended=extended,
72
  )
73
 
74
 
 
103
  )
104
  parser.add_argument("--results-dir", default=None)
105
  parser.add_argument("--rebuild", action="store_true")
106
+ parser.add_argument(
107
+ "--base-protocol", action="store_true",
108
+ help="run the whole sweep under harness.A's exact fixed 16-token protocol "
109
+ "instead of the extended 2048-token default",
110
+ )
111
  args = parser.parse_args()
112
  if args.scene and args.scenes:
113
  parser.error("positional scene and --scenes cannot be used together")
 
140
  models, spatial_code_formats, input_selections, frame_counts, selected,
141
  depths=depths, trackings=trackings,
142
  results_dir=args.results_dir, rebuild=args.rebuild,
143
+ extended=not args.base_protocol,
144
  )
145
 
146
 
harness/C/__pycache__/launch.cpython-311.pyc CHANGED
Binary files a/harness/C/__pycache__/launch.cpython-311.pyc and b/harness/C/__pycache__/launch.cpython-311.pyc differ
 
harness/C/__pycache__/run.cpython-311.pyc CHANGED
Binary files a/harness/C/__pycache__/run.cpython-311.pyc and b/harness/C/__pycache__/run.cpython-311.pyc differ
 
harness/C/__pycache__/sweep.cpython-311.pyc CHANGED
Binary files a/harness/C/__pycache__/sweep.cpython-311.pyc and b/harness/C/__pycache__/sweep.cpython-311.pyc differ
 
harness/C/launch.py CHANGED
@@ -50,7 +50,7 @@ def _load_run_module():
50
 
51
  def _worker(
52
  tasks, results, model, spatial_code_format, input_selection, frame_count, depth, tracking,
53
- results_dir, gpu, cpu_threads, reasoning_budget, force_budget,
54
  ):
55
  if gpu is not None:
56
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
@@ -85,6 +85,7 @@ def _worker(
85
  scene=scene,
86
  results_dir=results_dir,
87
  adapter=adapter,
 
88
  reasoning_budget=reasoning_budget,
89
  force_budget=force_budget,
90
  )
@@ -101,13 +102,18 @@ def _worker(
101
  def launch(
102
  model, spatial_code_format, input_selection, frame_count, selected,
103
  depth=DEFAULT_DEPTH, tracking=DEFAULT_TRACKING, results_dir=None, rebuild=False,
104
- reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
105
  ):
106
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
107
- condition = f"{model}/{spatial_code_format}/{depth}/{tracking}/{input_selection}/{frame_count}"
 
 
 
 
108
  run = _load_run_module()
109
  root = run.results_dir_for(
110
- model, spatial_code_format, depth, tracking, input_selection, frame_count, results_dir
 
111
  )
112
  pending = []
113
  completed = 0
@@ -145,7 +151,8 @@ def launch(
145
  target=_worker,
146
  args=(
147
  tasks, results, model, spatial_code_format, input_selection, frame_count,
148
- depth, tracking, results_dir, gpu, cpu_threads, reasoning_budget, force_budget,
 
149
  ),
150
  )
151
  for gpu in assignments
@@ -192,6 +199,10 @@ def main():
192
  parser.add_argument("--tracking", default=DEFAULT_TRACKING, choices=TRACKING_MODES)
193
  parser.add_argument("--results-dir", default=None)
194
  parser.add_argument("--rebuild", action="store_true")
 
 
 
 
195
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
196
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
197
  args = parser.parse_args()
@@ -213,6 +224,7 @@ def main():
213
  launch(
214
  args.model, args.spatial_code_format, args.input_selection, args.frames, selected,
215
  depth=args.depth, tracking=args.tracking, results_dir=args.results_dir, rebuild=args.rebuild,
 
216
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
217
  )
218
 
 
50
 
51
  def _worker(
52
  tasks, results, model, spatial_code_format, input_selection, frame_count, depth, tracking,
53
+ results_dir, gpu, cpu_threads, extended, reasoning_budget, force_budget,
54
  ):
55
  if gpu is not None:
56
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
 
85
  scene=scene,
86
  results_dir=results_dir,
87
  adapter=adapter,
88
+ extended=extended,
89
  reasoning_budget=reasoning_budget,
90
  force_budget=force_budget,
91
  )
 
102
  def launch(
103
  model, spatial_code_format, input_selection, frame_count, selected,
104
  depth=DEFAULT_DEPTH, tracking=DEFAULT_TRACKING, results_dir=None, rebuild=False,
105
+ extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
106
  ):
107
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
108
+ protocol = "extended" if extended else "base"
109
+ condition = (
110
+ f"{model}/{protocol}/{spatial_code_format}/{depth}/{tracking}"
111
+ f"/{input_selection}/{frame_count}"
112
+ )
113
  run = _load_run_module()
114
  root = run.results_dir_for(
115
+ model, protocol, spatial_code_format, depth, tracking, input_selection, frame_count,
116
+ results_dir,
117
  )
118
  pending = []
119
  completed = 0
 
151
  target=_worker,
152
  args=(
153
  tasks, results, model, spatial_code_format, input_selection, frame_count,
154
+ depth, tracking, results_dir, gpu, cpu_threads, extended, reasoning_budget,
155
+ force_budget,
156
  ),
157
  )
158
  for gpu in assignments
 
199
  parser.add_argument("--tracking", default=DEFAULT_TRACKING, choices=TRACKING_MODES)
200
  parser.add_argument("--results-dir", default=None)
201
  parser.add_argument("--rebuild", action="store_true")
202
+ parser.add_argument(
203
+ "--base-protocol", action="store_true",
204
+ help="run harness.A's exact fixed 16-token protocol instead of the extended default",
205
+ )
206
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
207
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
208
  args = parser.parse_args()
 
224
  launch(
225
  args.model, args.spatial_code_format, args.input_selection, args.frames, selected,
226
  depth=args.depth, tracking=args.tracking, results_dir=args.results_dir, rebuild=args.rebuild,
227
+ extended=not args.base_protocol,
228
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
229
  )
230
 
harness/C/run.py CHANGED
@@ -40,14 +40,17 @@ from harness.C import prompts as combined_prompts # noqa: E402
40
 
41
 
42
  def results_dir_for(
43
- model, spatial_code_format, depth, tracking, input_selection, frame_count, results_dir=None
 
44
  ):
45
- """Return the result root isolated by model + spatial-code-format + depth +
46
- tracking + input + frames."""
 
 
47
  if results_dir is not None:
48
  return Path(results_dir)
49
  return (
50
- RESULTS_DIR / model / spatial_code_format / depth / tracking
51
  / input_selection / str(frame_count)
52
  )
53
 
@@ -61,10 +64,11 @@ def _build_record(row, prompt, answer, metric_name, score, model, model_path, so
61
  "dtype": answer["dtype"],
62
  "library_versions": answer["library_versions"],
63
  "condition": (
64
- f"{source_info['spatial_code_format']}:{source_info['depth']}:"
65
- f"{source_info['tracking']}:{source_info['input_selection']}:"
66
- f"{source_info['frame_count']}"
67
  ),
 
68
  "spatial_code_format": source_info["spatial_code_format"],
69
  "input_selection": source_info["input_selection"],
70
  "frame_count": source_info["frame_count"],
@@ -112,6 +116,7 @@ def write_question_result(
112
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, source_info)
113
  root = results_dir_for(
114
  model,
 
115
  source_info["spatial_code_format"],
116
  source_info["depth"],
117
  source_info["tracking"],
@@ -142,6 +147,7 @@ def run(
142
  results_dir=None,
143
  write_results=True,
144
  adapter=None,
 
145
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
146
  force_budget=MAX_NEW_TOKENS,
147
  ):
@@ -152,7 +158,10 @@ def run(
152
  Uses ``adapter.answer_extended`` (a large ``reasoning_budget`` first pass, with a
153
  short forced second call only if the model doesn't conclude within it) as the
154
  standing default protocol, same as harness.B, since C combines the same complex
155
- spatial-code JSON with the video frames.
 
 
 
156
 
157
  Pass a pre-loaded ``adapter`` (as harness.C.launch's persistent per-GPU workers do)
158
  to reuse one already-loaded model across many calls; the caller then owns unloading
@@ -190,9 +199,13 @@ def run(
190
  prompt = combined_prompts.build_prompt(
191
  cached["code"], row["question_type"], row["question"], row.get("options")
192
  )
193
- answer = adapter.answer_extended(
194
- cached["frame_images"], prompt,
195
- reasoning_budget=reasoning_budget, force_budget=force_budget,
 
 
 
 
196
  )
197
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
198
  score_doc = vsi_official_eval.vsibench_process_results(
@@ -200,6 +213,7 @@ def run(
200
  )["vsibench_score"]
201
  metric_name, score = _scalar_score(row["question_type"], score_doc)
202
  source_info = {
 
203
  "spatial_code_format": spatial_code_format,
204
  "input_selection": input_selection,
205
  "frame_count": frame_count,
@@ -247,12 +261,18 @@ def main():
247
  parser.add_argument("--device", default="cuda")
248
  parser.add_argument(
249
  "--results-dir", default=None,
250
- help="override the default results/C/<model>/<format>/<depth>/<tracking>/<input>/<frames> root",
 
251
  )
252
  parser.add_argument(
253
  "--no-write", action="store_true",
254
  help="skip writing per-question JSON files; print/score only",
255
  )
 
 
 
 
 
256
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
257
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
258
  args = parser.parse_args()
@@ -275,6 +295,7 @@ def main():
275
  device=args.device,
276
  results_dir=args.results_dir,
277
  write_results=not args.no_write,
 
278
  reasoning_budget=args.reasoning_budget,
279
  force_budget=args.force_budget,
280
  )
 
40
 
41
 
42
  def results_dir_for(
43
+ model, protocol, spatial_code_format, depth, tracking, input_selection, frame_count,
44
+ results_dir=None,
45
  ):
46
+ """Return the result root isolated by model + protocol + spatial-code-format +
47
+ depth + tracking + input + frames. ``protocol`` is "base" (16-token) or "extended"
48
+ (2048-token) -- a real path segment, so the two protocols' records can never collide
49
+ on disk."""
50
  if results_dir is not None:
51
  return Path(results_dir)
52
  return (
53
+ RESULTS_DIR / model / protocol / spatial_code_format / depth / tracking
54
  / input_selection / str(frame_count)
55
  )
56
 
 
64
  "dtype": answer["dtype"],
65
  "library_versions": answer["library_versions"],
66
  "condition": (
67
+ f"{source_info['protocol']}:{source_info['spatial_code_format']}:"
68
+ f"{source_info['depth']}:{source_info['tracking']}:"
69
+ f"{source_info['input_selection']}:{source_info['frame_count']}"
70
  ),
71
+ "protocol": source_info["protocol"],
72
  "spatial_code_format": source_info["spatial_code_format"],
73
  "input_selection": source_info["input_selection"],
74
  "frame_count": source_info["frame_count"],
 
116
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, source_info)
117
  root = results_dir_for(
118
  model,
119
+ source_info["protocol"],
120
  source_info["spatial_code_format"],
121
  source_info["depth"],
122
  source_info["tracking"],
 
147
  results_dir=None,
148
  write_results=True,
149
  adapter=None,
150
+ extended=True,
151
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
152
  force_budget=MAX_NEW_TOKENS,
153
  ):
 
158
  Uses ``adapter.answer_extended`` (a large ``reasoning_budget`` first pass, with a
159
  short forced second call only if the model doesn't conclude within it) as the
160
  standing default protocol, same as harness.B, since C combines the same complex
161
+ spatial-code JSON with the video frames. ``extended=False`` runs harness.A's exact
162
+ fixed 16-token base protocol instead (plain ``adapter.answer``), so the protocol x
163
+ representation grid can be measured with the identical generation mechanism in
164
+ every cell.
165
 
166
  Pass a pre-loaded ``adapter`` (as harness.C.launch's persistent per-GPU workers do)
167
  to reuse one already-loaded model across many calls; the caller then owns unloading
 
199
  prompt = combined_prompts.build_prompt(
200
  cached["code"], row["question_type"], row["question"], row.get("options")
201
  )
202
+ answer = (
203
+ adapter.answer_extended(
204
+ cached["frame_images"], prompt,
205
+ reasoning_budget=reasoning_budget, force_budget=force_budget,
206
+ )
207
+ if extended
208
+ else adapter.answer(cached["frame_images"], prompt)
209
  )
210
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
211
  score_doc = vsi_official_eval.vsibench_process_results(
 
213
  )["vsibench_score"]
214
  metric_name, score = _scalar_score(row["question_type"], score_doc)
215
  source_info = {
216
+ "protocol": "extended" if extended else "base",
217
  "spatial_code_format": spatial_code_format,
218
  "input_selection": input_selection,
219
  "frame_count": frame_count,
 
261
  parser.add_argument("--device", default="cuda")
262
  parser.add_argument(
263
  "--results-dir", default=None,
264
+ help="override the default results/C/<model>/<protocol>/<format>/"
265
+ "<depth>/<tracking>/<input>/<frames> root",
266
  )
267
  parser.add_argument(
268
  "--no-write", action="store_true",
269
  help="skip writing per-question JSON files; print/score only",
270
  )
271
+ parser.add_argument(
272
+ "--base-protocol", action="store_true",
273
+ help="run harness.A's exact fixed 16-token protocol (plain answer()) instead of "
274
+ "the extended 2048-token default",
275
+ )
276
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
277
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
278
  args = parser.parse_args()
 
295
  device=args.device,
296
  results_dir=args.results_dir,
297
  write_results=not args.no_write,
298
+ extended=not args.base_protocol,
299
  reasoning_budget=args.reasoning_budget,
300
  force_budget=args.force_budget,
301
  )
harness/D/__pycache__/launch.cpython-311.pyc CHANGED
Binary files a/harness/D/__pycache__/launch.cpython-311.pyc and b/harness/D/__pycache__/launch.cpython-311.pyc differ
 
harness/D/__pycache__/run.cpython-311.pyc CHANGED
Binary files a/harness/D/__pycache__/run.cpython-311.pyc and b/harness/D/__pycache__/run.cpython-311.pyc differ
 
harness/D/__pycache__/sweep.cpython-311.pyc CHANGED
Binary files a/harness/D/__pycache__/sweep.cpython-311.pyc and b/harness/D/__pycache__/sweep.cpython-311.pyc differ
 
harness/D/run.py CHANGED
@@ -28,11 +28,13 @@ from harness.D import prompts as code_prompts # noqa: E402
28
  from harness.D import spatial_codes # noqa: E402
29
 
30
 
31
- def results_dir_for(model, spatial_code_format, results_dir=None):
32
- """Return the result root isolated by model + spatial-code-format."""
 
 
33
  if results_dir is not None:
34
  return Path(results_dir)
35
- return RESULTS_DIR / model / spatial_code_format
36
 
37
 
38
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info):
@@ -43,7 +45,8 @@ def _build_record(row, prompt, answer, metric_name, score, model, model_path, co
43
  "device": answer["device"],
44
  "dtype": answer["dtype"],
45
  "library_versions": answer["library_versions"],
46
- "condition": code_info["spatial_code_format"],
 
47
  "spatial_code_format": code_info["spatial_code_format"],
48
  "spatial_code_path": code_info["spatial_code_path"],
49
  "scene": row["scene_name"],
@@ -82,7 +85,9 @@ def write_question_result(
82
  ):
83
  """Write one question's full, untruncated result record. Return (path, record)."""
84
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
85
- root = results_dir_for(model, code_info["spatial_code_format"], results_dir)
 
 
86
  scene_dir = root / record["scene"]
87
  scene_dir.mkdir(parents=True, exist_ok=True)
88
  path = scene_dir / f"{row['id']}.json"
@@ -102,8 +107,10 @@ def run(
102
  results_dir=None,
103
  write_results=True,
104
  adapter=None,
 
105
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
106
  force_budget=MAX_NEW_TOKENS,
 
107
  ):
108
  """Answer every matching question with one model, given its scene's GROUND-TRUTH
109
  spatial code as text (no video frames). Each question's full record is written to
@@ -111,7 +118,14 @@ def run(
111
 
112
  Uses ``adapter.answer_extended`` as the standing default protocol, same as
113
  harness.B -- working through a full spatial-code JSON before answering benefits
114
- from more room than a short visual caption does.
 
 
 
 
 
 
 
115
 
116
  Pass a pre-loaded ``adapter`` (as harness.D.launch's persistent per-GPU workers do)
117
  to reuse one already-loaded model across many calls; the caller then owns unloading
@@ -131,13 +145,19 @@ def run(
131
  scene_id = row["scene_name"]
132
  if scene_id not in code_cache:
133
  code, path = spatial_codes.load_spatial_code(scene_id, spatial_code_format)
 
 
134
  code_cache[scene_id] = {"code": code, "path": path}
135
  cached = code_cache[scene_id]
136
  prompt = code_prompts.build_prompt(
137
  cached["code"], row["question_type"], row["question"], row.get("options")
138
  )
139
- answer = adapter.answer_extended(
140
- [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
 
 
 
 
141
  )
142
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
143
  score_doc = vsi_official_eval.vsibench_process_results(
@@ -145,6 +165,7 @@ def run(
145
  )["vsibench_score"]
146
  metric_name, score = _scalar_score(row["question_type"], score_doc)
147
  code_info = {
 
148
  "spatial_code_format": spatial_code_format,
149
  "spatial_code_path": cached["path"],
150
  }
@@ -178,12 +199,17 @@ def main():
178
  parser.add_argument("--device", default="cuda")
179
  parser.add_argument(
180
  "--results-dir", default=None,
181
- help="override the default results/D/<model>/<format> root",
182
  )
183
  parser.add_argument(
184
  "--no-write", action="store_true",
185
  help="skip writing per-question JSON files; print/score only",
186
  )
 
 
 
 
 
187
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
188
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
189
  args = parser.parse_args()
@@ -200,6 +226,7 @@ def main():
200
  device=args.device,
201
  results_dir=args.results_dir,
202
  write_results=not args.no_write,
 
203
  reasoning_budget=args.reasoning_budget,
204
  force_budget=args.force_budget,
205
  )
 
28
  from harness.D import spatial_codes # noqa: E402
29
 
30
 
31
+ def results_dir_for(model, protocol, spatial_code_format, results_dir=None):
32
+ """Return the result root isolated by model + protocol + spatial-code-format.
33
+ ``protocol`` is "base" (16-token) or "extended" (2048-token) -- a real path
34
+ segment, so the two protocols' records can never collide on disk."""
35
  if results_dir is not None:
36
  return Path(results_dir)
37
+ return RESULTS_DIR / model / protocol / spatial_code_format
38
 
39
 
40
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info):
 
45
  "device": answer["device"],
46
  "dtype": answer["dtype"],
47
  "library_versions": answer["library_versions"],
48
+ "condition": f"{code_info['protocol']}:{code_info['spatial_code_format']}",
49
+ "protocol": code_info["protocol"],
50
  "spatial_code_format": code_info["spatial_code_format"],
51
  "spatial_code_path": code_info["spatial_code_path"],
52
  "scene": row["scene_name"],
 
85
  ):
86
  """Write one question's full, untruncated result record. Return (path, record)."""
87
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
88
+ root = results_dir_for(
89
+ model, code_info["protocol"], code_info["spatial_code_format"], results_dir
90
+ )
91
  scene_dir = root / record["scene"]
92
  scene_dir.mkdir(parents=True, exist_ok=True)
93
  path = scene_dir / f"{row['id']}.json"
 
107
  results_dir=None,
108
  write_results=True,
109
  adapter=None,
110
+ extended=True,
111
  reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
112
  force_budget=MAX_NEW_TOKENS,
113
+ code_transform=None,
114
  ):
115
  """Answer every matching question with one model, given its scene's GROUND-TRUTH
116
  spatial code as text (no video frames). Each question's full record is written to
 
118
 
119
  Uses ``adapter.answer_extended`` as the standing default protocol, same as
120
  harness.B -- working through a full spatial-code JSON before answering benefits
121
+ from more room than a short visual caption does. ``extended=False`` runs
122
+ harness.A's exact fixed 16-token base protocol instead (plain ``adapter.answer``).
123
+
124
+ ``code_transform``, when given, is called as ``code_transform(code, scene_id,
125
+ spatial_code_format)`` on each freshly loaded code and its return value is what
126
+ the prompt is built from -- the hook the corruption module (README Theme 8) uses
127
+ to run corrupted codes through this EXACT prompt/adapter path instead of a
128
+ duplicated one. ``None`` (the default) leaves behavior byte-identical to before.
129
 
130
  Pass a pre-loaded ``adapter`` (as harness.D.launch's persistent per-GPU workers do)
131
  to reuse one already-loaded model across many calls; the caller then owns unloading
 
145
  scene_id = row["scene_name"]
146
  if scene_id not in code_cache:
147
  code, path = spatial_codes.load_spatial_code(scene_id, spatial_code_format)
148
+ if code_transform is not None:
149
+ code = code_transform(code, scene_id, spatial_code_format)
150
  code_cache[scene_id] = {"code": code, "path": path}
151
  cached = code_cache[scene_id]
152
  prompt = code_prompts.build_prompt(
153
  cached["code"], row["question_type"], row["question"], row.get("options")
154
  )
155
+ answer = (
156
+ adapter.answer_extended(
157
+ [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
158
+ )
159
+ if extended
160
+ else adapter.answer([], prompt)
161
  )
162
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
163
  score_doc = vsi_official_eval.vsibench_process_results(
 
165
  )["vsibench_score"]
166
  metric_name, score = _scalar_score(row["question_type"], score_doc)
167
  code_info = {
168
+ "protocol": "extended" if extended else "base",
169
  "spatial_code_format": spatial_code_format,
170
  "spatial_code_path": cached["path"],
171
  }
 
199
  parser.add_argument("--device", default="cuda")
200
  parser.add_argument(
201
  "--results-dir", default=None,
202
+ help="override the default results/D/<model>/<protocol>/<format> root",
203
  )
204
  parser.add_argument(
205
  "--no-write", action="store_true",
206
  help="skip writing per-question JSON files; print/score only",
207
  )
208
+ parser.add_argument(
209
+ "--base-protocol", action="store_true",
210
+ help="run harness.A's exact fixed 16-token protocol (plain answer()) instead of "
211
+ "the extended 2048-token default",
212
+ )
213
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
214
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
215
  args = parser.parse_args()
 
226
  device=args.device,
227
  results_dir=args.results_dir,
228
  write_results=not args.no_write,
229
+ extended=not args.base_protocol,
230
  reasoning_budget=args.reasoning_budget,
231
  force_budget=args.force_budget,
232
  )
harness/E/__pycache__/launch.cpython-311.pyc ADDED
Binary file (11.2 kB). View file
 
harness/E/run.py ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run one VLM over VSI-Bench questions completely blind -- question text only.
2
+
3
+ Writes one JSON file per question in the identical shape harness.A/B/C/D use -- with no
4
+ frame or spatial-code provenance fields at all, since E receives no scene input of any
5
+ kind. Scoring reuses the same real, unmodified official scorer every harness uses.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import json
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ WORKSPACE_ROOT = Path(__file__).resolve().parent.parent.parent
16
+ if str(WORKSPACE_ROOT) not in sys.path:
17
+ sys.path.insert(0, str(WORKSPACE_ROOT))
18
+
19
+ from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
20
+ from harness.A import models as vlm_models # noqa: E402
21
+ from harness.A.run import _scalar_score, load_questions, vsi_official_eval # noqa: E402
22
+ from harness.E import RESULTS_DIR # noqa: E402
23
+ from harness.E import prompts as blind_prompts # noqa: E402
24
+
25
+
26
+ def results_dir_for(model, protocol, results_dir=None):
27
+ """Return the result root isolated by model + protocol. ``protocol`` is "base"
28
+ (16-token) or "extended" (2048-token) -- a real path segment, so the two protocols'
29
+ records can never collide on disk."""
30
+ if results_dir is not None:
31
+ return Path(results_dir)
32
+ return RESULTS_DIR / model / protocol
33
+
34
+
35
+ def _build_record(row, prompt, answer, metric_name, score, model, model_path, protocol):
36
+ """Assemble one question's full, untruncated result record (nothing summarized)."""
37
+ return {
38
+ "model": model,
39
+ "model_path": str(model_path),
40
+ "device": answer["device"],
41
+ "dtype": answer["dtype"],
42
+ "library_versions": answer["library_versions"],
43
+ "condition": protocol,
44
+ "protocol": protocol,
45
+ "scene": row["scene_name"],
46
+ "dataset": row.get("dataset"),
47
+ "question_id": row["id"],
48
+ "question_type": row["question_type"],
49
+ "question": row["question"],
50
+ "options": row.get("options"),
51
+ "full_prompt": prompt,
52
+ "rendered_prompt": answer["prompt_text"],
53
+ "answer_expected": row["ground_truth"],
54
+ "answer_given": answer["answer_text"],
55
+ "answer_raw": answer["answer_raw"],
56
+ "input_token_count": answer["input_token_count"],
57
+ "vision_input_shapes": answer["vision_input_shapes"],
58
+ "output_token_ids": answer["output_token_ids"],
59
+ "output_token_count": answer["output_token_count"],
60
+ "hit_token_limit": answer["hit_token_limit"],
61
+ "eos_token_ids": answer["eos_token_ids"],
62
+ "generation_seconds": answer["generation_seconds"],
63
+ "generation_config": answer["generation_config"],
64
+ "reasoning_text": answer.get("reasoning_text"),
65
+ "reasoning_raw": answer.get("reasoning_raw"),
66
+ "reasoning_token_ids": answer.get("reasoning_token_ids"),
67
+ "reasoning_token_count": answer.get("reasoning_token_count"),
68
+ "reasoning_hit_limit": answer.get("reasoning_hit_limit"),
69
+ "forced": answer.get("forced", False),
70
+ "forced_input_token_count": answer.get("forced_input_token_count"),
71
+ "metric": metric_name,
72
+ "score": score,
73
+ }
74
+
75
+
76
+ def write_question_result(
77
+ row, prompt, answer, metric_name, score, model, model_path, protocol, results_dir=None
78
+ ):
79
+ """Write one question's full, untruncated result record. Return (path, record)."""
80
+ record = _build_record(row, prompt, answer, metric_name, score, model, model_path, protocol)
81
+ root = results_dir_for(model, protocol, results_dir)
82
+ scene_dir = root / record["scene"]
83
+ scene_dir.mkdir(parents=True, exist_ok=True)
84
+ path = scene_dir / f"{row['id']}.json"
85
+ with path.open("w", encoding="utf-8") as stream:
86
+ json.dump(record, stream, indent=1)
87
+ return path, record
88
+
89
+
90
+ def run(
91
+ model,
92
+ scene=None,
93
+ scenes=None,
94
+ limit=None,
95
+ device="cuda",
96
+ jsonl_path=None,
97
+ results_dir=None,
98
+ write_results=True,
99
+ adapter=None,
100
+ extended=False,
101
+ reasoning_budget=EXTENDED_MAX_NEW_TOKENS,
102
+ force_budget=MAX_NEW_TOKENS,
103
+ ):
104
+ """Answer every matching question with one model, completely blind (question text
105
+ only, no frames, no spatial code). Each question's full record is written to its
106
+ own JSON file as soon as it is answered (unless ``write_results=False``).
107
+
108
+ Base 16-token protocol by default, exactly like harness.A; ``extended=True``
109
+ switches to the same ``answer_extended`` protocol every other harness supports.
110
+
111
+ Pass a pre-loaded ``adapter`` (as harness.E.launch's persistent per-GPU workers do)
112
+ to reuse one already-loaded model across many calls; the caller then owns unloading
113
+ it. Without one, ``run`` loads and unloads its own adapter, same as harness.A.
114
+ """
115
+ rows = load_questions(jsonl_path, scene, scenes, limit)
116
+ if not rows:
117
+ return []
118
+ owns_adapter = adapter is None
119
+ if owns_adapter:
120
+ adapter = vlm_models.get_adapter(model)
121
+ adapter.load_model(device)
122
+ protocol = "extended" if extended else "base"
123
+ results = []
124
+ try:
125
+ for row in rows:
126
+ prompt = blind_prompts.build_prompt(
127
+ row["question_type"], row["question"], row.get("options")
128
+ )
129
+ answer = (
130
+ adapter.answer_extended(
131
+ [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
132
+ )
133
+ if extended
134
+ else adapter.answer([], prompt)
135
+ )
136
+ doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
137
+ score_doc = vsi_official_eval.vsibench_process_results(
138
+ doc, [answer["answer_text"]]
139
+ )["vsibench_score"]
140
+ metric_name, score = _scalar_score(row["question_type"], score_doc)
141
+ if write_results:
142
+ path, record = write_question_result(
143
+ row, prompt, answer, metric_name, score, model, adapter.model_path,
144
+ protocol, results_dir,
145
+ )
146
+ else:
147
+ path = None
148
+ record = _build_record(
149
+ row, prompt, answer, metric_name, score, model, adapter.model_path, protocol
150
+ )
151
+ record["result_path"] = str(path) if path else None
152
+ results.append(record)
153
+ finally:
154
+ if owns_adapter:
155
+ adapter.unload()
156
+ return results
157
+
158
+
159
+ def main():
160
+ parser = argparse.ArgumentParser()
161
+ parser.add_argument("--model", required=True, choices=vlm_models.available_models())
162
+ parser.add_argument("--scene", default=None, help="restrict to one VSI-Bench scene")
163
+ parser.add_argument("--limit", type=int, default=None, help="cap the number of questions")
164
+ parser.add_argument("--device", default="cuda")
165
+ parser.add_argument(
166
+ "--results-dir", default=None,
167
+ help="override the default results/E/<model>/<protocol> root",
168
+ )
169
+ parser.add_argument(
170
+ "--no-write", action="store_true",
171
+ help="skip writing per-question JSON files; print/score only",
172
+ )
173
+ parser.add_argument(
174
+ "--extended", action="store_true",
175
+ help=(
176
+ f"use a {EXTENDED_MAX_NEW_TOKENS}-token reasoning budget instead of the fixed "
177
+ f"{MAX_NEW_TOKENS}-token VSI-Bench protocol, with a short forced second call "
178
+ "only if the model doesn't conclude within it"
179
+ ),
180
+ )
181
+ parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
182
+ parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
183
+ args = parser.parse_args()
184
+ if args.reasoning_budget < 1:
185
+ parser.error("--reasoning-budget must be positive")
186
+ if args.force_budget < 1:
187
+ parser.error("--force-budget must be positive")
188
+
189
+ results = run(
190
+ args.model,
191
+ scene=args.scene,
192
+ limit=args.limit,
193
+ device=args.device,
194
+ results_dir=args.results_dir,
195
+ write_results=not args.no_write,
196
+ extended=args.extended,
197
+ reasoning_budget=args.reasoning_budget,
198
+ force_budget=args.force_budget,
199
+ )
200
+
201
+ for result in results:
202
+ print(
203
+ f"[{result['scene']}#{result['question_id']}] {result['question_type']}: "
204
+ f"pred={result['answer_given']!r} gt={result['answer_expected']!r} "
205
+ f"score={result['score']} ({result['generation_seconds']:.2f}s) -> "
206
+ f"{result['result_path']}"
207
+ )
208
+ if results:
209
+ mean_score = sum(r["score"] for r in results) / len(results)
210
+ total_seconds = sum(r["generation_seconds"] for r in results)
211
+ print(
212
+ f"\n{len(results)} questions, mean vsibench_score={mean_score:.4f}, "
213
+ f"total generation time={total_seconds:.1f}s"
214
+ )
215
+
216
+
217
+ if __name__ == "__main__":
218
+ main()
tests/test_C/test_run.py CHANGED
@@ -40,6 +40,7 @@ _FAKE_ROW = {
40
  }
41
 
42
  _FAKE_SOURCE_INFO = {
 
43
  "spatial_code_format": "explicit",
44
  "input_selection": "selective",
45
  "frame_count": 64,
@@ -53,15 +54,18 @@ _FAKE_SOURCE_INFO = {
53
 
54
 
55
  def test_results_dir_for_matches_established_dimension_nesting():
56
- root = harness_run.results_dir_for("qwen3.5-4b", "compact", "metric", "tracking", "uniform", 32)
 
 
57
  assert root == (
58
- C.RESULTS_DIR / "qwen3.5-4b" / "compact" / "metric" / "tracking" / "uniform" / "32"
 
59
  )
60
 
61
 
62
  def test_results_dir_for_honors_explicit_override(tmp_path):
63
  root = harness_run.results_dir_for(
64
- "qwen3.5-4b", "explicit", "relative", "no tracking", "selective", 16, tmp_path
65
  )
66
  assert root == tmp_path
67
 
@@ -86,7 +90,8 @@ def test_build_record_carries_both_frame_and_spatial_code_provenance():
86
  assert record["question"] == "How many chairs?"
87
  assert record["answer_given"] == "4"
88
  assert record["vision_input_shapes"] == _FAKE_ANSWER["vision_input_shapes"]
89
- assert record["condition"] == "explicit:metric:tracking:selective:64"
 
90
  assert record["score"] == 1.0
91
 
92
 
 
40
  }
41
 
42
  _FAKE_SOURCE_INFO = {
43
+ "protocol": "extended",
44
  "spatial_code_format": "explicit",
45
  "input_selection": "selective",
46
  "frame_count": 64,
 
54
 
55
 
56
  def test_results_dir_for_matches_established_dimension_nesting():
57
+ root = harness_run.results_dir_for(
58
+ "qwen3.5-4b", "extended", "compact", "metric", "tracking", "uniform", 32
59
+ )
60
  assert root == (
61
+ C.RESULTS_DIR / "qwen3.5-4b" / "extended" / "compact" / "metric" / "tracking"
62
+ / "uniform" / "32"
63
  )
64
 
65
 
66
  def test_results_dir_for_honors_explicit_override(tmp_path):
67
  root = harness_run.results_dir_for(
68
+ "qwen3.5-4b", "base", "explicit", "relative", "no tracking", "selective", 16, tmp_path
69
  )
70
  assert root == tmp_path
71
 
 
90
  assert record["question"] == "How many chairs?"
91
  assert record["answer_given"] == "4"
92
  assert record["vision_input_shapes"] == _FAKE_ANSWER["vision_input_shapes"]
93
+ assert record["condition"] == "extended:explicit:metric:tracking:selective:64"
94
+ assert record["protocol"] == "extended"
95
  assert record["score"] == 1.0
96
 
97
 
tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc and b/tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc differ
 
tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323676 ADDED
File without changes
tests/test_D/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807 ADDED
File without changes
tests/test_D/test_run.py CHANGED
@@ -40,18 +40,19 @@ _FAKE_ROW = {
40
  }
41
 
42
  _FAKE_CODE_INFO = {
 
43
  "spatial_code_format": "explicit",
44
  "spatial_code_path": "/workspace/data/spatial codes/ground truth/explicit/scene0001_00.json",
45
  }
46
 
47
 
48
- def test_results_dir_for_matches_model_and_format_only():
49
- root = harness_run.results_dir_for("qwen3.5-4b", "compact")
50
- assert root == D.RESULTS_DIR / "qwen3.5-4b" / "compact"
51
 
52
 
53
  def test_results_dir_for_honors_explicit_override(tmp_path):
54
- root = harness_run.results_dir_for("qwen3.5-4b", "explicit", tmp_path)
55
  assert root == tmp_path
56
 
57
 
@@ -67,7 +68,8 @@ def test_build_record_preserves_every_field_untruncated():
67
  assert record["spatial_code_format"] == "explicit"
68
  assert record["spatial_code_path"] == _FAKE_CODE_INFO["spatial_code_path"]
69
  # No depth/tracking/input_selection/frame_count -- ground truth has no such axis.
70
- assert record["condition"] == "explicit"
 
71
  assert "input_selection" not in record
72
  assert "frame_count" not in record
73
  assert "depth" not in record
@@ -115,3 +117,37 @@ def test_build_record_defaults_reasoning_fields_when_absent():
115
  )
116
  assert record["reasoning_token_count"] is None
117
  assert record["forced"] is False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  }
41
 
42
  _FAKE_CODE_INFO = {
43
+ "protocol": "extended",
44
  "spatial_code_format": "explicit",
45
  "spatial_code_path": "/workspace/data/spatial codes/ground truth/explicit/scene0001_00.json",
46
  }
47
 
48
 
49
+ def test_results_dir_for_matches_model_protocol_and_format_only():
50
+ root = harness_run.results_dir_for("qwen3.5-4b", "extended", "compact")
51
+ assert root == D.RESULTS_DIR / "qwen3.5-4b" / "extended" / "compact"
52
 
53
 
54
  def test_results_dir_for_honors_explicit_override(tmp_path):
55
+ root = harness_run.results_dir_for("qwen3.5-4b", "base", "explicit", tmp_path)
56
  assert root == tmp_path
57
 
58
 
 
68
  assert record["spatial_code_format"] == "explicit"
69
  assert record["spatial_code_path"] == _FAKE_CODE_INFO["spatial_code_path"]
70
  # No depth/tracking/input_selection/frame_count -- ground truth has no such axis.
71
+ assert record["condition"] == "extended:explicit"
72
+ assert record["protocol"] == "extended"
73
  assert "input_selection" not in record
74
  assert "frame_count" not in record
75
  assert "depth" not in record
 
117
  )
118
  assert record["reasoning_token_count"] is None
119
  assert record["forced"] is False
120
+
121
+
122
+ def test_run_code_transform_hook_replaces_the_loaded_code(monkeypatch, tmp_path):
123
+ """The corruption module's entry point: the hook's return value is what the
124
+ prompt is built from, and passing no hook keeps behavior identical."""
125
+ scene = "13c3e046d7"
126
+ seen = {}
127
+
128
+ def fake_load(scene_id, spatial_code_format):
129
+ return {"objects": {"chair": {"count": 1}}}, f"/fake/{scene_id}.json"
130
+
131
+ class FakeAdapter:
132
+ model_path = "/fake/model"
133
+
134
+ def answer_extended(self, frames, prompt, **kwargs):
135
+ seen["prompt"] = prompt
136
+ return {
137
+ "prompt_text": prompt, "answer_text": "1", "answer_raw": "1",
138
+ "input_token_count": 1, "vision_input_shapes": {},
139
+ "output_token_ids": [1], "output_token_count": 1,
140
+ "hit_token_limit": False, "eos_token_ids": [1],
141
+ "generation_seconds": 0.0, "device": "cpu", "dtype": "float32",
142
+ "library_versions": {}, "generation_config": {},
143
+ }
144
+
145
+ monkeypatch.setattr(harness_run.spatial_codes, "load_spatial_code", fake_load)
146
+ replacement = {"objects": {"table": {"count": 9}}}
147
+ results = harness_run.run(
148
+ "qwen3.5-2b", scene=scene, adapter=FakeAdapter(), write_results=False, limit=1,
149
+ code_transform=lambda code, scene_id, fmt: replacement,
150
+ )
151
+ assert results
152
+ assert '"table"' in seen["prompt"]
153
+ assert '"chair"' not in seen["prompt"]
tests/test_E/__init__.py ADDED
File without changes
tests/test_E/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (144 Bytes). View file
 
tests/test_E/__pycache__/test_launch.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (8.15 kB). View file
 
tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (9.66 kB). View file
 
tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc.323676 ADDED
File without changes
tests/test_E/__pycache__/test_prompts.cpython-311-pytest-8.3.5.pyc.323807 ADDED
File without changes
tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (15.1 kB). View file
 
tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323676 ADDED
File without changes
tests/test_E/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807 ADDED
File without changes
tests/test_E/__pycache__/test_sweep.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (5.9 kB). View file
 
tests/test_E/test_launch.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/E/launch.py -- multi-GPU scene sharding for the blind floor."""
2
+
3
+ from harness.A.run import load_questions as harness_a_load_questions
4
+ from harness.E import launch
5
+
6
+
7
+ def test_launcher_imports():
8
+ assert callable(launch.main)
9
+
10
+
11
+ def test_launch_skips_scene_already_fully_answered(tmp_path, capsys):
12
+ scene = "13c3e046d7"
13
+ rows = harness_a_load_questions(scene=scene)
14
+ assert rows, "fixture scene must have real questions in the VSI-Bench manifest"
15
+
16
+ scene_dir = tmp_path / scene
17
+ scene_dir.mkdir()
18
+ for row in rows:
19
+ (scene_dir / f"{row['id']}.json").write_text("{}")
20
+
21
+ launch.launch("qwen3.5-2b", [scene], results_dir=tmp_path)
22
+
23
+ output = capsys.readouterr().out
24
+ assert "skipped" in output
25
+ assert "DONE: 1 ok, 0 failed" in output
26
+
27
+
28
+ def test_launch_rebuild_forces_pending_even_when_answered(tmp_path, monkeypatch):
29
+ scene = "13c3e046d7"
30
+ rows = harness_a_load_questions(scene=scene)
31
+ scene_dir = tmp_path / scene
32
+ scene_dir.mkdir()
33
+ for row in rows:
34
+ (scene_dir / f"{row['id']}.json").write_text("{}")
35
+
36
+ monkeypatch.setattr(launch, "visible_gpus", lambda: [])
37
+ monkeypatch.setattr(
38
+ launch.mp, "get_context",
39
+ lambda *_: (_ for _ in ()).throw(RuntimeError("rebuild correctly reached worker dispatch")),
40
+ )
41
+ try:
42
+ launch.launch("qwen3.5-2b", [scene], results_dir=tmp_path, rebuild=True)
43
+ except RuntimeError as exc:
44
+ assert "rebuild correctly reached worker dispatch" in str(exc)
45
+ else:
46
+ raise AssertionError("expected rebuild to force scene into the pending path")
47
+
48
+
49
+ def test_launch_protocols_use_separate_result_roots():
50
+ run = launch._load_run_module()
51
+ base = run.results_dir_for("qwen3.5-2b", "base")
52
+ extended = run.results_dir_for("qwen3.5-2b", "extended")
53
+ assert base != extended
tests/test_E/test_prompts.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/E/prompts.py -- blind question-only prompt construction."""
2
+
3
+ import pytest
4
+
5
+ from harness.A.prompts import MCA_QUESTION_TYPES, NA_QUESTION_TYPES
6
+ from harness.E import prompts as blind_prompts
7
+
8
+
9
+ def test_na_question_prompt_is_question_plus_post_prompt_only():
10
+ prompt = blind_prompts.build_prompt("object_counting", "How many chairs?")
11
+ assert prompt == "How many chairs?\n" + blind_prompts.NA_POST_PROMPT
12
+
13
+
14
+ def test_mca_question_prompt_includes_options_and_post_prompt():
15
+ prompt = blind_prompts.build_prompt(
16
+ "object_rel_distance", "Which is closest?", ["A. sofa", "B. table"]
17
+ )
18
+ assert "Options:\nA. sofa\nB. table" in prompt
19
+ assert prompt.endswith(blind_prompts.MCA_POST_PROMPT)
20
+
21
+
22
+ def test_no_scene_language_anywhere():
23
+ # Blind means blind: no context line claiming frames, video, or a spatial code.
24
+ prompt = blind_prompts.build_prompt("object_counting", "How many chairs?")
25
+ lowered = prompt.lower()
26
+ assert "frame" not in lowered
27
+ assert "video" not in lowered
28
+ assert "spatial code" not in lowered
29
+
30
+
31
+ def test_mca_question_requires_options():
32
+ with pytest.raises(ValueError):
33
+ blind_prompts.build_prompt("route_planning", "Which way?", None)
34
+
35
+
36
+ def test_unknown_question_type_rejected():
37
+ with pytest.raises(ValueError):
38
+ blind_prompts.build_prompt("not_a_real_type", "?", None)
39
+
40
+
41
+ @pytest.mark.parametrize("question_type", NA_QUESTION_TYPES)
42
+ def test_every_na_question_type_builds(question_type):
43
+ assert blind_prompts.build_prompt(question_type, "q?")
44
+
45
+
46
+ @pytest.mark.parametrize("question_type", MCA_QUESTION_TYPES)
47
+ def test_every_mca_question_type_builds(question_type):
48
+ assert blind_prompts.build_prompt(question_type, "q?", ["A. x", "B. y"])
tests/test_E/test_run.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/E/run.py -- result-record shape and result-file writing."""
2
+
3
+ import json
4
+
5
+ from harness import E
6
+ from harness.E import run as harness_run
7
+
8
+ _FAKE_ANSWER = {
9
+ "prompt_text": "<rendered chat template>",
10
+ "answer_text": "4",
11
+ "answer_raw": "<|im_start|>assistant\n4<|im_end|>",
12
+ "input_token_count": 42,
13
+ "vision_input_shapes": {},
14
+ "output_token_ids": [19, 151645],
15
+ "output_token_count": 2,
16
+ "hit_token_limit": False,
17
+ "eos_token_ids": [151645],
18
+ "generation_seconds": 0.2,
19
+ "device": "cuda",
20
+ "dtype": "bfloat16",
21
+ "library_versions": {"transformers": "5.14.1", "torch": "2.13.0+cu130"},
22
+ "generation_config": {
23
+ "max_new_tokens": 16,
24
+ "do_sample": False,
25
+ "temperature": 0.0,
26
+ "top_p": None,
27
+ "top_k": None,
28
+ "enable_thinking": False,
29
+ },
30
+ }
31
+
32
+ _FAKE_ROW = {
33
+ "id": 7,
34
+ "scene_name": "scene0001_00",
35
+ "dataset": "scannet",
36
+ "question_type": "object_counting",
37
+ "question": "How many chairs?",
38
+ "options": None,
39
+ "ground_truth": "4",
40
+ }
41
+
42
+
43
+ def test_results_dir_for_matches_model_and_protocol_only():
44
+ root = harness_run.results_dir_for("qwen3.5-4b", "base")
45
+ assert root == E.RESULTS_DIR / "qwen3.5-4b" / "base"
46
+
47
+
48
+ def test_results_dir_for_isolates_the_two_protocols():
49
+ assert harness_run.results_dir_for("qwen3.5-4b", "base") != harness_run.results_dir_for(
50
+ "qwen3.5-4b", "extended"
51
+ )
52
+
53
+
54
+ def test_results_dir_for_honors_explicit_override(tmp_path):
55
+ assert harness_run.results_dir_for("qwen3.5-4b", "base", tmp_path) == tmp_path
56
+
57
+
58
+ def test_build_record_has_no_scene_input_provenance():
59
+ record = harness_run._build_record(
60
+ _FAKE_ROW, "full prompt text", _FAKE_ANSWER, "MRA:.5:.95:.05", 1.0,
61
+ "qwen3.5-4b", "/root/models/qwen3.5-4b", "base",
62
+ )
63
+ assert record["condition"] == "base"
64
+ assert record["protocol"] == "base"
65
+ assert record["question"] == "How many chairs?"
66
+ assert record["answer_given"] == "4"
67
+ assert record["metric"] == "MRA:.5:.95:.05"
68
+ assert record["score"] == 1.0
69
+ # Blind: no frame or spatial-code provenance of any kind.
70
+ assert "frame_selection" not in record
71
+ assert "video_path" not in record
72
+ assert "frame_indices" not in record
73
+ assert "spatial_code_format" not in record
74
+ assert "spatial_code_path" not in record
75
+
76
+
77
+ def test_write_question_result_writes_one_json_file_per_question(tmp_path):
78
+ path, record = harness_run.write_question_result(
79
+ _FAKE_ROW, "full prompt text", _FAKE_ANSWER, "MRA:.5:.95:.05", 1.0,
80
+ "qwen3.5-4b", "/root/models/qwen3.5-4b", "base", results_dir=tmp_path,
81
+ )
82
+ assert path == tmp_path / "scene0001_00" / "7.json"
83
+ on_disk = json.loads(path.read_text())
84
+ assert on_disk == record
tests/test_E/test_sweep.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for harness/E/sweep.py -- per-model blind-floor sweeping."""
2
+
3
+ import pytest
4
+
5
+ from harness.E import sweep
6
+
7
+
8
+ def test_sweep_imports():
9
+ assert callable(sweep.main)
10
+
11
+
12
+ def test_sweep_runs_every_model_through_launch(monkeypatch):
13
+ launched = []
14
+ monkeypatch.setattr(
15
+ sweep.harness_launch, "launch",
16
+ lambda model, scenes, **kwargs: launched.append((model, kwargs.get("extended"))),
17
+ )
18
+ sweep.sweep(["qwen3.5-2b", "qwen3.5-4b"], ["scene_a"], extended=True)
19
+ assert launched == [("qwen3.5-2b", True), ("qwen3.5-4b", True)]
20
+
21
+
22
+ def test_sweep_defaults_to_base_protocol(monkeypatch):
23
+ launched = []
24
+ monkeypatch.setattr(
25
+ sweep.harness_launch, "launch",
26
+ lambda model, scenes, **kwargs: launched.append(kwargs.get("extended")),
27
+ )
28
+ sweep.sweep(["qwen3.5-2b"], ["scene_a"])
29
+ assert launched == [False]
30
+
31
+
32
+ def test_sweep_parser_rejects_unknown_model(monkeypatch, capsys):
33
+ monkeypatch.setattr("sys.argv", ["sweep", "--models", "not-a-model"])
34
+ with pytest.raises(SystemExit):
35
+ sweep.main()
36
+ assert "unknown" in capsys.readouterr().err
tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc CHANGED
Binary files a/tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc and b/tests/test_analysis/__pycache__/test_aggregate.cpython-311-pytest-8.3.5.pyc differ
 
tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc CHANGED
Binary files a/tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc and b/tests/test_analysis/__pycache__/test_compare.cpython-311-pytest-8.3.5.pyc differ
 
tests/test_analysis/__pycache__/test_cot_audit.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (12.2 kB). View file
 
tests/test_analysis/__pycache__/test_depth.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (7.83 kB). View file
 
tests/test_analysis/__pycache__/test_solvability.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (6.83 kB). View file
 
tests/test_analysis/__pycache__/test_stats.cpython-311-pytest-8.3.5.pyc ADDED
Binary file (14.6 kB). View file