AntonioJun commited on
Commit
9f132da
·
verified ·
1 Parent(s): c197316

Add files using upload-large-folder tool

Browse files
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/launch.py CHANGED
@@ -26,6 +26,7 @@ if str(WORKSPACE_ROOT) not in sys.path:
26
  from encoder.ground_truth import scenes as ground_truth_scenes # noqa: E402
27
  from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
28
  from harness.A import models as vlm_models # noqa: E402
 
29
  from harness.D import DEFAULT_SPATIAL_CODE_FORMAT, SPATIAL_CODE_FORMATS # noqa: E402
30
  from inference.launch import available_cpu_count, visible_gpus # noqa: E402
31
 
@@ -39,7 +40,8 @@ def _load_run_module():
39
 
40
 
41
  def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
42
- extended, reasoning_budget, force_budget, strip_schema_legend):
 
43
  if gpu is not None:
44
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
45
  for variable in ("OMP_NUM_THREADS", "MKL_NUM_THREADS", "OPENBLAS_NUM_THREADS"):
@@ -70,6 +72,9 @@ def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_th
70
  reasoning_budget=reasoning_budget,
71
  force_budget=force_budget,
72
  strip_schema_legend=strip_schema_legend,
 
 
 
73
  )
74
  mean_score = (
75
  sum(r["score"] for r in answered) / len(answered) if answered else None
@@ -85,12 +90,18 @@ def launch(
85
  model, spatial_code_format, selected, results_dir=None, rebuild=False,
86
  extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
87
  strip_schema_legend=False,
 
88
  ):
89
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
90
  protocol = f"{reasoning_budget}" if extended else "base"
91
  condition = f"{model}/{protocol}/{spatial_code_format}"
 
 
92
  run = _load_run_module()
93
- root = run.results_dir_for(model, protocol, spatial_code_format, results_dir)
 
 
 
94
  pending = []
95
  completed = 0
96
  for scene in selected:
@@ -128,6 +139,7 @@ def launch(
128
  args=(
129
  tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
130
  extended, reasoning_budget, force_budget, strip_schema_legend,
 
131
  ),
132
  )
133
  for gpu in assignments
@@ -186,6 +198,20 @@ def main():
186
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
187
  help="drop the embedded schema legend (the amended main-run design)",
188
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
190
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
191
  args = parser.parse_args()
@@ -202,10 +228,13 @@ def main():
202
  parser.error("--reasoning-budget must be positive")
203
  if args.force_budget < 1:
204
  parser.error("--force-budget must be positive")
 
 
205
  launch(
206
  args.model, args.spatial_code_format, selected,
207
  results_dir=args.results_dir, rebuild=args.rebuild,
208
  extended=not args.base_protocol,
 
209
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
210
  strip_schema_legend=args.strip_schema_legend,
211
  )
 
26
  from encoder.ground_truth import scenes as ground_truth_scenes # noqa: E402
27
  from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
28
  from harness.A import models as vlm_models # noqa: E402
29
+ from harness.B import DEFAULT_INPUT_SELECTION, FRAMES_PER_VIDEO, INPUT_SELECTIONS # noqa: E402
30
  from harness.D import DEFAULT_SPATIAL_CODE_FORMAT, SPATIAL_CODE_FORMATS # noqa: E402
31
  from inference.launch import available_cpu_count, visible_gpus # noqa: E402
32
 
 
40
 
41
 
42
  def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
43
+ extended, reasoning_budget, force_budget, strip_schema_legend,
44
+ frames, frame_selection, frame_count):
45
  if gpu is not None:
46
  os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
47
  for variable in ("OMP_NUM_THREADS", "MKL_NUM_THREADS", "OPENBLAS_NUM_THREADS"):
 
72
  reasoning_budget=reasoning_budget,
73
  force_budget=force_budget,
74
  strip_schema_legend=strip_schema_legend,
75
+ frames=frames,
76
+ frame_selection=frame_selection,
77
+ frame_count=frame_count,
78
  )
79
  mean_score = (
80
  sum(r["score"] for r in answered) / len(answered) if answered else None
 
90
  model, spatial_code_format, selected, results_dir=None, rebuild=False,
91
  extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
92
  strip_schema_legend=False,
93
+ frames=False, frame_selection=DEFAULT_INPUT_SELECTION, frame_count=FRAMES_PER_VIDEO,
94
  ):
95
  """Answer every question for ``selected`` scenes, sharded across every visible GPU."""
96
  protocol = f"{reasoning_budget}" if extended else "base"
97
  condition = f"{model}/{protocol}/{spatial_code_format}"
98
+ if frames:
99
+ condition += f"/frames/{frame_selection}/{frame_count}"
100
  run = _load_run_module()
101
+ root = run.results_dir_for(
102
+ model, protocol, spatial_code_format, results_dir,
103
+ frames=frames, frame_selection=frame_selection, frame_count=frame_count,
104
+ )
105
  pending = []
106
  completed = 0
107
  for scene in selected:
 
139
  args=(
140
  tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
141
  extended, reasoning_budget, force_budget, strip_schema_legend,
142
+ frames, frame_selection, frame_count,
143
  ),
144
  )
145
  for gpu in assignments
 
198
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
199
  help="drop the embedded schema legend (the amended main-run design)",
200
  )
201
+ parser.add_argument(
202
+ "--with-frames", action="store_true", dest="frames",
203
+ help="frames+ground-truth-code arm: also sample and show the scene's raw video "
204
+ "frames alongside the ground-truth code (default sampling: uniform, 32 frames -- "
205
+ "the frozen Step-1 config)",
206
+ )
207
+ parser.add_argument(
208
+ "--frame-selection", default=DEFAULT_INPUT_SELECTION, choices=INPUT_SELECTIONS,
209
+ dest="frame_selection", help="only used with --with-frames",
210
+ )
211
+ parser.add_argument(
212
+ "--frames-per-video", type=int, default=FRAMES_PER_VIDEO, dest="frame_count",
213
+ help="only used with --with-frames",
214
+ )
215
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
216
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
217
  args = parser.parse_args()
 
228
  parser.error("--reasoning-budget must be positive")
229
  if args.force_budget < 1:
230
  parser.error("--force-budget must be positive")
231
+ if args.frame_count < 1:
232
+ parser.error("--frames-per-video must be positive")
233
  launch(
234
  args.model, args.spatial_code_format, selected,
235
  results_dir=args.results_dir, rebuild=args.rebuild,
236
  extended=not args.base_protocol,
237
+ frames=args.frames, frame_selection=args.frame_selection, frame_count=args.frame_count,
238
  reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
239
  strip_schema_legend=args.strip_schema_legend,
240
  )
harness/D/run.py CHANGED
@@ -20,36 +20,66 @@ WORKSPACE_ROOT = Path(__file__).resolve().parent.parent.parent
20
  if str(WORKSPACE_ROOT) not in sys.path:
21
  sys.path.insert(0, str(WORKSPACE_ROOT))
22
 
 
23
  from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
 
24
  from harness.A import models as vlm_models # noqa: E402
25
  from harness.A.run import _scalar_score, load_questions, vsi_official_eval # noqa: E402
 
 
26
  from harness.D import DEFAULT_SPATIAL_CODE_FORMAT, RESULTS_DIR, SPATIAL_CODE_FORMATS # noqa: E402
27
  from harness.D import prompts as code_prompts # noqa: E402
28
  from harness.D.prompts import NO_LEGEND_PRE_PROMPT # noqa: E402
29
  from harness.D import spatial_codes # noqa: E402
30
 
31
 
32
- def results_dir_for(model, protocol, spatial_code_format, results_dir=None):
 
 
 
33
  """Return the result root isolated by model + protocol + spatial-code-format.
34
  ``protocol`` is "base" (16-token) or "<reasoning budget>" (e.g. "512") -- a real path segment, so records from different protocols OR
35
- different reasoning budgets can never collide on disk."""
 
 
 
 
 
 
36
  if results_dir is not None:
37
  return Path(results_dir)
38
- return RESULTS_DIR / model / protocol / spatial_code_format
 
 
 
39
 
40
 
41
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info):
42
- """Assemble one question's full, untruncated result record (nothing summarized)."""
 
 
 
 
 
 
 
 
43
  return {
44
  "model": model,
45
  "model_path": str(model_path),
46
  "device": answer["device"],
47
  "dtype": answer["dtype"],
48
  "library_versions": answer["library_versions"],
49
- "condition": f"{code_info['protocol']}:{code_info['spatial_code_format']}",
50
  "protocol": code_info["protocol"],
51
  "spatial_code_format": code_info["spatial_code_format"],
52
  "spatial_code_path": code_info["spatial_code_path"],
 
 
 
 
 
 
53
  "scene": row["scene_name"],
54
  "dataset": row.get("dataset"),
55
  "question_id": row["id"],
@@ -87,7 +117,10 @@ def write_question_result(
87
  """Write one question's full, untruncated result record. Return (path, record)."""
88
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
89
  root = results_dir_for(
90
- model, code_info["protocol"], code_info["spatial_code_format"], results_dir
 
 
 
91
  )
92
  scene_dir = root / record["scene"]
93
  scene_dir.mkdir(parents=True, exist_ok=True)
@@ -113,10 +146,26 @@ def run(
113
  force_budget=MAX_NEW_TOKENS,
114
  code_transform=None,
115
  strip_schema_legend=False,
 
 
 
116
  ):
117
  """Answer every matching question with one model, given its scene's GROUND-TRUTH
118
- spatial code as text (no video frames). Each question's full record is written to
119
- its own JSON file as soon as it is answered (unless ``write_results=False``).
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  Uses ``adapter.answer_extended`` as the standing default protocol, same as
122
  harness.B -- working through a full spatial-code JSON before answering benefits
@@ -151,18 +200,36 @@ def run(
151
  code = code_transform(code, scene_id, spatial_code_format)
152
  if strip_schema_legend:
153
  code = {k: v for k, v in code.items() if k != "spatial code schema"}
154
- code_cache[scene_id] = {"code": code, "path": path}
 
 
 
 
 
 
 
 
 
 
155
  cached = code_cache[scene_id]
 
 
 
 
 
 
 
156
  prompt = code_prompts.build_prompt(
157
  cached["code"], row["question_type"], row["question"], row.get("options"),
158
- context_line=NO_LEGEND_PRE_PROMPT if strip_schema_legend else None,
159
  )
160
  answer = (
161
  adapter.answer_extended(
162
- [], prompt, reasoning_budget=reasoning_budget, force_budget=force_budget
 
163
  )
164
  if extended
165
- else adapter.answer([], prompt)
166
  )
167
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
168
  score_doc = vsi_official_eval.vsibench_process_results(
@@ -173,6 +240,12 @@ def run(
173
  "protocol": f"{reasoning_budget}" if extended else "base",
174
  "spatial_code_format": spatial_code_format,
175
  "spatial_code_path": cached["path"],
 
 
 
 
 
 
176
  }
177
  if write_results:
178
  path, record = write_question_result(
@@ -219,6 +292,20 @@ def main():
219
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
220
  help="drop the embedded schema legend (the amended main-run design)",
221
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
223
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
224
  args = parser.parse_args()
@@ -226,6 +313,8 @@ def main():
226
  parser.error("--reasoning-budget must be positive")
227
  if args.force_budget < 1:
228
  parser.error("--force-budget must be positive")
 
 
229
 
230
  results = run(
231
  args.model,
@@ -239,6 +328,9 @@ def main():
239
  strip_schema_legend=args.strip_schema_legend,
240
  reasoning_budget=args.reasoning_budget,
241
  force_budget=args.force_budget,
 
 
 
242
  )
243
 
244
  for result in results:
 
20
  if str(WORKSPACE_ROOT) not in sys.path:
21
  sys.path.insert(0, str(WORKSPACE_ROOT))
22
 
23
+ import inference as inference_config # noqa: E402
24
  from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
25
+ from harness.A import frames as frame_sampling # noqa: E402
26
  from harness.A import models as vlm_models # noqa: E402
27
  from harness.A.run import _scalar_score, load_questions, vsi_official_eval # noqa: E402
28
+ from harness.B import DEFAULT_INPUT_SELECTION, FRAMES_PER_VIDEO, INPUT_SELECTIONS # noqa: E402
29
+ from harness.C import prompts as combined_prompts # noqa: E402
30
  from harness.D import DEFAULT_SPATIAL_CODE_FORMAT, RESULTS_DIR, SPATIAL_CODE_FORMATS # noqa: E402
31
  from harness.D import prompts as code_prompts # noqa: E402
32
  from harness.D.prompts import NO_LEGEND_PRE_PROMPT # noqa: E402
33
  from harness.D import spatial_codes # noqa: E402
34
 
35
 
36
+ def results_dir_for(
37
+ model, protocol, spatial_code_format, results_dir=None,
38
+ frames=False, frame_selection=DEFAULT_INPUT_SELECTION, frame_count=FRAMES_PER_VIDEO,
39
+ ):
40
  """Return the result root isolated by model + protocol + spatial-code-format.
41
  ``protocol`` is "base" (16-token) or "<reasoning budget>" (e.g. "512") -- a real path segment, so records from different protocols OR
42
+ different reasoning budgets can never collide on disk.
43
+
44
+ ``frames=True`` (the frames+ground-truth-code arm) appends its own "frames/
45
+ <selection>/<count>" segment -- video frames have no bearing on which ground-truth
46
+ code gets loaded (ground truth has no depth/tracking/input-selection axis at all;
47
+ see harness/D/__init__.py), but they DO change what the model sees, so this arm's
48
+ records must never share a path with the text-only condition's."""
49
  if results_dir is not None:
50
  return Path(results_dir)
51
+ root = RESULTS_DIR / model / protocol / spatial_code_format
52
+ if frames:
53
+ root = root / "frames" / frame_selection / str(frame_count)
54
+ return root
55
 
56
 
57
  def _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info):
58
+ """Assemble one question's full, untruncated result record (nothing summarized).
59
+
60
+ ``code_info`` carries frame provenance (``video_path``, ``frame_indices``,
61
+ ``frame_timestamps``) only for the frames+ground-truth-code arm; all three are None
62
+ on the standard text-only condition, matching how harness.A/B/D's other optional
63
+ fields (``reasoning_text`` etc.) are present-but-null rather than absent."""
64
+ condition = f"{code_info['protocol']}:{code_info['spatial_code_format']}"
65
+ if code_info.get("frames"):
66
+ condition += f":frames:{code_info['frame_selection']}:{code_info['frame_count']}"
67
  return {
68
  "model": model,
69
  "model_path": str(model_path),
70
  "device": answer["device"],
71
  "dtype": answer["dtype"],
72
  "library_versions": answer["library_versions"],
73
+ "condition": condition,
74
  "protocol": code_info["protocol"],
75
  "spatial_code_format": code_info["spatial_code_format"],
76
  "spatial_code_path": code_info["spatial_code_path"],
77
+ "frames": code_info.get("frames", False),
78
+ "frame_selection": code_info.get("frame_selection"),
79
+ "frame_count": code_info.get("frame_count"),
80
+ "video_path": code_info.get("video_path"),
81
+ "frame_indices": code_info.get("frame_indices"),
82
+ "frame_timestamps_seconds": code_info.get("frame_timestamps"),
83
  "scene": row["scene_name"],
84
  "dataset": row.get("dataset"),
85
  "question_id": row["id"],
 
117
  """Write one question's full, untruncated result record. Return (path, record)."""
118
  record = _build_record(row, prompt, answer, metric_name, score, model, model_path, code_info)
119
  root = results_dir_for(
120
+ model, code_info["protocol"], code_info["spatial_code_format"], results_dir,
121
+ frames=code_info.get("frames", False),
122
+ frame_selection=code_info.get("frame_selection", DEFAULT_INPUT_SELECTION),
123
+ frame_count=code_info.get("frame_count", FRAMES_PER_VIDEO),
124
  )
125
  scene_dir = root / record["scene"]
126
  scene_dir.mkdir(parents=True, exist_ok=True)
 
146
  force_budget=MAX_NEW_TOKENS,
147
  code_transform=None,
148
  strip_schema_legend=False,
149
+ frames=False,
150
+ frame_selection=DEFAULT_INPUT_SELECTION,
151
+ frame_count=FRAMES_PER_VIDEO,
152
  ):
153
  """Answer every matching question with one model, given its scene's GROUND-TRUTH
154
+ spatial code as text. Each question's full record is written to its own JSON file
155
+ as soon as it is answered (unless ``write_results=False``).
156
+
157
+ ``frames=True`` runs the frames+ground-truth-code arm: the scene's raw video is
158
+ ALSO sampled (``frame_selection``/``frame_count``, harness.A.frames.sample_frames --
159
+ the same sampling every harness uses; ground truth has no depth/tracking axis for
160
+ frames to be sourced "from", so there is nothing for this to mismatch against) and
161
+ shown alongside the ground-truth code, with harness.C's frames+code context line
162
+ (byte-identical composition rule: harness.A's frame sentence + harness.B's code
163
+ sentence, the same CODE_DESCRIPTION D's own text-only line already uses). This is
164
+ the ground-truth counterpart of harness C -- C answers with frames + a PERCEIVED
165
+ code; this is frames + the PERFECT code -- which harness C itself cannot produce,
166
+ since its spatial-code loader is perception-only. The default ``frame_selection``/
167
+ ``frame_count`` match the frozen Step-1 config (uniform, 32) so a default frames=True
168
+ call needs no extra flags to land on the same sampling every other harness uses.
169
 
170
  Uses ``adapter.answer_extended`` as the standing default protocol, same as
171
  harness.B -- working through a full spatial-code JSON before answering benefits
 
200
  code = code_transform(code, scene_id, spatial_code_format)
201
  if strip_schema_legend:
202
  code = {k: v for k, v in code.items() if k != "spatial code schema"}
203
+ entry = {"code": code, "path": path}
204
+ if frames:
205
+ video_path = inference_config.video_path(scene_id, row.get("dataset"))
206
+ frame_images, frame_timestamps, frame_indices = frame_sampling.sample_frames(
207
+ video_path, frame_count, frame_selection
208
+ )
209
+ entry.update(
210
+ video_path=video_path, frame_images=frame_images,
211
+ frame_timestamps=frame_timestamps, frame_indices=frame_indices,
212
+ )
213
+ code_cache[scene_id] = entry
214
  cached = code_cache[scene_id]
215
+ if frames:
216
+ context_line = (
217
+ combined_prompts.NO_LEGEND_PRE_PROMPT if strip_schema_legend
218
+ else combined_prompts.PRE_PROMPT
219
+ )
220
+ else:
221
+ context_line = NO_LEGEND_PRE_PROMPT if strip_schema_legend else None
222
  prompt = code_prompts.build_prompt(
223
  cached["code"], row["question_type"], row["question"], row.get("options"),
224
+ context_line=context_line,
225
  )
226
  answer = (
227
  adapter.answer_extended(
228
+ cached["frame_images"] if frames else [], prompt,
229
+ reasoning_budget=reasoning_budget, force_budget=force_budget,
230
  )
231
  if extended
232
+ else adapter.answer(cached["frame_images"] if frames else [], prompt)
233
  )
234
  doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
235
  score_doc = vsi_official_eval.vsibench_process_results(
 
240
  "protocol": f"{reasoning_budget}" if extended else "base",
241
  "spatial_code_format": spatial_code_format,
242
  "spatial_code_path": cached["path"],
243
+ "frames": frames,
244
+ "frame_selection": frame_selection if frames else None,
245
+ "frame_count": frame_count if frames else None,
246
+ "video_path": cached.get("video_path"),
247
+ "frame_indices": cached.get("frame_indices"),
248
+ "frame_timestamps": cached.get("frame_timestamps"),
249
  }
250
  if write_results:
251
  path, record = write_question_result(
 
292
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
293
  help="drop the embedded schema legend (the amended main-run design)",
294
  )
295
+ parser.add_argument(
296
+ "--with-frames", action="store_true", dest="frames",
297
+ help="frames+ground-truth-code arm: also sample and show the scene's raw video "
298
+ "frames alongside the ground-truth code (default sampling: uniform, 32 frames -- "
299
+ "the frozen Step-1 config)",
300
+ )
301
+ parser.add_argument(
302
+ "--frame-selection", default=DEFAULT_INPUT_SELECTION, choices=INPUT_SELECTIONS,
303
+ dest="frame_selection", help="only used with --with-frames",
304
+ )
305
+ parser.add_argument(
306
+ "--frames-per-video", type=int, default=FRAMES_PER_VIDEO, dest="frame_count",
307
+ help="only used with --with-frames",
308
+ )
309
  parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
310
  parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
311
  args = parser.parse_args()
 
313
  parser.error("--reasoning-budget must be positive")
314
  if args.force_budget < 1:
315
  parser.error("--force-budget must be positive")
316
+ if args.frame_count < 1:
317
+ parser.error("--frames-per-video must be positive")
318
 
319
  results = run(
320
  args.model,
 
328
  strip_schema_legend=args.strip_schema_legend,
329
  reasoning_budget=args.reasoning_budget,
330
  force_budget=args.force_budget,
331
+ frames=args.frames,
332
+ frame_selection=args.frame_selection,
333
+ frame_count=args.frame_count,
334
  )
335
 
336
  for result in results:
harness/D/sweep.py CHANGED
@@ -25,7 +25,7 @@ if str(WORKSPACE_ROOT) not in sys.path:
25
  from harness.A import models as vlm_models # noqa: E402
26
  from harness.A import EXTENDED_MAX_NEW_TOKENS # noqa: E402
27
  from harness.A.sweep import _parse_csv_choice # noqa: E402
28
- from harness.B import SPATIAL_CODE_FORMATS # noqa: E402
29
  from harness.D import launch as harness_launch # noqa: E402
30
 
31
 
@@ -41,19 +41,22 @@ def build_plan(models, spatial_code_formats):
41
  def sweep(
42
  models, spatial_code_formats, selected_scenes, results_dir=None, rebuild=False,
43
  extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, strip_schema_legend=False,
 
44
  ):
45
  """Run every (model, spatial_code_format) pair across all visible GPUs."""
46
  plan = build_plan(models, spatial_code_formats)
47
  protocol = "extended" if extended else "base"
48
  for index, (model, spatial_code_format) in enumerate(plan, start=1):
49
  print(
50
- f"=== sweep {index}/{len(plan)}: {model}/{protocol}/{spatial_code_format} ===",
 
51
  flush=True,
52
  )
53
  harness_launch.launch(
54
  model, spatial_code_format, selected_scenes,
55
  results_dir=results_dir, rebuild=rebuild, extended=extended,
56
  reasoning_budget=reasoning_budget, strip_schema_legend=strip_schema_legend,
 
57
  )
58
 
59
 
@@ -88,9 +91,25 @@ def main():
88
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
89
  help="drop the embedded schema legend (the amended main-run design)",
90
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  args = parser.parse_args()
92
  if args.scene and args.scenes:
93
  parser.error("positional scene and --scenes cannot be used together")
 
 
94
 
95
  try:
96
  models = _parse_csv_choice(args.models, vlm_models.available_models(), "--models")
@@ -114,6 +133,7 @@ def main():
114
  extended=not args.base_protocol,
115
  reasoning_budget=args.reasoning_budget,
116
  strip_schema_legend=args.strip_schema_legend,
 
117
  )
118
 
119
 
 
25
  from harness.A import models as vlm_models # noqa: E402
26
  from harness.A import EXTENDED_MAX_NEW_TOKENS # noqa: E402
27
  from harness.A.sweep import _parse_csv_choice # noqa: E402
28
+ from harness.B import DEFAULT_INPUT_SELECTION, FRAMES_PER_VIDEO, INPUT_SELECTIONS, SPATIAL_CODE_FORMATS # noqa: E402
29
  from harness.D import launch as harness_launch # noqa: E402
30
 
31
 
 
41
  def sweep(
42
  models, spatial_code_formats, selected_scenes, results_dir=None, rebuild=False,
43
  extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, strip_schema_legend=False,
44
+ frames=False, frame_selection=DEFAULT_INPUT_SELECTION, frame_count=FRAMES_PER_VIDEO,
45
  ):
46
  """Run every (model, spatial_code_format) pair across all visible GPUs."""
47
  plan = build_plan(models, spatial_code_formats)
48
  protocol = "extended" if extended else "base"
49
  for index, (model, spatial_code_format) in enumerate(plan, start=1):
50
  print(
51
+ f"=== sweep {index}/{len(plan)}: {model}/{protocol}/{spatial_code_format}"
52
+ + (f"/frames/{frame_selection}/{frame_count}" if frames else "") + " ===",
53
  flush=True,
54
  )
55
  harness_launch.launch(
56
  model, spatial_code_format, selected_scenes,
57
  results_dir=results_dir, rebuild=rebuild, extended=extended,
58
  reasoning_budget=reasoning_budget, strip_schema_legend=strip_schema_legend,
59
+ frames=frames, frame_selection=frame_selection, frame_count=frame_count,
60
  )
61
 
62
 
 
91
  "--no-schema-legend", action="store_true", dest="strip_schema_legend",
92
  help="drop the embedded schema legend (the amended main-run design)",
93
  )
94
+ parser.add_argument(
95
+ "--with-frames", action="store_true", dest="frames",
96
+ help="frames+ground-truth-code arm: also sample and show the scene's raw video "
97
+ "frames alongside the ground-truth code (default sampling: uniform, 32 frames -- "
98
+ "the frozen Step-1 config)",
99
+ )
100
+ parser.add_argument(
101
+ "--frame-selection", default=DEFAULT_INPUT_SELECTION, choices=INPUT_SELECTIONS,
102
+ dest="frame_selection", help="only used with --with-frames",
103
+ )
104
+ parser.add_argument(
105
+ "--frames-per-video", type=int, default=FRAMES_PER_VIDEO, dest="frame_count",
106
+ help="only used with --with-frames",
107
+ )
108
  args = parser.parse_args()
109
  if args.scene and args.scenes:
110
  parser.error("positional scene and --scenes cannot be used together")
111
+ if args.frame_count < 1:
112
+ parser.error("--frames-per-video must be positive")
113
 
114
  try:
115
  models = _parse_csv_choice(args.models, vlm_models.available_models(), "--models")
 
133
  extended=not args.base_protocol,
134
  reasoning_budget=args.reasoning_budget,
135
  strip_schema_legend=args.strip_schema_legend,
136
+ frames=args.frames, frame_selection=args.frame_selection, frame_count=args.frame_count,
137
  )
138
 
139
 
tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc CHANGED
Binary files a/tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc and b/tests/test_D/__pycache__/test_run.cpython-311-pytest-9.1.1.pyc differ
 
tests/test_D/test_run.py CHANGED
@@ -67,11 +67,18 @@ def test_build_record_preserves_every_field_untruncated():
67
  assert record["answer_given"] == "4"
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
76
  assert "tracking" not in record
77
  assert record["metric"] == "MRA:.5:.95:.05"
 
67
  assert record["answer_given"] == "4"
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 -- ground truth has no such axis. frames/
71
+ # frame_selection/frame_count/video_path/frame_indices/frame_timestamps_seconds DO
72
+ # exist on every record (the frames+ground-truth-code arm's fields), null here since
73
+ # _FAKE_CODE_INFO has no "frames" key -- same present-but-null pattern as
74
+ # reasoning_text on a base-protocol record.
75
  assert record["condition"] == "extended:explicit"
76
  assert record["protocol"] == "extended"
77
+ assert record["frames"] is False
78
+ assert record["frame_selection"] is None
79
+ assert record["frame_count"] is None
80
+ assert record["video_path"] is None
81
  assert "input_selection" not in record
 
82
  assert "depth" not in record
83
  assert "tracking" not in record
84
  assert record["metric"] == "MRA:.5:.95:.05"