Add files using upload-large-folder tool
Browse files- README.md +297 -48
- analysis/__pycache__/aggregate.cpython-311.pyc +0 -0
- analysis/__pycache__/compare.cpython-311.pyc +0 -0
- analysis/__pycache__/cot_audit.cpython-311.pyc +0 -0
- analysis/__pycache__/depth.cpython-311.pyc +0 -0
- analysis/__pycache__/solvability.cpython-311.pyc +0 -0
- analysis/__pycache__/stats.cpython-311.pyc +0 -0
- analysis/__pycache__/sufficiency.cpython-311.pyc +0 -0
- analysis/aggregate.py +3 -1
- analysis/compare.py +142 -84
- analysis/cot_audit.py +171 -0
- analysis/depth.py +108 -0
- analysis/preregistration.md +102 -0
- analysis/solvability.py +115 -0
- analysis/stats.py +144 -0
- analysis/sufficiency.py +131 -0
- corruption/__init__.py +34 -0
- corruption/__pycache__/__init__.cpython-311.pyc +0 -0
- corruption/__pycache__/chimera.cpython-311.pyc +0 -0
- corruption/__pycache__/empirical.cpython-311.pyc +0 -0
- corruption/__pycache__/launch.cpython-311.pyc +0 -0
- corruption/__pycache__/run.cpython-311.pyc +0 -0
- corruption/__pycache__/transforms.cpython-311.pyc +0 -0
- corruption/chimera.py +99 -0
- corruption/empirical.py +131 -0
- corruption/launch.py +84 -0
- corruption/run.py +286 -0
- corruption/transforms.py +251 -0
- harness/C/sweep.py +11 -2
- harness/D/launch.py +12 -5
- harness/D/sweep.py +20 -4
- harness/E/__init__.py +33 -0
- harness/E/__pycache__/__init__.cpython-311.pyc +0 -0
- harness/E/__pycache__/prompts.cpython-311.pyc +0 -0
- harness/E/__pycache__/run.cpython-311.pyc +0 -0
- harness/E/__pycache__/sweep.cpython-311.pyc +0 -0
- harness/E/launch.py +188 -0
- harness/E/prompts.py +28 -0
- harness/E/sweep.py +78 -0
- tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc +0 -0
- tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807 +0 -0
- tests/test_A/test_run.py +10 -3
- tests/test_symbolic/__pycache__/test_solver.cpython-311-pytest-8.3.5.pyc +0 -0
- tests/test_symbolic/test_solver.py +55 -0
README.md
CHANGED
|
@@ -24,7 +24,7 @@ data/ VSI-Bench videos, spatial codes (encoder output), caches
|
|
| 24 |
encoder/ builds spatial codes (compact + explicit, perceived + ground truth)
|
| 25 |
inference/ SAM3 + Depth Anything 3 raw-model runners (encoder's inputs)
|
| 26 |
symbolic/ formula-driven solver -- answers questions from a spatial code, no VLM
|
| 27 |
-
harness/A, B, C, D
|
| 28 |
analysis/ per-category scoring, cross-harness comparison, CSV export
|
| 29 |
experiments/ separate, concluded track: geometry-formula tuning for encoder/
|
| 30 |
results/ every harness's + symbolic's output, one JSON per question
|
|
@@ -87,6 +87,11 @@ annotations don't carry — per-object "first visible time," a property of a spe
|
|
| 87 |
camera walkthrough, not of a static 3D scan — is sourced from VSI-Bench's own real
|
| 88 |
`obj_appearance_order` question answers where available (topologically merged across
|
| 89 |
every such question for a scene) and left `null`, never fabricated, where it isn't.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
Rebuild with `python -m encoder.ground_truth`.
|
| 91 |
|
| 92 |
### `symbolic/` — the formula-driven solver (no VLM)
|
|
@@ -110,9 +115,9 @@ is documented with its measured before/after numbers in
|
|
| 110 |
the VLM-harness hypotheses below, and its findings are already baked into
|
| 111 |
`encoder/geometric.py` and `symbolic/solver.py` as shipped.
|
| 112 |
|
| 113 |
-
### `harness/A`, `B`, `C`, `D` — VLM-based answering
|
| 114 |
|
| 115 |
-
All
|
| 116 |
(Qwen3.5-4B, Qwen3.5-2B, InternVL3.5-4B), greedy-decoded, and write one untruncated JSON
|
| 117 |
result per question in the identical record shape (so any of them can be pointed at
|
| 118 |
`analysis.aggregate` with no per-harness special-casing). They differ only in what's
|
|
@@ -124,6 +129,11 @@ shown to the model:
|
|
| 124 |
| **B** | spatial code as text only | perceived (`encoder/`, SAM3+DA3) |
|
| 125 |
| **C** | video frames **and** spatial code, sourced from the identical `(depth, tracking, input, frames)` config so they can never mismatch | perceived (`encoder/`, SAM3+DA3) |
|
| 126 |
| **D** | spatial code as text only | **ground truth** (`encoder/ground_truth.py`) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
Every harness's prompt (`prompts.py`) uses the same context-line → code-JSON →
|
| 129 |
question → post-prompt structure, reusing harness A's exact question-type split and
|
|
@@ -133,14 +143,20 @@ table and appearance order; only compact has per-instance orientation vectors)
|
|
| 133 |
never over- or under-claims either format; the code's own embedded schema legend is
|
| 134 |
what actually documents every field present in a given call.
|
| 135 |
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
forced `"Final answer:"` continuation only if the model
|
| 140 |
-
via literal generation continuation, not a new chat turn)
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
| 145 |
D additionally has `harness/D/symbolic_eval.py`, which runs the real symbolic solver
|
| 146 |
(no VLM at all) directly on ground-truth codes — the perfect-information ceiling,
|
|
@@ -166,6 +182,7 @@ depth/tracking runs of the same scene/model/format can never collide on disk.
|
|
| 166 |
python -m harness.A.sweep --models all --frame-selections all --frames 16,32,64
|
| 167 |
python -m harness.B.sweep --models all --spatial-code-formats all --input-selections selective --frames 32
|
| 168 |
python -m harness.D.sweep --models all # both spatial_code_formats always -- see "Plan D" below
|
|
|
|
| 169 |
python -m harness.D.symbolic_eval --spatial-code-format explicit # perfect-information ceiling
|
| 170 |
```
|
| 171 |
|
|
@@ -173,10 +190,11 @@ python -m harness.D.symbolic_eval --spatial-code-format explicit # perfect-inf
|
|
| 173 |
|
| 174 |
| Harness | Path |
|
| 175 |
|---|---|
|
| 176 |
-
| A | `results/A/<model>/<frame_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 177 |
-
| B | `results/B/<model>/<format>/<depth>/<tracking>/<input_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 178 |
-
| C | `results/C/<model>/<format>/<depth>/<tracking>/<input_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 179 |
-
| D | `results/D/<model>/<format>/<scene>/<question_id>.json` (VLM path only — `symbolic_eval` writes to `results/symbolic/ground truth/...` below, not here) |
|
|
|
|
| 180 |
| symbolic (production) | `results/symbolic/<depth>/<tracking>/<input_selection>/<frame_count>/<format>/<scene>/<question_id>.json` |
|
| 181 |
| symbolic (ground truth) | `results/symbolic/ground truth/<format>/<scene>/<question_id>.json` |
|
| 182 |
|
|
@@ -190,11 +208,17 @@ harness's per-question record already shares the same shape):
|
|
| 190 |
- `analysis/aggregate.py` — per-category MRA/accuracy scores via the *real* official
|
| 191 |
VSI-Bench aggregator (never reimplemented, imported directly from
|
| 192 |
`thinking-in-space`), plus latency/token/forced-answer telemetry. `--harness
|
| 193 |
-
{A,B,C,D}` or `--results-dir`; `--csv <path>` to export.
|
| 194 |
-
- `analysis/compare.py` — joins
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
```bash
|
| 200 |
python -m analysis.aggregate --harness B --csv b_scores.csv
|
|
@@ -315,7 +339,7 @@ python -m harness.A.launch --model NAME --frame-selection {uniform,selective} --
|
|
| 315 |
[scene | --scenes a,b,c]
|
| 316 |
|
| 317 |
python -m harness.A.sweep --models {NAME,...|all} --frame-selections {uniform,selective|all} \
|
| 318 |
-
--frames N,N,... [--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 319 |
```
|
| 320 |
|
| 321 |
### `harness/B` — spatial code only (text)
|
|
@@ -336,8 +360,9 @@ python -m harness.B.sweep --models {NAME,...|all} --spatial-code-formats {explic
|
|
| 336 |
[--depths {relative,metric|all}] [--trackings {tracking,"no tracking"|all}] \
|
| 337 |
[--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 338 |
```
|
| 339 |
-
B
|
| 340 |
-
|
|
|
|
| 341 |
|
| 342 |
### `harness/C` — frames + spatial code
|
| 343 |
|
|
@@ -364,7 +389,7 @@ python -m harness.D.launch --model NAME --spatial-code-format {explicit,compact}
|
|
| 364 |
[--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 365 |
|
| 366 |
python -m harness.D.sweep --models {NAME,...|all} [--spatial-code-formats {explicit,compact|all}] \
|
| 367 |
-
[--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 368 |
|
| 369 |
# perfect-information ceiling: real symbolic solver directly on ground-truth codes, no VLM
|
| 370 |
# writes into results/symbolic/ground truth/<format>/... (not results/D/...)
|
|
@@ -372,15 +397,82 @@ python -m harness.D.symbolic_eval --spatial-code-format {explicit,compact} \
|
|
| 372 |
[--limit N] [--results-dir DIR] [--no-write] [scene | --scenes a,b,c]
|
| 373 |
```
|
| 374 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
### `analysis/` — aggregation and comparison
|
| 376 |
|
| 377 |
```bash
|
| 378 |
-
python -m analysis.aggregate --harness {A,B,C,D} [--csv PATH] [--json]
|
| 379 |
python -m analysis.aggregate --results-dir DIR [--csv PATH] [--json] # explicit path instead
|
| 380 |
python -m analysis.compare [--a-results-dir DIR] [--b-results-dir DIR] [--c-results-dir DIR] \
|
| 381 |
-
[--csv PATH] [--json]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
```
|
| 383 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 384 |
### `tests/`
|
| 385 |
|
| 386 |
```bash
|
|
@@ -427,6 +519,28 @@ that makes it a *measurable* claim rather than a plausible-sounding one — a re
|
|
| 427 |
control, a shared record schema, an already-logged telemetry field, or a provable
|
| 428 |
derivation — not just an assertion resting on the experiment "probably" working.
|
| 429 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
Anchor findings the hypotheses are grounded in: VSI-Bench's own manual error analysis
|
| 431 |
attributes ~71% of MLLM errors to spatial reasoning (40% relational, 31%
|
| 432 |
egocentric-allocentric transform), ~15% to perception, ~14% to language; chain-of-thought
|
|
@@ -500,15 +614,18 @@ reasoning capacity, was their binding constraint.
|
|
| 500 |
harness with a single `--spatial-code-format` flag, at identical scenes/questions.
|
| 501 |
- **H12 — verbosity × capacity.** Compact's fuller schema helps 4B, hurts 2B.
|
| 502 |
*Justified by*: same mechanism as H11, cut by model instead of protocol.
|
| 503 |
-
- **H13 —
|
| 504 |
-
|
| 505 |
-
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
|
|
|
|
|
|
|
|
|
| 512 |
|
| 513 |
### Theme 5 — Perception inputs (frame selection and count)
|
| 514 |
|
|
@@ -549,17 +666,74 @@ reasoning capacity, was their binding constraint.
|
|
| 549 |
directly comparable because B is evaluated by the exact same official scorer and
|
| 550 |
category breakdown the source paper itself used.
|
| 551 |
|
| 552 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
|
| 554 |
Every hypothesis above that concerns *encoder* error rather than *reasoning* error (H1,
|
| 555 |
H4, H6, H7, H11, H13) gets an additional, sharper cross-check for free: D re-answers B's
|
| 556 |
-
same questions with a **ground-truth** spatial code instead of a perceived one
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
project's opening claim.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 563 |
|
| 564 |
---
|
| 565 |
|
|
@@ -572,6 +746,8 @@ selection, and spatial-code format would otherwise multiply the run count far be
|
|
| 572 |
what's needed to answer the hypotheses above.
|
| 573 |
|
| 574 |
**Step 1 — Plan A decides frame count and input selection.**
|
|
|
|
|
|
|
| 575 |
|
| 576 |
```bash
|
| 577 |
python -m harness.A.sweep --models all --frame-selections all --frames 16,32,64
|
|
@@ -590,6 +766,17 @@ better than 32-frame ones for the encoder side either — the tie-break isn't a
|
|
| 590 |
coin-flip, it's backed by evidence already in hand from a different part of this
|
| 591 |
project.
|
| 592 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
**Step 2 — Regenerate spatial codes at the winning config, immediately after Step 1.**
|
| 594 |
|
| 595 |
This has to happen right after Plan A, *before* Plan B, not later: only 72 of
|
|
@@ -601,6 +788,13 @@ to be `uniform` (not `selective`), this step is gated on building the SAM3 raw
|
|
| 601 |
masklet cache for uniform-mode sampling first, since that cache currently only exists
|
| 602 |
for `selective`.
|
| 603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
**Step 3 — Plan B decides spatial-code format.**
|
| 605 |
|
| 606 |
```bash
|
|
@@ -611,6 +805,10 @@ python -m harness.B.sweep --models all --spatial-code-formats all \
|
|
| 611 |
6 configs (3 models × {explicit, compact}), input selection and frame count fixed from
|
| 612 |
Step 1. Aggregate with `analysis.aggregate --harness B`; average "overall" per format
|
| 613 |
across the 3 models — the argmax format is `format*`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
|
| 615 |
**Step 4 — Plan C runs the fully-fixed config.**
|
| 616 |
|
|
@@ -620,6 +818,7 @@ python -m harness.C.sweep --models all --spatial-code-formats <format*> \
|
|
| 620 |
```
|
| 621 |
|
| 622 |
3 configs (one per model) — every non-model axis is now fixed by Steps 1–3.
|
|
|
|
| 623 |
|
| 624 |
**Step 5 — Plan D: the ground-truth ceiling, run any time after Step 1.**
|
| 625 |
|
|
@@ -636,21 +835,71 @@ annotation-only). Running both is the only way to see whether B's real-perceptio
|
|
| 636 |
format ranking still holds under perfect information. D has no dependency on Steps 2–4
|
| 637 |
completing — it can run in parallel with them, since ground truth needs no perceived
|
| 638 |
spatial code at all.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 639 |
|
| 640 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
|
| 642 |
```bash
|
| 643 |
python -m analysis.compare --csv comparison.csv
|
| 644 |
```
|
| 645 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 646 |
Cross-harness comparison (A vs. B vs. C at the frozen config) plus every telemetry-only
|
| 647 |
hypothesis (H8, H9, H19, H20) that needs no new runs, just the JSONs already on disk.
|
| 648 |
|
| 649 |
-
**Optional follow-ons**, pursued only if the headline results above warrant it
|
|
|
|
| 650 |
|
| 651 |
-
- Re-run Steps 3–4 a second time under the *extended* protocol at the same frozen
|
| 652 |
-
config, to get the 16-token-vs-extended comparison (H7, H10) without reopening the
|
| 653 |
-
config-selection question.
|
| 654 |
- The H6 perturbation probe: clone harness C's prompt path with one object's
|
| 655 |
position/size perturbed in the injected code, on a sample of questions from the
|
| 656 |
frozen C config.
|
|
|
|
| 24 |
encoder/ builds spatial codes (compact + explicit, perceived + ground truth)
|
| 25 |
inference/ SAM3 + Depth Anything 3 raw-model runners (encoder's inputs)
|
| 26 |
symbolic/ formula-driven solver -- answers questions from a spatial code, no VLM
|
| 27 |
+
harness/A, B, C, D, E VLM-based answering, one harness per input configuration
|
| 28 |
analysis/ per-category scoring, cross-harness comparison, CSV export
|
| 29 |
experiments/ separate, concluded track: geometry-formula tuning for encoder/
|
| 30 |
results/ every harness's + symbolic's output, one JSON per question
|
|
|
|
| 87 |
camera walkthrough, not of a static 3D scan — is sourced from VSI-Bench's own real
|
| 88 |
`obj_appearance_order` question answers where available (topologically merged across
|
| 89 |
every such question for a scene) and left `null`, never fabricated, where it isn't.
|
| 90 |
+
**Known circularity**: because that field is reconstructed from the answer keys of the
|
| 91 |
+
very `obj_appearance_order` questions being scored, every D and symbolic-ground-truth
|
| 92 |
+
result on that category is contaminated by construction — exclude
|
| 93 |
+
`obj_appearance_order` from any ceiling or perception-error claim built on
|
| 94 |
+
ground-truth codes, and report it separately with this caveat.
|
| 95 |
Rebuild with `python -m encoder.ground_truth`.
|
| 96 |
|
| 97 |
### `symbolic/` — the formula-driven solver (no VLM)
|
|
|
|
| 115 |
the VLM-harness hypotheses below, and its findings are already baked into
|
| 116 |
`encoder/geometric.py` and `symbolic/solver.py` as shipped.
|
| 117 |
|
| 118 |
+
### `harness/A`, `B`, `C`, `D`, `E` — VLM-based answering
|
| 119 |
|
| 120 |
+
All five harnesses answer the same real VSI-Bench questions with one of three VLMs
|
| 121 |
(Qwen3.5-4B, Qwen3.5-2B, InternVL3.5-4B), greedy-decoded, and write one untruncated JSON
|
| 122 |
result per question in the identical record shape (so any of them can be pointed at
|
| 123 |
`analysis.aggregate` with no per-harness special-casing). They differ only in what's
|
|
|
|
| 129 |
| **B** | spatial code as text only | perceived (`encoder/`, SAM3+DA3) |
|
| 130 |
| **C** | video frames **and** spatial code, sourced from the identical `(depth, tracking, input, frames)` config so they can never mismatch | perceived (`encoder/`, SAM3+DA3) |
|
| 131 |
| **D** | spatial code as text only | **ground truth** (`encoder/ground_truth.py`) |
|
| 132 |
+
| **E** | question text only — the **blind floor** (no frames, no code, no scene input at all) | — |
|
| 133 |
+
|
| 134 |
+
E exists because VSI-Bench's own paper shows blind LLMs beat chance on several
|
| 135 |
+
categories through pure priors (typical room/object sizes) — without this floor, a
|
| 136 |
+
B-over-A gain could partly be prior-shifting rather than actual geometry use.
|
| 137 |
|
| 138 |
Every harness's prompt (`prompts.py`) uses the same context-line → code-JSON →
|
| 139 |
question → post-prompt structure, reusing harness A's exact question-type split and
|
|
|
|
| 143 |
never over- or under-claims either format; the code's own embedded schema legend is
|
| 144 |
what actually documents every field present in a given call.
|
| 145 |
|
| 146 |
+
The generation protocol is a real, first-class axis on EVERY harness — "base" (the
|
| 147 |
+
VSI-Bench paper's own protocol: greedy decoding, 16-token output cap, the exact
|
| 148 |
+
`lmms_eval` generation config) or "extended" (`answer_extended`: a large 2048-token
|
| 149 |
+
reasoning budget, with a short forced `"Final answer:"` continuation only if the model
|
| 150 |
+
doesn't conclude on its own, via literal generation continuation, not a new chat turn).
|
| 151 |
+
A and E default to base and opt into extended via `--extended`; B, C, and D default to
|
| 152 |
+
extended and opt into base via `--base-protocol`. Both directions run the IDENTICAL
|
| 153 |
+
generation mechanism (`answer()` / `answer_extended()`, shared by every harness), so
|
| 154 |
+
the protocol × representation grid (H7) is measured with the same code in every cell —
|
| 155 |
+
and the protocol is a results-path segment (`results/<harness>/<model>/<protocol>/...`)
|
| 156 |
+
plus a `"protocol"` record field, so the two protocols' records can never collide on
|
| 157 |
+
disk. Every record logs `reasoning_token_count`, `hit_token_limit`, and `forced`,
|
| 158 |
+
whether or not the extended protocol was used, so protocol effects can always be
|
| 159 |
+
measured after the fact.
|
| 160 |
|
| 161 |
D additionally has `harness/D/symbolic_eval.py`, which runs the real symbolic solver
|
| 162 |
(no VLM at all) directly on ground-truth codes — the perfect-information ceiling,
|
|
|
|
| 182 |
python -m harness.A.sweep --models all --frame-selections all --frames 16,32,64
|
| 183 |
python -m harness.B.sweep --models all --spatial-code-formats all --input-selections selective --frames 32
|
| 184 |
python -m harness.D.sweep --models all # both spatial_code_formats always -- see "Plan D" below
|
| 185 |
+
python -m harness.E.sweep --models all # blind floor, base protocol
|
| 186 |
python -m harness.D.symbolic_eval --spatial-code-format explicit # perfect-information ceiling
|
| 187 |
```
|
| 188 |
|
|
|
|
| 190 |
|
| 191 |
| Harness | Path |
|
| 192 |
|---|---|
|
| 193 |
+
| A | `results/A/<model>/<protocol>/<frame_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 194 |
+
| B | `results/B/<model>/<protocol>/<format>/<depth>/<tracking>/<input_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 195 |
+
| C | `results/C/<model>/<protocol>/<format>/<depth>/<tracking>/<input_selection>/<frame_count>/<scene>/<question_id>.json` |
|
| 196 |
+
| D | `results/D/<model>/<protocol>/<format>/<scene>/<question_id>.json` (VLM path only — `symbolic_eval` writes to `results/symbolic/ground truth/...` below, not here) |
|
| 197 |
+
| E | `results/E/<model>/<protocol>/<scene>/<question_id>.json` |
|
| 198 |
| symbolic (production) | `results/symbolic/<depth>/<tracking>/<input_selection>/<frame_count>/<format>/<scene>/<question_id>.json` |
|
| 199 |
| symbolic (ground truth) | `results/symbolic/ground truth/<format>/<scene>/<question_id>.json` |
|
| 200 |
|
|
|
|
| 208 |
- `analysis/aggregate.py` — per-category MRA/accuracy scores via the *real* official
|
| 209 |
VSI-Bench aggregator (never reimplemented, imported directly from
|
| 210 |
`thinking-in-space`), plus latency/token/forced-answer telemetry. `--harness
|
| 211 |
+
{A,B,C,D,E}` or `--results-dir`; `--csv <path>` to export.
|
| 212 |
+
- `analysis/compare.py` — joins every harness (A/B/C, plus D and E on their
|
| 213 |
+
`(model, protocol)` axes) into one side-by-side table, scored on the EXACT
|
| 214 |
+
question-id intersection of every cell in a row — never on mismatched question sets
|
| 215 |
+
(a harness that covered fewer scenes is compared only on the shared questions, with
|
| 216 |
+
each cell's full count reported alongside so coverage loss is a visible result).
|
| 217 |
+
`--csv <path>` to export.
|
| 218 |
+
- `analysis/stats.py` — scene-clustered paired bootstrap for any two result cells:
|
| 219 |
+
observed mean-score delta plus a reproducible (fixed-seed) confidence interval over
|
| 220 |
+
the exact question intersection, resampling scenes (not questions, which are
|
| 221 |
+
correlated within a scene).
|
| 222 |
|
| 223 |
```bash
|
| 224 |
python -m analysis.aggregate --harness B --csv b_scores.csv
|
|
|
|
| 339 |
[scene | --scenes a,b,c]
|
| 340 |
|
| 341 |
python -m harness.A.sweep --models {NAME,...|all} --frame-selections {uniform,selective|all} \
|
| 342 |
+
--frames N,N,... [--results-dir DIR] [--rebuild] [--extended] [scene | --scenes a,b,c]
|
| 343 |
```
|
| 344 |
|
| 345 |
### `harness/B` — spatial code only (text)
|
|
|
|
| 360 |
[--depths {relative,metric|all}] [--trackings {tracking,"no tracking"|all}] \
|
| 361 |
[--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 362 |
```
|
| 363 |
+
B defaults to the extended protocol (`answer_extended`); pass `--base-protocol` (on
|
| 364 |
+
`run`/`launch`/`sweep`) to run harness.A's exact fixed 16-token protocol instead —
|
| 365 |
+
needed for the protocol × representation cells of H7/H11/H18.
|
| 366 |
|
| 367 |
### `harness/C` — frames + spatial code
|
| 368 |
|
|
|
|
| 389 |
[--results-dir DIR] [--rebuild] [scene | --scenes a,b,c]
|
| 390 |
|
| 391 |
python -m harness.D.sweep --models {NAME,...|all} [--spatial-code-formats {explicit,compact|all}] \
|
| 392 |
+
[--results-dir DIR] [--rebuild] [--base-protocol] [scene | --scenes a,b,c]
|
| 393 |
|
| 394 |
# perfect-information ceiling: real symbolic solver directly on ground-truth codes, no VLM
|
| 395 |
# writes into results/symbolic/ground truth/<format>/... (not results/D/...)
|
|
|
|
| 397 |
[--limit N] [--results-dir DIR] [--no-write] [scene | --scenes a,b,c]
|
| 398 |
```
|
| 399 |
|
| 400 |
+
### `harness/E` — the blind floor (question only)
|
| 401 |
+
|
| 402 |
+
No scene input of any kind — question (and options) plus the standard post-prompt is
|
| 403 |
+
the entire prompt. Base 16-token protocol by default, `--extended` opt-in, same as A:
|
| 404 |
+
|
| 405 |
+
```bash
|
| 406 |
+
python -m harness.E.run --model NAME [--scene ID] [--limit N] [--device cuda] \
|
| 407 |
+
[--results-dir DIR] [--no-write] [--extended] [--reasoning-budget N] [--force-budget N]
|
| 408 |
+
|
| 409 |
+
python -m harness.E.launch --model NAME [--results-dir DIR] [--rebuild] [--extended] \
|
| 410 |
+
[scene | --scenes a,b,c]
|
| 411 |
+
|
| 412 |
+
python -m harness.E.sweep --models {NAME,...|all} [--results-dir DIR] [--rebuild] \
|
| 413 |
+
[--extended] [scene | --scenes a,b,c]
|
| 414 |
+
```
|
| 415 |
+
|
| 416 |
### `analysis/` — aggregation and comparison
|
| 417 |
|
| 418 |
```bash
|
| 419 |
+
python -m analysis.aggregate --harness {A,B,C,D,E} [--csv PATH] [--json]
|
| 420 |
python -m analysis.aggregate --results-dir DIR [--csv PATH] [--json] # explicit path instead
|
| 421 |
python -m analysis.compare [--a-results-dir DIR] [--b-results-dir DIR] [--c-results-dir DIR] \
|
| 422 |
+
[--d-results-dir DIR] [--e-results-dir DIR] [--csv PATH] [--json]
|
| 423 |
+
|
| 424 |
+
# scene-clustered paired bootstrap: delta, CI, and two-sided p-value; the primary
|
| 425 |
+
# hypothesis family is corrected with analysis.stats.holm_bonferroni
|
| 426 |
+
python -m analysis.stats --x-dir <baseline cell dir> --y-dir <comparison cell dir> \
|
| 427 |
+
[--iterations N] [--seed N] [--confidence 0.95]
|
| 428 |
+
|
| 429 |
+
# H26: solver-certified sufficiency decomposition of one VLM cell
|
| 430 |
+
python -m analysis.sufficiency --vlm-dir <B cell> --solver-dir <matching symbolic cell> \
|
| 431 |
+
[--threshold 1.0] [--exclude obj_appearance_order,route_planning] [--json]
|
| 432 |
+
|
| 433 |
+
# H23: deterministic chain-of-thought audit (no LLM judge) over B/D extended records
|
| 434 |
+
python -m analysis.cot_audit --results-dir <B or D cell> [--tolerance 0.01] [--json]
|
| 435 |
+
|
| 436 |
+
# H19 (exploratory): solved-set overlap across cells, exact question intersection
|
| 437 |
+
python -m analysis.solvability --cell A=<dir> --cell B=<dir> [--threshold 1.0] [--json]
|
| 438 |
+
|
| 439 |
+
# H25: solver computation-depth vs VLM accuracy (pass base + extended cells to read
|
| 440 |
+
# the depth x protocol interaction)
|
| 441 |
+
python -m analysis.depth --results-dir <cell> [--results-dir <cell2>] [--json]
|
| 442 |
```
|
| 443 |
|
| 444 |
+
### `corruption/` — perception-error mechanics (Theme 8)
|
| 445 |
+
|
| 446 |
+
Transforms always act on the COMPACT ground-truth code; the requested format is then
|
| 447 |
+
derived through encoder's own `_explicit_from_compact`, so corrupted formats can
|
| 448 |
+
never disagree. The VLM arm reuses `harness.D.run` unmodified (its `code_transform`
|
| 449 |
+
hook); the solver arm is free (CPU). `--sample` enforces the pre-registered
|
| 450 |
+
question sample:
|
| 451 |
+
|
| 452 |
+
```bash
|
| 453 |
+
# one condition, either arm
|
| 454 |
+
python -m corruption.run --arm {vlm,solver} --transform NAME --magnitude M \
|
| 455 |
+
[--model NAME] [--spatial-code-format {explicit,compact}] [--scenes a,b,c] \
|
| 456 |
+
[--sample analysis/corruption_sample.json] [--results-dir DIR]
|
| 457 |
+
|
| 458 |
+
# H24's certification gate: only (scene, transform, magnitude) triples the solver
|
| 459 |
+
# certifies answer-preserving enter the invariance analysis
|
| 460 |
+
python -m corruption.run --arm certify --transform {translate,rotate-z,reorder,round-precision} \
|
| 461 |
+
--magnitude M --scenes a,b,c
|
| 462 |
+
|
| 463 |
+
# grid looper (Step 6.5): solver arm always, VLM arm per model
|
| 464 |
+
python -m corruption.launch --arm both --models qwen3.5-4b,internvl3.5-4b \
|
| 465 |
+
--transforms position-jitter,dimension-noise,drop-objects,hallucinate-objects \
|
| 466 |
+
--magnitudes 0.1,0.25,0.5,1.0 --sample analysis/corruption_sample.json
|
| 467 |
+
```
|
| 468 |
+
|
| 469 |
+
Transform names: noise = `position-jitter`, `dimension-noise`, `drop-objects`,
|
| 470 |
+
`hallucinate-objects`, `class-swap`, `empirical` (sampled from the measured SAM3+DA3
|
| 471 |
+
residual distribution; magnitude = scale, 1.0 = the real operating point); chimera =
|
| 472 |
+
`chimera-gt-inventory`, `chimera-perceived-inventory` (H22); probes = `single-object`
|
| 473 |
+
(H6), `wrong-scene`; invariance (H24) = `translate`, `rotate-z`, `reorder`,
|
| 474 |
+
`round-precision`.
|
| 475 |
+
|
| 476 |
### `tests/`
|
| 477 |
|
| 478 |
```bash
|
|
|
|
| 519 |
control, a shared record schema, an already-logged telemetry field, or a provable
|
| 520 |
derivation — not just an assertion resting on the experiment "probably" working.
|
| 521 |
|
| 522 |
+
Not every hypothesis below has equal standing, and the run plan says so explicitly.
|
| 523 |
+
The full frozen classification (with directions, exclusions, and the corruption-arm
|
| 524 |
+
sample definition) lives in [`analysis/preregistration.md`](analysis/preregistration.md),
|
| 525 |
+
committed and backed up BEFORE any scheduled run executes. Summary:
|
| 526 |
+
|
| 527 |
+
- **Novel primary (Holm–Bonferroni-corrected family, all cells scheduled)**: H7 (the
|
| 528 |
+
protocol × representation interaction) and Theme 8's H21–H26 below. These six are
|
| 529 |
+
the program's literature-checked novel claims.
|
| 530 |
+
- **Confirmatory (rigorously tested, but extensions of the two source papers)**:
|
| 531 |
+
H1–H5, H10–H13. H1's headline read is E-corrected (gain over the blind floor, not
|
| 532 |
+
over zero) and every cross-harness delta is computed on matched question sets
|
| 533 |
+
(`analysis.compare`) with scene-clustered bootstrap CIs (`analysis.stats`).
|
| 534 |
+
- **Supporting**: H27 (format-flip brittleness under certified sufficiency).
|
| 535 |
+
- **Exploratory (reported as observations, not tests)**: H8, H9 (telemetry,
|
| 536 |
+
difficulty-confounded), H17, H18 (two families / one scale pair), H19 (solved-set
|
| 537 |
+
overlap — established methodology applied here), H20.
|
| 538 |
+
- **Out of scope by design**: H14, H16 (secondary sweeps, unscheduled); H15 (Step 2
|
| 539 |
+
builds codes for the winning frame selection only — the second perception cache is
|
| 540 |
+
deliberately not funded); H6 runs as a corruption-module probe but its topic
|
| 541 |
+
(text-over-vision anchoring) is established literature, so it is reported as an
|
| 542 |
+
instantiation, not a novel claim.
|
| 543 |
+
|
| 544 |
Anchor findings the hypotheses are grounded in: VSI-Bench's own manual error analysis
|
| 545 |
attributes ~71% of MLLM errors to spatial reasoning (40% relational, 31%
|
| 546 |
egocentric-allocentric transform), ~15% to perception, ~14% to language; chain-of-thought
|
|
|
|
| 614 |
harness with a single `--spatial-code-format` flag, at identical scenes/questions.
|
| 615 |
- **H12 — verbosity × capacity.** Compact's fuller schema helps 4B, hurts 2B.
|
| 616 |
*Justified by*: same mechanism as H11, cut by model instead of protocol.
|
| 617 |
+
- **H13 — consistency-by-construction (the cleanest control in this program).** The
|
| 618 |
+
two formats can never *disagree* about a scene's geometry: explicit is a provable,
|
| 619 |
+
mechanical derivation of compact — the same shared `_explicit_from_compact` function
|
| 620 |
+
regardless of source, empirically verified (0 mismatches across every measured
|
| 621 |
+
field: positions, dimensions, distance table, floor area, appearance order) after
|
| 622 |
+
fixing a real orientation-vector renormalization bug that briefly broke the
|
| 623 |
+
guarantee. Note what this does NOT claim: the formats are not informationally
|
| 624 |
+
equal — compact carries per-instance orientation vectors explicit drops, and
|
| 625 |
+
explicit carries precomputed derivations (distance table, floor area, appearance
|
| 626 |
+
order) compact leaves implicit. A B(explicit)-vs-B(compact) gap is therefore
|
| 627 |
+
presentation + computation-offloading + that field difference — with *inconsistency*
|
| 628 |
+
ruled out by construction, which is the part neither source paper could rule out.
|
| 629 |
|
| 630 |
### Theme 5 — Perception inputs (frame selection and count)
|
| 631 |
|
|
|
|
| 666 |
directly comparable because B is evaluated by the exact same official scorer and
|
| 667 |
category breakdown the source paper itself used.
|
| 668 |
|
| 669 |
+
### Theme 8 — Perception-error mechanics and solver-certified analysis (novel core)
|
| 670 |
+
|
| 671 |
+
These ride on the `corruption/` module (parameterized transformations of spatial
|
| 672 |
+
codes fed through harness.D's unmodified prompt path) and on the deterministic
|
| 673 |
+
solver's unique role as a per-question certification instrument. All corruption arms
|
| 674 |
+
use one shared, pre-registered ~600-question sample (7 categories, appearance order
|
| 675 |
+
excluded for circularity; see `analysis/preregistration.md`).
|
| 676 |
+
|
| 677 |
+
- **H21 — perception-requirements curve.** VLM accuracy vs. calibrated corruption of
|
| 678 |
+
ground-truth codes (position jitter, dimension noise, dropped/hallucinated
|
| 679 |
+
objects, class swaps), with one corruption mode sampled from the REAL SAM3+DA3
|
| 680 |
+
residual distribution (measured per class from perceived-vs-GT code pairs), not
|
| 681 |
+
just iid Gaussian. *Validation*: the synthetic curve must predict B's real
|
| 682 |
+
measured accuracy at the pipeline's measured error level — a held-out test, since
|
| 683 |
+
B's numbers are never used in fitting. Inverted, the curves give per-category
|
| 684 |
+
perception tolerance specs. The solver runs the same corrupted codes for free, so
|
| 685 |
+
soft (VLM) vs. brittle (formula) degradation is compared on identical input.
|
| 686 |
+
- **H22 — chimera decomposition.** Hybrid codes — ground-truth object inventory with
|
| 687 |
+
perceived geometry, and the reverse — causally split the B→D gap into detection-
|
| 688 |
+
error cost vs. geometric-error cost, per category. Interventional, where existing
|
| 689 |
+
error taxonomies are observational.
|
| 690 |
+
- **H23 — deterministic chain-of-thought audit.** Every number in B/D's logged
|
| 691 |
+
``reasoning_text`` is mechanically checked against the exact code the model was
|
| 692 |
+
given — no LLM judge — decomposing wrong answers into retrieval errors (cited a
|
| 693 |
+
value not in the code), transcription errors (right field, wrong value), and
|
| 694 |
+
computation errors (correct values, wrong arithmetic). Impossible with pixel
|
| 695 |
+
input; pure post-hoc analysis over records the scheduled runs already produce.
|
| 696 |
+
- **H24 — coordinate-frame invariance.** Solver-certified answer-preserving
|
| 697 |
+
re-parameterizations (origin translation, frame rotation, unit conversion, object
|
| 698 |
+
reorder, precision rounding) change ZERO information; any accuracy drop is
|
| 699 |
+
measured representation-frame brittleness. The solver's identical answers on the
|
| 700 |
+
transformed code are the proof the transformation was truly null.
|
| 701 |
+
- **H25 — computation-depth transfer.** The solver logs its per-question operation
|
| 702 |
+
count (an executable difficulty metric, not a human annotation); prediction: VLM
|
| 703 |
+
accuracy declines with depth, and H7's extended-protocol benefit concentrates in
|
| 704 |
+
high-depth questions. Zero new runs.
|
| 705 |
+
- **H26 — sufficiency-certificate decomposition.** The solver, run on the identical
|
| 706 |
+
perceived code B saw (free, CPU), certifies per question whether the answer is
|
| 707 |
+
derivably present. Conditioning every B comparison on that certificate separates
|
| 708 |
+
PROVEN reasoning failures (solver-correct, VLM-wrong) from PROVEN information
|
| 709 |
+
failures (solver-wrong) — a per-question certified split no correlational error
|
| 710 |
+
analysis can make.
|
| 711 |
+
- **H27 (supporting) — format-flip brittleness.** Restricted to questions the solver
|
| 712 |
+
answers correctly from BOTH formats (information certified sufficient in both
|
| 713 |
+
presentations), any B(explicit)-vs-B(compact) answer flip is pure presentation
|
| 714 |
+
sensitivity with semantics held provably fixed.
|
| 715 |
+
|
| 716 |
+
### Plan D and the deterministic-solver ceiling (cross-cutting)
|
| 717 |
|
| 718 |
Every hypothesis above that concerns *encoder* error rather than *reasoning* error (H1,
|
| 719 |
H4, H6, H7, H11, H13) gets an additional, sharper cross-check for free: D re-answers B's
|
| 720 |
+
same questions with a **ground-truth** spatial code instead of a perceived one (B and
|
| 721 |
+
D's prompts are byte-identical — only the file loaded changes), and
|
| 722 |
+
`harness/D/symbolic_eval.py` additionally answers them with the deterministic solver:
|
| 723 |
+
perfect geometry plus deterministic, formula-driven reasoning. Any B→D gap at matched
|
| 724 |
+
format is attributable to perception error, not reasoning error, because nothing else
|
| 725 |
+
changes between the two runs — this is the concrete mechanism behind "how much of the
|
| 726 |
+
gap is imperfect perception" in this project's opening claim.
|
| 727 |
+
|
| 728 |
+
Two caveats bound what the solver run may be called: it is a *deterministic solver*
|
| 729 |
+
ceiling, not a perfect-reasoning one — its route_planning parser scores ~3% on
|
| 730 |
+
ground-truth codes (far below even option-guessing), so per-category it is only a
|
| 731 |
+
valid ceiling where the solver actually performs — and its `obj_appearance_order`
|
| 732 |
+
score is circular (see the ground-truth circularity note in the `encoder/` section)
|
| 733 |
+
and must be excluded from ceiling claims. Chained with E (the blind floor) and B, the
|
| 734 |
+
valid categories give a fully measured per-category error budget:
|
| 735 |
+
E → B → D → solver = priors → +perceived geometry → +perfect geometry → +deterministic
|
| 736 |
+
reasoning.
|
| 737 |
|
| 738 |
---
|
| 739 |
|
|
|
|
| 746 |
what's needed to answer the hypotheses above.
|
| 747 |
|
| 748 |
**Step 1 — Plan A decides frame count and input selection.**
|
| 749 |
+
*Hypotheses fed*: baseline arm of H1/H3/H7/H19; the selective-vs-uniform readout is a
|
| 750 |
+
within-benchmark check of the known keyframe-selection effect (confirmatory).
|
| 751 |
|
| 752 |
```bash
|
| 753 |
python -m harness.A.sweep --models all --frame-selections all --frames 16,32,64
|
|
|
|
| 766 |
coin-flip, it's backed by evidence already in hand from a different part of this
|
| 767 |
project.
|
| 768 |
|
| 769 |
+
**Step 1.5 — Blind floor, any time (near-free).**
|
| 770 |
+
|
| 771 |
+
```bash
|
| 772 |
+
python -m harness.E.sweep --models all
|
| 773 |
+
```
|
| 774 |
+
|
| 775 |
+
*Hypotheses fed*: the prior-knowledge floor every gain claim is corrected against,
|
| 776 |
+
and the contamination probe (E far above the paper's published blind baselines =
|
| 777 |
+
leakage evidence). Run it FIRST — it is the cheapest run in the program and its
|
| 778 |
+
contamination readout is worth having before burning the big sweeps.
|
| 779 |
+
|
| 780 |
**Step 2 — Regenerate spatial codes at the winning config, immediately after Step 1.**
|
| 781 |
|
| 782 |
This has to happen right after Plan A, *before* Plan B, not later: only 72 of
|
|
|
|
| 788 |
masklet cache for uniform-mode sampling first, since that cache currently only exists
|
| 789 |
for `selective`.
|
| 790 |
|
| 791 |
+
Immediately after Step 2, also run the ZERO-GPU solver pass over the regenerated
|
| 792 |
+
perceived codes (`symbolic.launch` at the frozen config, both formats) — this is
|
| 793 |
+
H26's sufficiency certificate and H27's dual-sufficiency filter, and it must exist
|
| 794 |
+
before B's results are analyzed. Commit the realized corruption-arm question sample
|
| 795 |
+
to `analysis/preregistration.md` at this point (procedure and seed are already
|
| 796 |
+
frozen there).
|
| 797 |
+
|
| 798 |
**Step 3 — Plan B decides spatial-code format.**
|
| 799 |
|
| 800 |
```bash
|
|
|
|
| 805 |
6 configs (3 models × {explicit, compact}), input selection and frame count fixed from
|
| 806 |
Step 1. Aggregate with `analysis.aggregate --harness B`; average "overall" per format
|
| 807 |
across the 3 models — the argmax format is `format*`.
|
| 808 |
+
*Hypotheses fed*: H1–H3 (vs A and E), H11–H13, H12; B's extended traces are H23's
|
| 809 |
+
audit corpus and H25's depth-transfer corpus; B's real accuracy at the pipeline's
|
| 810 |
+
measured error level is H21's held-out prediction target; every B comparison is
|
| 811 |
+
conditioned on H26's certificate.
|
| 812 |
|
| 813 |
**Step 4 — Plan C runs the fully-fixed config.**
|
| 814 |
|
|
|
|
| 818 |
```
|
| 819 |
|
| 820 |
3 configs (one per model) — every non-model axis is now fixed by Steps 1–3.
|
| 821 |
+
*Hypotheses fed*: H4, H5; C's cells complete H7's representation axis.
|
| 822 |
|
| 823 |
**Step 5 — Plan D: the ground-truth ceiling, run any time after Step 1.**
|
| 824 |
|
|
|
|
| 835 |
format ranking still holds under perfect information. D has no dependency on Steps 2–4
|
| 836 |
completing — it can run in parallel with them, since ground truth needs no perceived
|
| 837 |
spatial code at all.
|
| 838 |
+
*Hypotheses fed*: the B→D perception-error split (byte-identical prompts) and the
|
| 839 |
+
solver ceiling; D's traces join H23's audit corpus. `obj_appearance_order` is
|
| 840 |
+
excluded from every D/ceiling claim (circularity — see `encoder/` section).
|
| 841 |
+
|
| 842 |
+
**Step 6 — Protocol controls and the blind floor, after Steps 3–4, at the frozen
|
| 843 |
+
config.** These 15 runs de-confound the headline comparisons (they are what makes H1 a
|
| 844 |
+
single-manipulation comparison and H7 a complete 2×2, and they establish the
|
| 845 |
+
prior-knowledge floor E):
|
| 846 |
+
|
| 847 |
+
```bash
|
| 848 |
+
# A under the extended protocol (3 runs) -- so A-vs-B/C can be compared at MATCHED
|
| 849 |
+
# protocol, not 16-token-A vs extended-B
|
| 850 |
+
python -m harness.A.sweep --models all --frame-selections <selection*> --frames <frames*> --extended
|
| 851 |
+
|
| 852 |
+
# B under the base 16-token protocol, BOTH formats (6 runs) -- completes H7's
|
| 853 |
+
# protocol x representation grid and H11's 16-token cell
|
| 854 |
+
python -m harness.B.sweep --models all --spatial-code-formats all \
|
| 855 |
+
--input-selections <selection*> --frames <frames*> --base-protocol
|
| 856 |
+
|
| 857 |
+
# C under the base 16-token protocol, winning format (3 runs)
|
| 858 |
+
python -m harness.C.sweep --models all --spatial-code-formats <format*> \
|
| 859 |
+
--input-selections <selection*> --frames <frames*> --base-protocol
|
| 860 |
+
|
| 861 |
+
# The blind floor's extended arm (3 runs) -- the E-base runs happened at Step 1.5;
|
| 862 |
+
# extended-E is the "does reasoning help with nothing but priors" control for H7
|
| 863 |
+
python -m harness.E.sweep --models all --extended
|
| 864 |
+
```
|
| 865 |
|
| 866 |
+
*Hypotheses fed*: these cells complete H7's 2×2 (the headline novel interaction),
|
| 867 |
+
H10, H11's 16-token half, and H18's base-protocol read.
|
| 868 |
+
|
| 869 |
+
**Step 6.5 — Corruption arms, after Step 2 (sample) and alongside Step 6.**
|
| 870 |
+
|
| 871 |
+
All on the one pre-registered ~600-question sample, extended protocol, ground-truth
|
| 872 |
+
base codes; the solver runs every arm at zero GPU cost as the second reasoner:
|
| 873 |
+
|
| 874 |
+
```bash
|
| 875 |
+
# H21: 4 corruption types x 4 magnitudes, BOTH 4B models (~19k generations),
|
| 876 |
+
# including the empirical-residual noise mode calibrated from Step 2's codes
|
| 877 |
+
# H22: 2 chimera conditions (GT inventory x perceived geometry, and the reverse)
|
| 878 |
+
# H24: 5 solver-certified answer-preserving re-parameterizations
|
| 879 |
+
# H6 probe + wrong-scene control + serialization/wording robustness: 1 model each
|
| 880 |
+
python -m corruption.launch ... # see corruption/ docs once built
|
| 881 |
+
```
|
| 882 |
+
|
| 883 |
+
*Hypotheses fed*: H21, H22, H24 (novel primary); H6 instantiation; the wrong-code
|
| 884 |
+
and robustness controls that close the "does the model even read the code" and
|
| 885 |
+
"is it a prompt artifact" objections.
|
| 886 |
+
|
| 887 |
+
**Step 7 — Analysis, after every stage, not gated on the whole plan finishing.**
|
| 888 |
|
| 889 |
```bash
|
| 890 |
python -m analysis.compare --csv comparison.csv
|
| 891 |
```
|
| 892 |
|
| 893 |
+
*Hypotheses fed here with ZERO new runs*: H23 (`analysis/cot_audit.py` over B/D
|
| 894 |
+
traces), H25 (solver depth vs. VLM accuracy), H26 (certificate conditioning), H27
|
| 895 |
+
(dual-sufficiency format flips), H8/H9/H17–H20 (exploratory).
|
| 896 |
+
|
| 897 |
Cross-harness comparison (A vs. B vs. C at the frozen config) plus every telemetry-only
|
| 898 |
hypothesis (H8, H9, H19, H20) that needs no new runs, just the JSONs already on disk.
|
| 899 |
|
| 900 |
+
**Optional follow-ons**, pursued only if the headline results above warrant it (the
|
| 901 |
+
16-token-vs-extended comparison itself is NOT optional anymore — Step 6 schedules it):
|
| 902 |
|
|
|
|
|
|
|
|
|
|
| 903 |
- The H6 perturbation probe: clone harness C's prompt path with one object's
|
| 904 |
position/size perturbed in the injected code, on a sample of questions from the
|
| 905 |
frozen C config.
|
analysis/__pycache__/aggregate.cpython-311.pyc
CHANGED
|
Binary files a/analysis/__pycache__/aggregate.cpython-311.pyc and b/analysis/__pycache__/aggregate.cpython-311.pyc differ
|
|
|
analysis/__pycache__/compare.cpython-311.pyc
CHANGED
|
Binary files a/analysis/__pycache__/compare.cpython-311.pyc and b/analysis/__pycache__/compare.cpython-311.pyc differ
|
|
|
analysis/__pycache__/cot_audit.cpython-311.pyc
ADDED
|
Binary file (11 kB). View file
|
|
|
analysis/__pycache__/depth.cpython-311.pyc
ADDED
|
Binary file (6.68 kB). View file
|
|
|
analysis/__pycache__/solvability.cpython-311.pyc
ADDED
|
Binary file (7.52 kB). View file
|
|
|
analysis/__pycache__/stats.cpython-311.pyc
ADDED
|
Binary file (10.2 kB). View file
|
|
|
analysis/__pycache__/sufficiency.cpython-311.pyc
ADDED
|
Binary file (7.69 kB). View file
|
|
|
analysis/aggregate.py
CHANGED
|
@@ -27,12 +27,14 @@ from harness.A.run import vsi_official_eval # noqa: E402
|
|
| 27 |
from harness.B import RESULTS_DIR as HARNESS_B_RESULTS_DIR # noqa: E402
|
| 28 |
from harness.C import RESULTS_DIR as HARNESS_C_RESULTS_DIR # noqa: E402
|
| 29 |
from harness.D import RESULTS_DIR as HARNESS_D_RESULTS_DIR # noqa: E402
|
|
|
|
| 30 |
|
| 31 |
RESULTS_DIRS = {
|
| 32 |
"A": HARNESS_A_RESULTS_DIR,
|
| 33 |
"B": HARNESS_B_RESULTS_DIR,
|
| 34 |
"C": HARNESS_C_RESULTS_DIR,
|
| 35 |
"D": HARNESS_D_RESULTS_DIR,
|
|
|
|
| 36 |
}
|
| 37 |
|
| 38 |
|
|
@@ -200,7 +202,7 @@ def main():
|
|
| 200 |
group = parser.add_mutually_exclusive_group(required=True)
|
| 201 |
group.add_argument(
|
| 202 |
"--harness", choices=sorted(RESULTS_DIRS),
|
| 203 |
-
help="aggregate one harness's default results directory (A, B, or
|
| 204 |
)
|
| 205 |
group.add_argument("--results-dir", default=None, help="aggregate an explicit directory")
|
| 206 |
parser.add_argument(
|
|
|
|
| 27 |
from harness.B import RESULTS_DIR as HARNESS_B_RESULTS_DIR # noqa: E402
|
| 28 |
from harness.C import RESULTS_DIR as HARNESS_C_RESULTS_DIR # noqa: E402
|
| 29 |
from harness.D import RESULTS_DIR as HARNESS_D_RESULTS_DIR # noqa: E402
|
| 30 |
+
from harness.E import RESULTS_DIR as HARNESS_E_RESULTS_DIR # noqa: E402
|
| 31 |
|
| 32 |
RESULTS_DIRS = {
|
| 33 |
"A": HARNESS_A_RESULTS_DIR,
|
| 34 |
"B": HARNESS_B_RESULTS_DIR,
|
| 35 |
"C": HARNESS_C_RESULTS_DIR,
|
| 36 |
"D": HARNESS_D_RESULTS_DIR,
|
| 37 |
+
"E": HARNESS_E_RESULTS_DIR,
|
| 38 |
}
|
| 39 |
|
| 40 |
|
|
|
|
| 202 |
group = parser.add_mutually_exclusive_group(required=True)
|
| 203 |
group.add_argument(
|
| 204 |
"--harness", choices=sorted(RESULTS_DIRS),
|
| 205 |
+
help="aggregate one harness's default results directory (A, B, C, D, or E)",
|
| 206 |
)
|
| 207 |
group.add_argument("--results-dir", default=None, help="aggregate an explicit directory")
|
| 208 |
parser.add_argument(
|
analysis/compare.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
| 1 |
-
"""Join harness
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
harness.A
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
"""
|
| 9 |
|
| 10 |
from __future__ import annotations
|
|
@@ -13,94 +21,143 @@ import argparse
|
|
| 13 |
import csv
|
| 14 |
import json
|
| 15 |
import sys
|
|
|
|
| 16 |
from pathlib import Path
|
| 17 |
|
| 18 |
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 19 |
if str(WORKSPACE_ROOT) not in sys.path:
|
| 20 |
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 21 |
|
| 22 |
-
from analysis.aggregate import RESULTS_DIRS,
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
def
|
| 26 |
-
"""
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
return
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def
|
| 40 |
-
"""
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
rows = {}
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
for key, stats in c_aggregated.items():
|
| 63 |
-
model, spatial_code_format, selection, frame_count = _parse_bc_key(key)
|
| 64 |
-
_row((model, selection, frame_count))["C"][spatial_code_format] = (
|
| 65 |
-
stats["official"].get("overall")
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
return rows
|
| 69 |
|
| 70 |
|
| 71 |
def flatten_rows(rows):
|
| 72 |
-
"""Flatten compare()'s
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
flat = []
|
| 77 |
-
for (model, selection,
|
| 78 |
flat_row = {
|
| 79 |
"model": model,
|
|
|
|
| 80 |
"selection": selection,
|
| 81 |
-
"frames":
|
| 82 |
-
"
|
| 83 |
}
|
| 84 |
-
for
|
| 85 |
-
|
| 86 |
-
flat_row[
|
|
|
|
| 87 |
flat.append(flat_row)
|
| 88 |
return flat
|
| 89 |
|
| 90 |
|
| 91 |
def write_csv(rows, path):
|
| 92 |
-
"""Write compare()'s output to ``path`` as CSV, one row per (model,
|
| 93 |
-
|
| 94 |
-
"C_<format>" for every spatial_code_format present."""
|
| 95 |
flat = flatten_rows(rows)
|
| 96 |
-
|
| 97 |
-
fieldnames = ["model", "selection", "frames", "
|
| 98 |
-
for
|
| 99 |
-
fieldnames += [
|
| 100 |
with open(path, "w", newline="", encoding="utf-8") as stream:
|
| 101 |
writer = csv.DictWriter(stream, fieldnames=fieldnames, restval="")
|
| 102 |
writer.writeheader()
|
| 103 |
-
for row in sorted(
|
|
|
|
|
|
|
| 104 |
writer.writerow(row)
|
| 105 |
|
| 106 |
|
|
@@ -109,16 +166,15 @@ def _format_score(value):
|
|
| 109 |
|
| 110 |
|
| 111 |
def _print_report(rows):
|
| 112 |
-
|
| 113 |
-
header = ["model", "selection", "frames", "
|
| 114 |
-
for fmt in formats:
|
| 115 |
-
header += [f"B({fmt})", f"C({fmt})"]
|
| 116 |
print(" | ".join(header))
|
| 117 |
-
for
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
print(" | ".join(line))
|
| 123 |
|
| 124 |
|
|
@@ -127,6 +183,8 @@ def main():
|
|
| 127 |
parser.add_argument("--a-results-dir", default=None)
|
| 128 |
parser.add_argument("--b-results-dir", default=None)
|
| 129 |
parser.add_argument("--c-results-dir", default=None)
|
|
|
|
|
|
|
| 130 |
parser.add_argument(
|
| 131 |
"--json", action="store_true", help="print the full comparison dict as JSON instead"
|
| 132 |
)
|
|
@@ -134,18 +192,18 @@ def main():
|
|
| 134 |
"--csv", default=None, help="also write the comparison table to this CSV path"
|
| 135 |
)
|
| 136 |
args = parser.parse_args()
|
| 137 |
-
rows = compare(
|
|
|
|
|
|
|
|
|
|
| 138 |
if not rows:
|
| 139 |
-
print("no result records found in any
|
| 140 |
return
|
| 141 |
if args.csv:
|
| 142 |
write_csv(rows, args.csv)
|
| 143 |
print(f"wrote {args.csv}")
|
| 144 |
if args.json:
|
| 145 |
-
json_rows = {
|
| 146 |
-
f"{model}/{selection}/{frame_count}": value
|
| 147 |
-
for (model, selection, frame_count), value in rows.items()
|
| 148 |
-
}
|
| 149 |
print(json.dumps(json_rows, indent=1))
|
| 150 |
else:
|
| 151 |
_print_report(rows)
|
|
|
|
| 1 |
+
"""Join every harness's per-question results into one side-by-side comparison, on the
|
| 2 |
+
EXACT INTERSECTION of answered questions -- never on mismatched question sets.
|
| 3 |
+
|
| 4 |
+
Rows are keyed by (model, protocol, input/frame selection, frame count) -- the axes
|
| 5 |
+
harness.A and harness.B/C share. harness.D (ground truth) has no selection/frame axis
|
| 6 |
+
and harness.E (blind floor) has no scene input at all, so their scores join each row on
|
| 7 |
+
(model, protocol) alone. Every score in a row is recomputed over only the question_ids
|
| 8 |
+
answered by EVERY cell present in that row, so a harness that covered fewer scenes
|
| 9 |
+
(e.g. B, gated on which scenes have a spatial code on disk) can never be compared
|
| 10 |
+
against a different, easier or harder question mix -- the row also reports how many
|
| 11 |
+
questions that shared set holds versus each cell's full count, so coverage loss is a
|
| 12 |
+
visible result, not a silent one.
|
| 13 |
+
|
| 14 |
+
Column labels for B/C carry the full format:depth:tracking identity, so two different
|
| 15 |
+
depth/tracking runs of the same format never silently merge.
|
| 16 |
"""
|
| 17 |
|
| 18 |
from __future__ import annotations
|
|
|
|
| 21 |
import csv
|
| 22 |
import json
|
| 23 |
import sys
|
| 24 |
+
from collections import defaultdict
|
| 25 |
from pathlib import Path
|
| 26 |
|
| 27 |
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 28 |
if str(WORKSPACE_ROOT) not in sys.path:
|
| 29 |
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 30 |
|
| 31 |
+
from analysis.aggregate import RESULTS_DIRS, _official_scores, iter_records # noqa: E402
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def _cells(records):
|
| 35 |
+
"""Group records into {(model, condition): {question_id: record}} cells."""
|
| 36 |
+
cells = defaultdict(dict)
|
| 37 |
+
for record in records:
|
| 38 |
+
cells[(record["model"], record["condition"])][record["question_id"]] = record
|
| 39 |
+
return dict(cells)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def _parse_a_condition(condition):
|
| 43 |
+
""""<protocol>:<selection>:<frames>" -> (protocol, selection, frames)."""
|
| 44 |
+
protocol, selection, frames = condition.split(":")
|
| 45 |
+
return protocol, selection, frames
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def _parse_bc_condition(condition):
|
| 49 |
+
""""<protocol>:<format>:<depth>:<tracking>:<input>:<frames>" ->
|
| 50 |
+
(protocol, format, depth, tracking, input_selection, frames)."""
|
| 51 |
+
protocol, fmt, depth, tracking, input_selection, frames = condition.split(":")
|
| 52 |
+
return protocol, fmt, depth, tracking, input_selection, frames
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _parse_d_condition(condition):
|
| 56 |
+
""""<protocol>:<format>" -> (protocol, format)."""
|
| 57 |
+
protocol, fmt = condition.split(":")
|
| 58 |
+
return protocol, fmt
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def compare(
|
| 62 |
+
a_results_dir=None,
|
| 63 |
+
b_results_dir=None,
|
| 64 |
+
c_results_dir=None,
|
| 65 |
+
d_results_dir=None,
|
| 66 |
+
e_results_dir=None,
|
| 67 |
+
):
|
| 68 |
+
"""Return {(model, protocol, selection, frames): row} where every row holds, for
|
| 69 |
+
every cell present, {"overall": score-on-shared-questions, "full_count": that
|
| 70 |
+
cell's own total} under "A", "E", and per-column "B"/"C"/"D" dicts, plus
|
| 71 |
+
"common_count" (the shared question-intersection size every overall was computed
|
| 72 |
+
on). Cells are matched on question_id intersection across ALL cells in the row."""
|
| 73 |
+
a_cells = _cells(iter_records(a_results_dir or RESULTS_DIRS["A"]))
|
| 74 |
+
b_cells = _cells(iter_records(b_results_dir or RESULTS_DIRS["B"]))
|
| 75 |
+
c_cells = _cells(iter_records(c_results_dir or RESULTS_DIRS["C"]))
|
| 76 |
+
d_cells = _cells(iter_records(d_results_dir or RESULTS_DIRS["D"]))
|
| 77 |
+
e_cells = _cells(iter_records(e_results_dir or RESULTS_DIRS["E"]))
|
| 78 |
+
|
| 79 |
+
# Assemble each row's member cells first; scores only get computed after the row's
|
| 80 |
+
# shared question set is known.
|
| 81 |
+
rows_members = defaultdict(dict) # row_key -> {column_name: question_map}
|
| 82 |
+
|
| 83 |
+
for (model, condition), questions in a_cells.items():
|
| 84 |
+
protocol, selection, frames = _parse_a_condition(condition)
|
| 85 |
+
rows_members[(model, protocol, selection, frames)]["A"] = questions
|
| 86 |
+
|
| 87 |
+
for harness, cells in (("B", b_cells), ("C", c_cells)):
|
| 88 |
+
for (model, condition), questions in cells.items():
|
| 89 |
+
protocol, fmt, depth, tracking, input_selection, frames = _parse_bc_condition(
|
| 90 |
+
condition
|
| 91 |
+
)
|
| 92 |
+
row_key = (model, protocol, input_selection, frames)
|
| 93 |
+
rows_members[row_key][f"{harness}_{fmt}:{depth}:{tracking}"] = questions
|
| 94 |
+
|
| 95 |
+
# D and E have no selection/frame axis: join them onto every row sharing their
|
| 96 |
+
# (model, protocol).
|
| 97 |
+
for row_key in list(rows_members):
|
| 98 |
+
model, protocol, _selection, _frames = row_key
|
| 99 |
+
for (d_model, condition), questions in d_cells.items():
|
| 100 |
+
d_protocol, fmt = _parse_d_condition(condition)
|
| 101 |
+
if (d_model, d_protocol) == (model, protocol):
|
| 102 |
+
rows_members[row_key][f"D_{fmt}"] = questions
|
| 103 |
+
for (e_model, condition), questions in e_cells.items():
|
| 104 |
+
if (e_model, condition) == (model, protocol):
|
| 105 |
+
rows_members[row_key]["E"] = questions
|
| 106 |
|
| 107 |
rows = {}
|
| 108 |
+
for row_key, members in rows_members.items():
|
| 109 |
+
common_ids = None
|
| 110 |
+
for questions in members.values():
|
| 111 |
+
ids = set(questions)
|
| 112 |
+
common_ids = ids if common_ids is None else common_ids & ids
|
| 113 |
+
common_ids = common_ids or set()
|
| 114 |
+
row = {"common_count": len(common_ids), "cells": {}}
|
| 115 |
+
for column, questions in members.items():
|
| 116 |
+
shared = [questions[qid] for qid in common_ids]
|
| 117 |
+
row["cells"][column] = {
|
| 118 |
+
"overall": _official_scores(shared).get("overall") if shared else None,
|
| 119 |
+
"full_count": len(questions),
|
| 120 |
+
}
|
| 121 |
+
rows[row_key] = row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
return rows
|
| 123 |
|
| 124 |
|
| 125 |
def flatten_rows(rows):
|
| 126 |
+
"""Flatten compare()'s output into one flat dict per row for csv.DictWriter --
|
| 127 |
+
"model", "protocol", "selection", "frames", "common_count", then one score column
|
| 128 |
+
per cell name plus a matching "<cell>_full_count" coverage column."""
|
| 129 |
+
columns = sorted({column for row in rows.values() for column in row["cells"]})
|
| 130 |
flat = []
|
| 131 |
+
for (model, protocol, selection, frames), row in rows.items():
|
| 132 |
flat_row = {
|
| 133 |
"model": model,
|
| 134 |
+
"protocol": protocol,
|
| 135 |
"selection": selection,
|
| 136 |
+
"frames": frames,
|
| 137 |
+
"common_count": row["common_count"],
|
| 138 |
}
|
| 139 |
+
for column in columns:
|
| 140 |
+
cell = row["cells"].get(column)
|
| 141 |
+
flat_row[column] = cell["overall"] if cell else None
|
| 142 |
+
flat_row[f"{column}_full_count"] = cell["full_count"] if cell else None
|
| 143 |
flat.append(flat_row)
|
| 144 |
return flat
|
| 145 |
|
| 146 |
|
| 147 |
def write_csv(rows, path):
|
| 148 |
+
"""Write compare()'s output to ``path`` as CSV, one row per (model, protocol,
|
| 149 |
+
selection, frames)."""
|
|
|
|
| 150 |
flat = flatten_rows(rows)
|
| 151 |
+
columns = sorted({column for row in rows.values() for column in row["cells"]})
|
| 152 |
+
fieldnames = ["model", "protocol", "selection", "frames", "common_count"]
|
| 153 |
+
for column in columns:
|
| 154 |
+
fieldnames += [column, f"{column}_full_count"]
|
| 155 |
with open(path, "w", newline="", encoding="utf-8") as stream:
|
| 156 |
writer = csv.DictWriter(stream, fieldnames=fieldnames, restval="")
|
| 157 |
writer.writeheader()
|
| 158 |
+
for row in sorted(
|
| 159 |
+
flat, key=lambda r: (r["model"], r["protocol"], r["selection"], r["frames"])
|
| 160 |
+
):
|
| 161 |
writer.writerow(row)
|
| 162 |
|
| 163 |
|
|
|
|
| 166 |
|
| 167 |
|
| 168 |
def _print_report(rows):
|
| 169 |
+
columns = sorted({column for row in rows.values() for column in row["cells"]})
|
| 170 |
+
header = ["model", "protocol", "selection", "frames", "common_n"] + columns
|
|
|
|
|
|
|
| 171 |
print(" | ".join(header))
|
| 172 |
+
for row_key in sorted(rows):
|
| 173 |
+
row = rows[row_key]
|
| 174 |
+
line = list(row_key) + [str(row["common_count"])]
|
| 175 |
+
for column in columns:
|
| 176 |
+
cell = row["cells"].get(column)
|
| 177 |
+
line.append(_format_score(cell["overall"]) if cell else "-")
|
| 178 |
print(" | ".join(line))
|
| 179 |
|
| 180 |
|
|
|
|
| 183 |
parser.add_argument("--a-results-dir", default=None)
|
| 184 |
parser.add_argument("--b-results-dir", default=None)
|
| 185 |
parser.add_argument("--c-results-dir", default=None)
|
| 186 |
+
parser.add_argument("--d-results-dir", default=None)
|
| 187 |
+
parser.add_argument("--e-results-dir", default=None)
|
| 188 |
parser.add_argument(
|
| 189 |
"--json", action="store_true", help="print the full comparison dict as JSON instead"
|
| 190 |
)
|
|
|
|
| 192 |
"--csv", default=None, help="also write the comparison table to this CSV path"
|
| 193 |
)
|
| 194 |
args = parser.parse_args()
|
| 195 |
+
rows = compare(
|
| 196 |
+
args.a_results_dir, args.b_results_dir, args.c_results_dir,
|
| 197 |
+
args.d_results_dir, args.e_results_dir,
|
| 198 |
+
)
|
| 199 |
if not rows:
|
| 200 |
+
print("no result records found in any harness's results directory")
|
| 201 |
return
|
| 202 |
if args.csv:
|
| 203 |
write_csv(rows, args.csv)
|
| 204 |
print(f"wrote {args.csv}")
|
| 205 |
if args.json:
|
| 206 |
+
json_rows = {"/".join(row_key): value for row_key, value in rows.items()}
|
|
|
|
|
|
|
|
|
|
| 207 |
print(json.dumps(json_rows, indent=1))
|
| 208 |
else:
|
| 209 |
_print_report(rows)
|
analysis/cot_audit.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""H23: the deterministic chain-of-thought audit -- no LLM judge anywhere.
|
| 2 |
+
|
| 3 |
+
Because B/D's input is a symbolic code, every number the model writes in its logged
|
| 4 |
+
``reasoning_text`` can be mechanically checked against the exact code it was given
|
| 5 |
+
(re-read from each record's own ``spatial_code_path``). Per record this yields:
|
| 6 |
+
|
| 7 |
+
- cited_numbers: every numeric literal in the reasoning trace
|
| 8 |
+
- grounded: cited numbers that appear in the code (within rounding tolerance), the
|
| 9 |
+
question/options text, or the trivial-arithmetic whitelist (small integers 0-12,
|
| 10 |
+
which are usually counts/steps the model computed, not values it retrieved)
|
| 11 |
+
- fabricated: cited numbers appearing in NONE of those sources -- the model asserted
|
| 12 |
+
a quantity its input never contained
|
| 13 |
+
|
| 14 |
+
Aggregated over wrong answers, the fabrication rate separates retrieval/transcription
|
| 15 |
+
failure (the trace itself cites values not in the input) from computation/other
|
| 16 |
+
failure (every cited value was real; the model combined them wrongly). This
|
| 17 |
+
decomposition needs zero new runs -- it reads records the scheduled B/D extended runs
|
| 18 |
+
already produce -- and involves no learned judge, so it cannot itself hallucinate.
|
| 19 |
+
|
| 20 |
+
Usage:
|
| 21 |
+
python -m analysis.cot_audit --results-dir "results/B/qwen3.5-4b/extended/..." \\
|
| 22 |
+
[--tolerance 0.01] [--json]
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
from __future__ import annotations
|
| 26 |
+
|
| 27 |
+
import argparse
|
| 28 |
+
import json
|
| 29 |
+
import re
|
| 30 |
+
import sys
|
| 31 |
+
from pathlib import Path
|
| 32 |
+
|
| 33 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 34 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 35 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 36 |
+
|
| 37 |
+
from analysis.aggregate import iter_records # noqa: E402
|
| 38 |
+
|
| 39 |
+
_NUMBER_RE = re.compile(r"[-+]?\d+(?:\.\d+)?")
|
| 40 |
+
_TRIVIAL_MAX = 12 # small integers are usually derived counts/steps, not retrievals
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def numbers_in(text):
|
| 44 |
+
"""Every numeric literal in ``text`` as floats."""
|
| 45 |
+
return [float(match) for match in _NUMBER_RE.findall(text or "")]
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def _json_numbers(value, out):
|
| 49 |
+
if isinstance(value, bool):
|
| 50 |
+
return
|
| 51 |
+
if isinstance(value, (int, float)):
|
| 52 |
+
out.append(float(value))
|
| 53 |
+
elif isinstance(value, str):
|
| 54 |
+
out.extend(numbers_in(value))
|
| 55 |
+
elif isinstance(value, list):
|
| 56 |
+
for item in value:
|
| 57 |
+
_json_numbers(item, out)
|
| 58 |
+
elif isinstance(value, dict):
|
| 59 |
+
for key, item in value.items():
|
| 60 |
+
_json_numbers(key, out)
|
| 61 |
+
_json_numbers(item, out)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def code_numbers(code):
|
| 65 |
+
"""Every numeric value anywhere in a spatial-code dict (keys and unit strings
|
| 66 |
+
included -- a model quoting "4.98 meters" cites the number inside the string)."""
|
| 67 |
+
out = []
|
| 68 |
+
_json_numbers(code, out)
|
| 69 |
+
return out
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def _grounded(cited, sources, tolerance):
|
| 73 |
+
if abs(cited) <= _TRIVIAL_MAX and float(cited).is_integer():
|
| 74 |
+
return True
|
| 75 |
+
return any(
|
| 76 |
+
abs(cited - source) <= tolerance * max(1.0, abs(source)) for source in sources
|
| 77 |
+
)
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def audit_record(record, tolerance=0.01, code_cache=None):
|
| 81 |
+
"""Audit one record's reasoning trace. Returns None when the record has no
|
| 82 |
+
reasoning text or its code file is unreadable; otherwise a dict with cited /
|
| 83 |
+
grounded / fabricated counts and the fabricated values themselves."""
|
| 84 |
+
reasoning = record.get("reasoning_text")
|
| 85 |
+
code_path = record.get("spatial_code_path")
|
| 86 |
+
if not reasoning or not code_path:
|
| 87 |
+
return None
|
| 88 |
+
code_cache = code_cache if code_cache is not None else {}
|
| 89 |
+
if code_path not in code_cache:
|
| 90 |
+
try:
|
| 91 |
+
with open(code_path, encoding="utf-8") as stream:
|
| 92 |
+
code_cache[code_path] = code_numbers(json.load(stream))
|
| 93 |
+
except OSError:
|
| 94 |
+
return None
|
| 95 |
+
sources = list(code_cache[code_path])
|
| 96 |
+
sources.extend(numbers_in(record.get("question")))
|
| 97 |
+
for option in record.get("options") or []:
|
| 98 |
+
sources.extend(numbers_in(option))
|
| 99 |
+
cited = numbers_in(reasoning)
|
| 100 |
+
fabricated = [
|
| 101 |
+
value for value in cited if not _grounded(value, sources, tolerance)
|
| 102 |
+
]
|
| 103 |
+
return {
|
| 104 |
+
"question_id": record["question_id"],
|
| 105 |
+
"question_type": record["question_type"],
|
| 106 |
+
"score": record["score"],
|
| 107 |
+
"cited": len(cited),
|
| 108 |
+
"fabricated": len(fabricated),
|
| 109 |
+
"fabricated_values": fabricated,
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def audit(records, tolerance=0.01):
|
| 114 |
+
"""Audit every auditable record; returns (per_record_audits, summary). The
|
| 115 |
+
summary splits wrong answers (score < 1) into fabrication-present vs
|
| 116 |
+
all-values-grounded -- H23's retrieval-vs-computation decomposition."""
|
| 117 |
+
code_cache = {}
|
| 118 |
+
audits = []
|
| 119 |
+
for record in records:
|
| 120 |
+
result = audit_record(record, tolerance, code_cache)
|
| 121 |
+
if result is not None:
|
| 122 |
+
audits.append(result)
|
| 123 |
+
wrong = [a for a in audits if a["score"] is not None and a["score"] < 1.0]
|
| 124 |
+
wrong_with_fabrication = [a for a in wrong if a["fabricated"] > 0]
|
| 125 |
+
summary = {
|
| 126 |
+
"audited": len(audits),
|
| 127 |
+
"wrong": len(wrong),
|
| 128 |
+
"wrong_with_fabrication": len(wrong_with_fabrication),
|
| 129 |
+
"fabrication_share_of_wrong": (
|
| 130 |
+
len(wrong_with_fabrication) / len(wrong) if wrong else None
|
| 131 |
+
),
|
| 132 |
+
"mean_cited": (
|
| 133 |
+
sum(a["cited"] for a in audits) / len(audits) if audits else None
|
| 134 |
+
),
|
| 135 |
+
"mean_fabricated": (
|
| 136 |
+
sum(a["fabricated"] for a in audits) / len(audits) if audits else None
|
| 137 |
+
),
|
| 138 |
+
}
|
| 139 |
+
return audits, summary
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def main():
|
| 143 |
+
parser = argparse.ArgumentParser()
|
| 144 |
+
parser.add_argument("--results-dir", required=True)
|
| 145 |
+
parser.add_argument("--tolerance", type=float, default=0.01)
|
| 146 |
+
parser.add_argument("--json", action="store_true")
|
| 147 |
+
args = parser.parse_args()
|
| 148 |
+
audits, summary = audit(iter_records(args.results_dir), tolerance=args.tolerance)
|
| 149 |
+
if args.json:
|
| 150 |
+
print(json.dumps({"summary": summary, "audits": audits}, indent=1))
|
| 151 |
+
return
|
| 152 |
+
print(f"audited records (with reasoning + readable code): {summary['audited']}")
|
| 153 |
+
print(f"wrong answers: {summary['wrong']}")
|
| 154 |
+
print(
|
| 155 |
+
f"wrong WITH fabricated citations (retrieval/transcription failure): "
|
| 156 |
+
f"{summary['wrong_with_fabrication']}"
|
| 157 |
+
)
|
| 158 |
+
if summary["fabrication_share_of_wrong"] is not None:
|
| 159 |
+
print(
|
| 160 |
+
f"fabrication share of wrong answers: "
|
| 161 |
+
f"{summary['fabrication_share_of_wrong']:.3f}"
|
| 162 |
+
)
|
| 163 |
+
if summary["mean_cited"] is not None:
|
| 164 |
+
print(
|
| 165 |
+
f"mean cited numbers per trace: {summary['mean_cited']:.1f} "
|
| 166 |
+
f"(mean fabricated: {summary['mean_fabricated']:.2f})"
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
if __name__ == "__main__":
|
| 171 |
+
main()
|
analysis/depth.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""H25: computation-depth transfer -- the solver's per-question operation count as
|
| 2 |
+
an executable difficulty metric, joined against VLM accuracy.
|
| 3 |
+
|
| 4 |
+
For each VLM record, the solver re-answers the identical question from the identical
|
| 5 |
+
code (re-read from the record's own ``spatial_code_path``) with operation counting
|
| 6 |
+
on (symbolic.solver.LAST_ANSWER_OPS), then buckets VLM accuracy by solver depth.
|
| 7 |
+
Prediction (analysis/preregistration.md): accuracy declines with depth, and the
|
| 8 |
+
extended protocol's benefit concentrates in high-depth questions -- pass two
|
| 9 |
+
--results-dir cells (base and extended) to read the interaction directly.
|
| 10 |
+
|
| 11 |
+
Zero new GPU runs: this consumes records the scheduled runs already produce.
|
| 12 |
+
|
| 13 |
+
Usage:
|
| 14 |
+
python -m analysis.depth --results-dir <cell> [--results-dir <cell2>] [--json]
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
from __future__ import annotations
|
| 18 |
+
|
| 19 |
+
import argparse
|
| 20 |
+
import json
|
| 21 |
+
import sys
|
| 22 |
+
from collections import defaultdict
|
| 23 |
+
from pathlib import Path
|
| 24 |
+
|
| 25 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 26 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 27 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 28 |
+
|
| 29 |
+
from analysis.aggregate import iter_records # noqa: E402
|
| 30 |
+
from symbolic import adapters, solver # noqa: E402
|
| 31 |
+
|
| 32 |
+
DEPTH_BUCKETS = ((0, 2), (3, 8), (9, 20), (21, None)) # ops -> shallow..deep
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def question_depth(record, code_cache):
|
| 36 |
+
"""Solver operation count for one record's (question, code) pair, or None when
|
| 37 |
+
the code file is unreadable."""
|
| 38 |
+
code_path = record.get("spatial_code_path")
|
| 39 |
+
if not code_path:
|
| 40 |
+
return None
|
| 41 |
+
if code_path not in code_cache:
|
| 42 |
+
try:
|
| 43 |
+
with open(code_path, encoding="utf-8") as stream:
|
| 44 |
+
code_cache[code_path] = adapters.adapt_spatial_code(json.load(stream))
|
| 45 |
+
except OSError:
|
| 46 |
+
code_cache[code_path] = None
|
| 47 |
+
adapted = code_cache[code_path]
|
| 48 |
+
if adapted is None:
|
| 49 |
+
return None
|
| 50 |
+
solver.answer(record["question_type"], record["question"], record.get("options"), adapted)
|
| 51 |
+
return solver.LAST_ANSWER_OPS.get("total")
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _bucket(depth):
|
| 55 |
+
for low, high in DEPTH_BUCKETS:
|
| 56 |
+
if depth >= low and (high is None or depth <= high):
|
| 57 |
+
return f"{low}-{'inf' if high is None else high}"
|
| 58 |
+
return "unbucketed"
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def depth_table(records):
|
| 62 |
+
"""{bucket: {"count", "mean_score", "mean_depth"}} plus per-record pairs."""
|
| 63 |
+
code_cache = {}
|
| 64 |
+
pairs = []
|
| 65 |
+
for record in records:
|
| 66 |
+
depth = question_depth(record, code_cache)
|
| 67 |
+
if depth is None or record["score"] is None:
|
| 68 |
+
continue
|
| 69 |
+
pairs.append((depth, record["score"]))
|
| 70 |
+
buckets = defaultdict(list)
|
| 71 |
+
for depth, score in pairs:
|
| 72 |
+
buckets[_bucket(depth)].append((depth, score))
|
| 73 |
+
table = {}
|
| 74 |
+
for bucket, values in sorted(buckets.items()):
|
| 75 |
+
table[bucket] = {
|
| 76 |
+
"count": len(values),
|
| 77 |
+
"mean_depth": sum(depth for depth, _ in values) / len(values),
|
| 78 |
+
"mean_score": sum(score for _, score in values) / len(values),
|
| 79 |
+
}
|
| 80 |
+
return table, pairs
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def main():
|
| 84 |
+
parser = argparse.ArgumentParser()
|
| 85 |
+
parser.add_argument(
|
| 86 |
+
"--results-dir", action="append", required=True,
|
| 87 |
+
help="repeatable: one bucketed table per cell (e.g. base and extended)",
|
| 88 |
+
)
|
| 89 |
+
parser.add_argument("--json", action="store_true")
|
| 90 |
+
args = parser.parse_args()
|
| 91 |
+
output = {}
|
| 92 |
+
for directory in args.results_dir:
|
| 93 |
+
table, pairs = depth_table(iter_records(directory))
|
| 94 |
+
output[directory] = {"buckets": table, "questions": len(pairs)}
|
| 95 |
+
if args.json:
|
| 96 |
+
print(json.dumps(output, indent=1))
|
| 97 |
+
return
|
| 98 |
+
for directory, result in output.items():
|
| 99 |
+
print(f"=== {directory} ({result['questions']} questions) ===")
|
| 100 |
+
for bucket, stats in result["buckets"].items():
|
| 101 |
+
print(
|
| 102 |
+
f" ops {bucket}: n={stats['count']} "
|
| 103 |
+
f"mean_depth={stats['mean_depth']:.1f} mean_score={stats['mean_score']:.3f}"
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
if __name__ == "__main__":
|
| 108 |
+
main()
|
analysis/preregistration.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Pre-registration — spatial-code VSI-Bench program
|
| 2 |
+
|
| 3 |
+
Frozen BEFORE any scheduled experiment run executes; committed to this repository and
|
| 4 |
+
backed up to the Hugging Face dataset repo so its timestamp precedes every result.
|
| 5 |
+
Any deviation from this plan must be reported as a deviation, not silently absorbed.
|
| 6 |
+
|
| 7 |
+
## Models
|
| 8 |
+
|
| 9 |
+
qwen3.5-4b, qwen3.5-2b, internvl3.5-4b (all core sweeps). Corruption-module arms:
|
| 10 |
+
H21 runs BOTH 4B models (qwen3.5-4b + internvl3.5-4b; the 2B is excluded to avoid
|
| 11 |
+
confounding capacity with tolerance); all single-model arms (H22, H24, H6,
|
| 12 |
+
wrong-scene, robustness) run qwen3.5-4b, swapped to Plan B's winning model if that
|
| 13 |
+
differs (decision rule fixed here, before results).
|
| 14 |
+
|
| 15 |
+
## Primary hypotheses (novel; confirmatory test, directional, Holm-Bonferroni
|
| 16 |
+
## corrected as a family)
|
| 17 |
+
|
| 18 |
+
- **H7 (interaction)**: extended reasoning (2048-token) helps B and C but is flat or
|
| 19 |
+
harmful for A, relative to the base 16-token protocol. Direction: (B_ext - B_base)
|
| 20 |
+
> (A_ext - A_base), same for C.
|
| 21 |
+
- **H21 (perception-requirements curve)**: VLM accuracy on corrupted ground-truth
|
| 22 |
+
codes falls monotonically with corruption magnitude, and the curve fitted on
|
| 23 |
+
synthetic corruption predicts B's real measured accuracy at the pipeline's
|
| 24 |
+
empirically measured error level (prediction within the curve's bootstrap CI).
|
| 25 |
+
- **H22 (chimera decomposition)**: geometric error (perceived geometry, GT inventory)
|
| 26 |
+
and detection error (perceived inventory, GT geometry) cost accuracy in different
|
| 27 |
+
categories -- geometry errors hurt metric categories, detection errors hurt
|
| 28 |
+
counting/order categories.
|
| 29 |
+
- **H23 (deterministic CoT audit)**: in B/D extended reasoning traces, cited-number
|
| 30 |
+
errors (retrieval/transcription, checked mechanically against the provided code)
|
| 31 |
+
account for a nonzero, measurable share of wrong answers, and that share is higher
|
| 32 |
+
for the 2B model than the 4B models.
|
| 33 |
+
- **H24 (coordinate-frame invariance)**: solver-certified answer-preserving
|
| 34 |
+
re-parameterizations (translation, rotation, unit conversion, list reorder,
|
| 35 |
+
precision rounding) reduce VLM accuracy; any statistically significant drop is
|
| 36 |
+
representation-frame brittleness, since zero information changed.
|
| 37 |
+
- **H25 (computation-depth transfer)**: VLM accuracy on code-as-text declines with
|
| 38 |
+
the solver's per-question operation count, and H7's extended-protocol benefit
|
| 39 |
+
concentrates in high-depth questions.
|
| 40 |
+
- **H26 (sufficiency-conditioned decomposition)**: conditioning every B comparison on
|
| 41 |
+
the solver's per-question sufficiency certificate (solver answers correctly from
|
| 42 |
+
the identical code B saw) splits B's errors into proven information failures vs
|
| 43 |
+
proven reasoning failures; prediction: the majority of B's errors on
|
| 44 |
+
solver-correct questions persist in D (they are reasoning failures, not
|
| 45 |
+
perception artifacts).
|
| 46 |
+
|
| 47 |
+
## Supporting (directional but secondary)
|
| 48 |
+
|
| 49 |
+
- **H27 (format-flip brittleness)**: on questions where the solver answers correctly
|
| 50 |
+
from BOTH formats of the same scene's code, B(explicit) and B(compact) still
|
| 51 |
+
disagree on a nonzero fraction -- pure presentation sensitivity under certified
|
| 52 |
+
informational sufficiency.
|
| 53 |
+
- H1-H5, H10-H13 as stated in README (confirmatory, extensions of the two source
|
| 54 |
+
papers; H1's headline read is blind-floor-corrected and matched-protocol).
|
| 55 |
+
|
| 56 |
+
## Exploratory (reported as observations; no confirmatory claim)
|
| 57 |
+
|
| 58 |
+
H8, H9 (telemetry, difficulty-confounded), H17, H18 (n=2 families / one scale pair),
|
| 59 |
+
H19 (per-question solved-set overlap -- established methodology applied here, with
|
| 60 |
+
guess-noise caveats), H20 (cross-paper comparability is weak), E-base vs E-extended.
|
| 61 |
+
|
| 62 |
+
## Out of scope by design
|
| 63 |
+
|
| 64 |
+
H6 runs as a corruption-module probe (single-object perturbation) but its topic
|
| 65 |
+
(text-over-vision anchoring) is established literature -- reported as an
|
| 66 |
+
instantiation, not a novel claim. H14, H16 (secondary frame-count sweeps) are not
|
| 67 |
+
scheduled. H15 (upstream-vs-downstream frame selection) is out of scope: Step 2
|
| 68 |
+
builds spatial codes for the winning selection only; the second perception cache is
|
| 69 |
+
deliberately not funded (encoder-side frame-choice gains were already measured as
|
| 70 |
+
marginal in the concluded geometry track).
|
| 71 |
+
|
| 72 |
+
## Known contaminations and exclusions (fixed in advance)
|
| 73 |
+
|
| 74 |
+
- `obj_appearance_order` is EXCLUDED from every ground-truth-code-based analysis
|
| 75 |
+
(D, solver ceiling, all corruption arms): the GT field is reconstructed from that
|
| 76 |
+
category's own answer keys (circular). It is reported for A/B/C/E only.
|
| 77 |
+
- route_planning is excluded from solver-side ceiling/certificate claims (documented
|
| 78 |
+
solver parser limitation, ~3% on GT codes); VLM-side results are reported.
|
| 79 |
+
- Harness E doubles as the contamination probe: E scores materially above the
|
| 80 |
+
VSI-Bench paper's published blind baselines are treated as evidence of
|
| 81 |
+
training-data leakage and reported prominently.
|
| 82 |
+
- "Ground truth" codes are annotation-derived and inherit VSI-Bench's documented
|
| 83 |
+
annotation-to-video drift (ReVSI, arXiv:2604.24300) -- stated as a limitation.
|
| 84 |
+
|
| 85 |
+
## Corruption-module sample (procedure frozen now; realized list committed at Step 2)
|
| 86 |
+
|
| 87 |
+
One shared sample for every corruption arm: ~600 questions, balanced across the 7
|
| 88 |
+
non-appearance-order categories (~85 each), drawn only from scenes having BOTH
|
| 89 |
+
perceived (Step 2) and ground-truth codes, spread over >= 100 distinct scenes,
|
| 90 |
+
sampled with RNG seed 20260725. The realized question-id list is committed to this
|
| 91 |
+
file, unmodified, immediately after Step 2 completes and before any corruption run.
|
| 92 |
+
All corruption arms run the extended protocol on ground-truth codes (chimera arms
|
| 93 |
+
use both code sources by construction). The solver runs every arm as the zero-cost
|
| 94 |
+
second reasoner.
|
| 95 |
+
|
| 96 |
+
## Analysis plan
|
| 97 |
+
|
| 98 |
+
Every cross-harness delta: exact question-id intersection (analysis.compare), scene-
|
| 99 |
+
clustered paired bootstrap with fixed seed (analysis.stats), 95% CIs. The primary
|
| 100 |
+
family (H7, H21-H26) is Holm-Bonferroni corrected; supporting and exploratory results
|
| 101 |
+
are reported with CIs but no corrected significance claims. Aggregate category scores
|
| 102 |
+
use only the real, unmodified official VSI-Bench aggregator.
|
analysis/solvability.py
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""H19 (exploratory): solved-set overlap across cells -- established error-overlap
|
| 2 |
+
methodology (cf. Mixed Signals, arXiv:2504.08974) applied to this program's cells;
|
| 3 |
+
deliberately NOT claimed as novel (see analysis/preregistration.md).
|
| 4 |
+
|
| 5 |
+
Given two or more result cells (e.g. A vs B vs C for one model at the frozen
|
| 6 |
+
config), computes -- on the exact question-id intersection -- each cell's solved set
|
| 7 |
+
(score >= threshold), pairwise Jaccard overlap, per-pair exclusive counts, and the
|
| 8 |
+
all/none partition. The interesting readout: similar aggregate scores with LOW
|
| 9 |
+
overlap means the representations solve DIFFERENT questions, which no aggregate
|
| 10 |
+
table can reveal. MCA guess-noise caveat applies (a solved MCA question may be a
|
| 11 |
+
lucky guess); interpret cell-level rates, not individual questions.
|
| 12 |
+
|
| 13 |
+
Usage:
|
| 14 |
+
python -m analysis.solvability --cell A=results/A/qwen3.5-4b/extended/selective/32 \\
|
| 15 |
+
--cell B="results/B/qwen3.5-4b/extended/explicit/relative/tracking/selective/32"
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from __future__ import annotations
|
| 19 |
+
|
| 20 |
+
import argparse
|
| 21 |
+
import itertools
|
| 22 |
+
import json
|
| 23 |
+
import sys
|
| 24 |
+
from pathlib import Path
|
| 25 |
+
|
| 26 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 27 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 28 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 29 |
+
|
| 30 |
+
from analysis.aggregate import iter_records # noqa: E402
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def solved_sets(cells, threshold=1.0):
|
| 34 |
+
"""{name: set(question_id solved)} restricted to the exact intersection of every
|
| 35 |
+
cell's answered questions. Returns (sets, common_ids)."""
|
| 36 |
+
answered = {}
|
| 37 |
+
scores = {}
|
| 38 |
+
for name, records in cells.items():
|
| 39 |
+
by_id = {record["question_id"]: record["score"] for record in records}
|
| 40 |
+
answered[name] = set(by_id)
|
| 41 |
+
scores[name] = by_id
|
| 42 |
+
common = set.intersection(*answered.values()) if answered else set()
|
| 43 |
+
return (
|
| 44 |
+
{
|
| 45 |
+
name: {
|
| 46 |
+
qid for qid in common
|
| 47 |
+
if scores[name][qid] is not None and scores[name][qid] >= threshold
|
| 48 |
+
}
|
| 49 |
+
for name in cells
|
| 50 |
+
},
|
| 51 |
+
common,
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def overlap(cells, threshold=1.0):
|
| 56 |
+
"""Full overlap report: per-cell solved counts, pairwise Jaccard + exclusives,
|
| 57 |
+
and the solved-by-all / solved-by-none partition, all on the intersection."""
|
| 58 |
+
sets, common = solved_sets(cells, threshold)
|
| 59 |
+
if not common:
|
| 60 |
+
return {"questions": 0}
|
| 61 |
+
names = sorted(sets)
|
| 62 |
+
pairs = {}
|
| 63 |
+
for first, second in itertools.combinations(names, 2):
|
| 64 |
+
a, b = sets[first], sets[second]
|
| 65 |
+
union = a | b
|
| 66 |
+
pairs[f"{first}|{second}"] = {
|
| 67 |
+
"jaccard": len(a & b) / len(union) if union else None,
|
| 68 |
+
f"only_{first}": len(a - b),
|
| 69 |
+
f"only_{second}": len(b - a),
|
| 70 |
+
"both": len(a & b),
|
| 71 |
+
}
|
| 72 |
+
return {
|
| 73 |
+
"questions": len(common),
|
| 74 |
+
"solved": {name: len(sets[name]) for name in names},
|
| 75 |
+
"pairs": pairs,
|
| 76 |
+
"solved_by_all": len(set.intersection(*sets.values())),
|
| 77 |
+
"solved_by_none": len(common - set.union(*sets.values())),
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def main():
|
| 82 |
+
parser = argparse.ArgumentParser()
|
| 83 |
+
parser.add_argument(
|
| 84 |
+
"--cell", action="append", required=True,
|
| 85 |
+
help="name=results_dir; repeat for each cell (at least two)",
|
| 86 |
+
)
|
| 87 |
+
parser.add_argument("--threshold", type=float, default=1.0)
|
| 88 |
+
parser.add_argument("--json", action="store_true")
|
| 89 |
+
args = parser.parse_args()
|
| 90 |
+
cells = {}
|
| 91 |
+
for spec in args.cell:
|
| 92 |
+
if "=" not in spec:
|
| 93 |
+
parser.error(f"--cell must be name=dir, got {spec!r}")
|
| 94 |
+
name, directory = spec.split("=", 1)
|
| 95 |
+
cells[name] = list(iter_records(directory))
|
| 96 |
+
if len(cells) < 2:
|
| 97 |
+
parser.error("need at least two --cell entries")
|
| 98 |
+
|
| 99 |
+
report = overlap(cells, threshold=args.threshold)
|
| 100 |
+
if args.json:
|
| 101 |
+
print(json.dumps(report, indent=1))
|
| 102 |
+
return
|
| 103 |
+
if not report["questions"]:
|
| 104 |
+
print("no shared question_ids across the given cells")
|
| 105 |
+
return
|
| 106 |
+
print(f"shared questions: {report['questions']}")
|
| 107 |
+
for name, count in report["solved"].items():
|
| 108 |
+
print(f" {name}: solved {count}")
|
| 109 |
+
for pair, stats in report["pairs"].items():
|
| 110 |
+
print(f" {pair}: jaccard={stats['jaccard']:.3f} {stats}")
|
| 111 |
+
print(f" solved by all: {report['solved_by_all']}; by none: {report['solved_by_none']}")
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
if __name__ == "__main__":
|
| 115 |
+
main()
|
analysis/stats.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Scene-clustered paired bootstrap for cross-harness deltas.
|
| 2 |
+
|
| 3 |
+
Compares two result cells (e.g. one B run vs one A run) on their exact
|
| 4 |
+
question-intersection, resampling SCENES with replacement -- questions within a scene
|
| 5 |
+
share the same video/geometry and are correlated, so resampling questions directly
|
| 6 |
+
would understate the interval.
|
| 7 |
+
|
| 8 |
+
The bootstrapped statistic is the mean per-question vsibench score (each question's
|
| 9 |
+
own official per-question score, unweighted), NOT the category-weighted official
|
| 10 |
+
"overall": a scene resample can drop a whole category (or a rel_direction subtype the
|
| 11 |
+
official aggregator refuses to score alone), which would crash or bias the
|
| 12 |
+
category-weighted rollup. The paired question-level delta is the quantity every
|
| 13 |
+
paired hypothesis here (H1, H7, B-vs-D, ...) is actually about; the category-weighted
|
| 14 |
+
"overall" remains analysis.aggregate/compare's job on the full (non-resampled) sets.
|
| 15 |
+
|
| 16 |
+
Deterministic by default (fixed --seed), so a reported interval is reproducible.
|
| 17 |
+
|
| 18 |
+
Usage:
|
| 19 |
+
python -m analysis.stats --x-dir results/A/qwen3.5-4b/extended/selective/32 \\
|
| 20 |
+
--y-dir "results/B/qwen3.5-4b/extended/explicit/relative/tracking/selective/32"
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
from __future__ import annotations
|
| 24 |
+
|
| 25 |
+
import argparse
|
| 26 |
+
import random
|
| 27 |
+
import statistics
|
| 28 |
+
import sys
|
| 29 |
+
from collections import defaultdict
|
| 30 |
+
from pathlib import Path
|
| 31 |
+
|
| 32 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 33 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 34 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 35 |
+
|
| 36 |
+
from analysis.aggregate import iter_records # noqa: E402
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def paired_questions(x_records, y_records):
|
| 40 |
+
"""Return {scene: [(x_score, y_score), ...]} over the exact question-id
|
| 41 |
+
intersection of the two record sets."""
|
| 42 |
+
x_by_id = {record["question_id"]: record for record in x_records}
|
| 43 |
+
y_by_id = {record["question_id"]: record for record in y_records}
|
| 44 |
+
common = sorted(set(x_by_id) & set(y_by_id))
|
| 45 |
+
by_scene = defaultdict(list)
|
| 46 |
+
for question_id in common:
|
| 47 |
+
x = x_by_id[question_id]
|
| 48 |
+
by_scene[x["scene"]].append((x["score"], y_by_id[question_id]["score"]))
|
| 49 |
+
return dict(by_scene)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def paired_bootstrap(x_records, y_records, iterations=2000, seed=0, confidence=0.95):
|
| 53 |
+
"""Return the observed y-minus-x mean-score delta plus a scene-clustered bootstrap
|
| 54 |
+
confidence interval over the two record sets' exact question intersection.
|
| 55 |
+
|
| 56 |
+
Output dict: "delta" (observed), "ci_low"/"ci_high", "confidence", "iterations",
|
| 57 |
+
"questions" (intersection size), "scenes" (cluster count). Returns None when the
|
| 58 |
+
intersection is empty."""
|
| 59 |
+
by_scene = paired_questions(x_records, y_records)
|
| 60 |
+
if not by_scene:
|
| 61 |
+
return None
|
| 62 |
+
scenes = sorted(by_scene)
|
| 63 |
+
pairs = [pair for scene in scenes for pair in by_scene[scene]]
|
| 64 |
+
observed = statistics.mean(y - x for x, y in pairs)
|
| 65 |
+
|
| 66 |
+
rng = random.Random(seed)
|
| 67 |
+
deltas = []
|
| 68 |
+
for _ in range(iterations):
|
| 69 |
+
resampled = [
|
| 70 |
+
pair
|
| 71 |
+
for _ in range(len(scenes))
|
| 72 |
+
for pair in by_scene[rng.choice(scenes)]
|
| 73 |
+
]
|
| 74 |
+
deltas.append(statistics.mean(y - x for x, y in resampled))
|
| 75 |
+
deltas.sort()
|
| 76 |
+
tail = (1.0 - confidence) / 2.0
|
| 77 |
+
low_index = int(tail * iterations)
|
| 78 |
+
high_index = min(iterations - 1, int((1.0 - tail) * iterations))
|
| 79 |
+
# Two-sided bootstrap p-value: twice the smaller tail proportion, floored at
|
| 80 |
+
# 1/iterations (a resampling p can never claim more precision than its resamples).
|
| 81 |
+
at_most = sum(1 for delta in deltas if delta <= 0.0) / iterations
|
| 82 |
+
at_least = sum(1 for delta in deltas if delta >= 0.0) / iterations
|
| 83 |
+
p_value = max(1.0 / iterations, min(1.0, 2.0 * min(at_most, at_least)))
|
| 84 |
+
return {
|
| 85 |
+
"delta": observed,
|
| 86 |
+
"ci_low": deltas[low_index],
|
| 87 |
+
"ci_high": deltas[high_index],
|
| 88 |
+
"p_value": p_value,
|
| 89 |
+
"confidence": confidence,
|
| 90 |
+
"iterations": iterations,
|
| 91 |
+
"questions": len(pairs),
|
| 92 |
+
"scenes": len(scenes),
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def holm_bonferroni(p_values):
|
| 97 |
+
"""Holm-Bonferroni step-down adjustment for one hypothesis family (the primary
|
| 98 |
+
family in analysis/preregistration.md). Input {name: p}; returns {name:
|
| 99 |
+
adjusted_p}, monotone and clipped to 1.0."""
|
| 100 |
+
ordered = sorted(p_values.items(), key=lambda item: item[1])
|
| 101 |
+
total = len(ordered)
|
| 102 |
+
adjusted = {}
|
| 103 |
+
running_max = 0.0
|
| 104 |
+
for rank, (name, p) in enumerate(ordered):
|
| 105 |
+
value = min(1.0, (total - rank) * p)
|
| 106 |
+
running_max = max(running_max, value)
|
| 107 |
+
adjusted[name] = running_max
|
| 108 |
+
return adjusted
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def main():
|
| 112 |
+
parser = argparse.ArgumentParser()
|
| 113 |
+
parser.add_argument("--x-dir", required=True, help="baseline cell's results directory")
|
| 114 |
+
parser.add_argument("--y-dir", required=True, help="comparison cell's results directory")
|
| 115 |
+
parser.add_argument("--iterations", type=int, default=2000)
|
| 116 |
+
parser.add_argument("--seed", type=int, default=0)
|
| 117 |
+
parser.add_argument("--confidence", type=float, default=0.95)
|
| 118 |
+
args = parser.parse_args()
|
| 119 |
+
if args.iterations < 1:
|
| 120 |
+
parser.error("--iterations must be positive")
|
| 121 |
+
if not 0.0 < args.confidence < 1.0:
|
| 122 |
+
parser.error("--confidence must be between 0 and 1")
|
| 123 |
+
|
| 124 |
+
result = paired_bootstrap(
|
| 125 |
+
list(iter_records(args.x_dir)),
|
| 126 |
+
list(iter_records(args.y_dir)),
|
| 127 |
+
iterations=args.iterations,
|
| 128 |
+
seed=args.seed,
|
| 129 |
+
confidence=args.confidence,
|
| 130 |
+
)
|
| 131 |
+
if result is None:
|
| 132 |
+
print("no shared question_ids between the two results directories")
|
| 133 |
+
raise SystemExit(1)
|
| 134 |
+
print(
|
| 135 |
+
f"delta (y - x, mean per-question score): {result['delta']:+.4f}\n"
|
| 136 |
+
f"{int(result['confidence'] * 100)}% scene-clustered bootstrap CI: "
|
| 137 |
+
f"[{result['ci_low']:+.4f}, {result['ci_high']:+.4f}]\n"
|
| 138 |
+
f"paired questions: {result['questions']} across {result['scenes']} scene(s); "
|
| 139 |
+
f"{result['iterations']} resamples (seed {args.seed})"
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
if __name__ == "__main__":
|
| 144 |
+
main()
|
analysis/sufficiency.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""H26: the solver-certified sufficiency decomposition.
|
| 2 |
+
|
| 3 |
+
The deterministic solver, run on the IDENTICAL code a VLM cell saw, certifies per
|
| 4 |
+
question whether the answer is derivably present in that code. Conditioning the VLM
|
| 5 |
+
cell on that certificate splits its errors into:
|
| 6 |
+
|
| 7 |
+
- PROVEN reasoning failures: solver-certified questions (answer derivably present)
|
| 8 |
+
the VLM still got wrong -- the information was there; the model failed to use it.
|
| 9 |
+
- PROVEN information failures: solver-uncertified questions -- no reasoner, however
|
| 10 |
+
perfect, could have derived the expected answer from this code (perception error
|
| 11 |
+
or representation insufficiency), so the VLM's failure there is not evidence about
|
| 12 |
+
its reasoning.
|
| 13 |
+
|
| 14 |
+
The certificate is ``solver_score >= threshold`` (default 1.0: the solver's derived
|
| 15 |
+
answer scored perfectly). Exclusions from analysis/preregistration.md apply: pass
|
| 16 |
+
--exclude to drop obj_appearance_order (circular on ground-truth codes) and/or
|
| 17 |
+
route_planning (documented solver parser limitation -- an uncertified route question
|
| 18 |
+
may be solver weakness, not information absence, so H26 claims skip that category).
|
| 19 |
+
|
| 20 |
+
Usage:
|
| 21 |
+
python -m analysis.sufficiency \\
|
| 22 |
+
--vlm-dir "results/B/qwen3.5-4b/extended/explicit/relative/tracking/selective/32" \\
|
| 23 |
+
--solver-dir "results/symbolic/relative/tracking/selective/32/explicit" \\
|
| 24 |
+
--exclude obj_appearance_order,route_planning
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
from __future__ import annotations
|
| 28 |
+
|
| 29 |
+
import argparse
|
| 30 |
+
import json
|
| 31 |
+
import sys
|
| 32 |
+
from collections import defaultdict
|
| 33 |
+
from pathlib import Path
|
| 34 |
+
|
| 35 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 36 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 37 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 38 |
+
|
| 39 |
+
from analysis.aggregate import iter_records # noqa: E402
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def certificates(solver_records, threshold=1.0):
|
| 43 |
+
"""{question_id: bool} -- True iff the solver derived a >= threshold answer."""
|
| 44 |
+
return {
|
| 45 |
+
record["question_id"]: record["score"] is not None and record["score"] >= threshold
|
| 46 |
+
for record in solver_records
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def decompose(vlm_records, solver_records, threshold=1.0, exclude=()):
|
| 51 |
+
"""Split one VLM cell by the solver certificate over the shared question set.
|
| 52 |
+
|
| 53 |
+
Returns {"certified": stats, "uncertified": stats, "questions": n} where each
|
| 54 |
+
stats dict has "count", "mean_score", "vlm_correct", "vlm_wrong" -- the
|
| 55 |
+
"certified"/"vlm_wrong" cell is the PROVEN-reasoning-failure count."""
|
| 56 |
+
certificate = certificates(solver_records, threshold)
|
| 57 |
+
excluded = set(exclude)
|
| 58 |
+
split = {
|
| 59 |
+
"certified": defaultdict(list),
|
| 60 |
+
"uncertified": defaultdict(list),
|
| 61 |
+
}
|
| 62 |
+
matched = 0
|
| 63 |
+
for record in vlm_records:
|
| 64 |
+
if record["question_type"] in excluded:
|
| 65 |
+
continue
|
| 66 |
+
question_id = record["question_id"]
|
| 67 |
+
if question_id not in certificate:
|
| 68 |
+
continue
|
| 69 |
+
matched += 1
|
| 70 |
+
bucket = "certified" if certificate[question_id] else "uncertified"
|
| 71 |
+
split[bucket]["scores"].append(record["score"])
|
| 72 |
+
split[bucket]["types"].append(record["question_type"])
|
| 73 |
+
|
| 74 |
+
def stats(bucket):
|
| 75 |
+
scores = split[bucket]["scores"]
|
| 76 |
+
if not scores:
|
| 77 |
+
return {"count": 0, "mean_score": None, "vlm_correct": 0, "vlm_wrong": 0}
|
| 78 |
+
correct = sum(1 for score in scores if score is not None and score >= threshold)
|
| 79 |
+
return {
|
| 80 |
+
"count": len(scores),
|
| 81 |
+
"mean_score": sum(scores) / len(scores),
|
| 82 |
+
"vlm_correct": correct,
|
| 83 |
+
"vlm_wrong": len(scores) - correct,
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
return {
|
| 87 |
+
"certified": stats("certified"),
|
| 88 |
+
"uncertified": stats("uncertified"),
|
| 89 |
+
"questions": matched,
|
| 90 |
+
"threshold": threshold,
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def main():
|
| 95 |
+
parser = argparse.ArgumentParser()
|
| 96 |
+
parser.add_argument("--vlm-dir", required=True)
|
| 97 |
+
parser.add_argument("--solver-dir", required=True)
|
| 98 |
+
parser.add_argument("--threshold", type=float, default=1.0)
|
| 99 |
+
parser.add_argument(
|
| 100 |
+
"--exclude", default="",
|
| 101 |
+
help="comma-separated question_types to drop (see analysis/preregistration.md)",
|
| 102 |
+
)
|
| 103 |
+
parser.add_argument("--json", action="store_true")
|
| 104 |
+
args = parser.parse_args()
|
| 105 |
+
exclude = tuple(t.strip() for t in args.exclude.split(",") if t.strip())
|
| 106 |
+
|
| 107 |
+
result = decompose(
|
| 108 |
+
list(iter_records(args.vlm_dir)),
|
| 109 |
+
list(iter_records(args.solver_dir)),
|
| 110 |
+
threshold=args.threshold,
|
| 111 |
+
exclude=exclude,
|
| 112 |
+
)
|
| 113 |
+
if args.json:
|
| 114 |
+
print(json.dumps(result, indent=1))
|
| 115 |
+
return
|
| 116 |
+
certified, uncertified = result["certified"], result["uncertified"]
|
| 117 |
+
print(f"matched questions: {result['questions']} (threshold {result['threshold']})")
|
| 118 |
+
print(
|
| 119 |
+
f"certified (answer derivably present): {certified['count']} -- "
|
| 120 |
+
f"VLM correct {certified['vlm_correct']}, "
|
| 121 |
+
f"PROVEN reasoning failures {certified['vlm_wrong']}"
|
| 122 |
+
)
|
| 123 |
+
print(
|
| 124 |
+
f"uncertified (information failure): {uncertified['count']} -- "
|
| 125 |
+
f"VLM 'correct' {uncertified['vlm_correct']} (not evidence of reasoning), "
|
| 126 |
+
f"wrong {uncertified['vlm_wrong']}"
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
if __name__ == "__main__":
|
| 131 |
+
main()
|
corruption/__init__.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Corruption module: parameterized transformations of spatial codes, feeding
|
| 2 |
+
harness.D's unmodified prompt path (VLM arm) and the symbolic solver (free CPU arm).
|
| 3 |
+
|
| 4 |
+
Every transform operates on the COMPACT code -- the pure geometric primitives -- and
|
| 5 |
+
the requested format is then derived through the exact same `_explicit_from_compact`
|
| 6 |
+
the encoder uses, so a corrupted explicit code can never disagree with its corrupted
|
| 7 |
+
compact sibling (the same consistency-by-construction guarantee the clean pipeline
|
| 8 |
+
has; see README Theme 8 / H21-H24 and analysis/preregistration.md).
|
| 9 |
+
|
| 10 |
+
Transform families:
|
| 11 |
+
- noise (H21): position jitter, dimension noise, dropped objects, hallucinated
|
| 12 |
+
objects, class swaps, plus empirical noise sampled from the REAL measured
|
| 13 |
+
SAM3+DA3 residual distribution (corruption/empirical.py)
|
| 14 |
+
- chimera (H22): ground-truth inventory x perceived geometry hybrids
|
| 15 |
+
(corruption/chimera.py), plus the single-object H6 probe and wrong-scene control
|
| 16 |
+
- invariance (H24): solver-certified answer-preserving re-parameterizations
|
| 17 |
+
(translation, rotation, reorder, precision)
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from __future__ import annotations
|
| 21 |
+
|
| 22 |
+
import os
|
| 23 |
+
from pathlib import Path
|
| 24 |
+
|
| 25 |
+
from harness.A import WORKSPACE_ROOT
|
| 26 |
+
|
| 27 |
+
# One JSON per question:
|
| 28 |
+
# results/corruption/<arm>/<transform>/<magnitude>/<model-or-solver>/<scene>/<question_id>.json
|
| 29 |
+
RESULTS_DIR = Path(
|
| 30 |
+
os.environ.get("VSI_CORRUPTION_RESULTS_DIR", WORKSPACE_ROOT / "results" / "corruption")
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# The pre-registered corruption-arm sampling seed (analysis/preregistration.md).
|
| 34 |
+
SAMPLE_SEED = 20260725
|
corruption/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (1.68 kB). View file
|
|
|
corruption/__pycache__/chimera.cpython-311.pyc
ADDED
|
Binary file (6.38 kB). View file
|
|
|
corruption/__pycache__/empirical.cpython-311.pyc
ADDED
|
Binary file (8.13 kB). View file
|
|
|
corruption/__pycache__/launch.cpython-311.pyc
ADDED
|
Binary file (7.06 kB). View file
|
|
|
corruption/__pycache__/run.cpython-311.pyc
ADDED
|
Binary file (16.5 kB). View file
|
|
|
corruption/__pycache__/transforms.cpython-311.pyc
ADDED
|
Binary file (15.6 kB). View file
|
|
|
corruption/chimera.py
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Chimera codes (H22) and the single-object probe (H6): interventional hybrids of
|
| 2 |
+
ground-truth and perceived COMPACT codes for the same scene.
|
| 3 |
+
|
| 4 |
+
The B-to-D gap confounds two perception failure modes: DETECTION error (which
|
| 5 |
+
objects exist, how many) and GEOMETRIC error (where they are, how big). The two
|
| 6 |
+
chimeras isolate them causally:
|
| 7 |
+
|
| 8 |
+
- gt_inventory_perceived_geometry: ground truth decides which classes/instances
|
| 9 |
+
exist; each instance's box is replaced by its nearest perceived box of the same
|
| 10 |
+
class where one exists (geometry becomes perceived; inventory stays perfect).
|
| 11 |
+
- perceived_inventory_gt_geometry: perception decides the inventory; each perceived
|
| 12 |
+
instance's box is replaced by its nearest ground-truth box of the same class where
|
| 13 |
+
one exists (inventory stays flawed; geometry becomes perfect).
|
| 14 |
+
|
| 15 |
+
Both return (code, coverage) -- coverage reports how many instances actually got a
|
| 16 |
+
swapped box vs. kept their own (a class the other source lacks has nothing to swap
|
| 17 |
+
with), so every chimera result can be conditioned on real swap coverage instead of
|
| 18 |
+
silently diluting the manipulation.
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
from __future__ import annotations
|
| 22 |
+
|
| 23 |
+
import json
|
| 24 |
+
import math
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _copy(code):
|
| 28 |
+
return json.loads(json.dumps(code))
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _center(instance):
|
| 32 |
+
return instance["3D oriented bounding box"]["3D oriented bounding box center coordinates"]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def _distance(a, b):
|
| 36 |
+
return math.dist(a, b)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def _swap_boxes(target_code, source_code):
|
| 40 |
+
"""For every instance in ``target_code``, replace its box with the nearest
|
| 41 |
+
unused same-class box from ``source_code`` (greedy nearest-center matching).
|
| 42 |
+
Returns (new_code, coverage) without mutating either input."""
|
| 43 |
+
code = _copy(target_code)
|
| 44 |
+
swapped = 0
|
| 45 |
+
total = 0
|
| 46 |
+
for class_name, items in code["objects"].items():
|
| 47 |
+
available = [
|
| 48 |
+
_copy(item) for item in source_code["objects"].get(class_name, [])
|
| 49 |
+
]
|
| 50 |
+
for item in items:
|
| 51 |
+
total += 1
|
| 52 |
+
if not available:
|
| 53 |
+
continue
|
| 54 |
+
best = min(
|
| 55 |
+
range(len(available)),
|
| 56 |
+
key=lambda index: _distance(_center(item), _center(available[index])),
|
| 57 |
+
)
|
| 58 |
+
source = available.pop(best)
|
| 59 |
+
item["3D oriented bounding box"] = source["3D oriented bounding box"]
|
| 60 |
+
swapped += 1
|
| 61 |
+
coverage = {"instances": total, "swapped": swapped}
|
| 62 |
+
return code, coverage
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def gt_inventory_perceived_geometry(gt_code, perceived_code):
|
| 66 |
+
"""Ground-truth inventory, perceived geometry: isolates GEOMETRIC error cost."""
|
| 67 |
+
return _swap_boxes(gt_code, perceived_code)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def perceived_inventory_gt_geometry(gt_code, perceived_code):
|
| 71 |
+
"""Perceived inventory, ground-truth geometry: isolates DETECTION error cost."""
|
| 72 |
+
return _swap_boxes(perceived_code, gt_code)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def perturb_single_object(code, rng, position_offset_meters=1.0, size_scale=2.0):
|
| 76 |
+
"""The H6 probe: displace and rescale exactly ONE randomly chosen instance,
|
| 77 |
+
leaving everything else untouched. Returns (code, perturbed) where ``perturbed``
|
| 78 |
+
names the class/instance changed, so the conflict question set can be selected."""
|
| 79 |
+
code = _copy(code)
|
| 80 |
+
candidates = [
|
| 81 |
+
(class_name, index)
|
| 82 |
+
for class_name, items in code["objects"].items()
|
| 83 |
+
for index in range(len(items))
|
| 84 |
+
]
|
| 85 |
+
if not candidates:
|
| 86 |
+
return code, None
|
| 87 |
+
class_name, index = candidates[rng.randrange(len(candidates))]
|
| 88 |
+
box = code["objects"][class_name][index]["3D oriented bounding box"]
|
| 89 |
+
center = box["3D oriented bounding box center coordinates"]
|
| 90 |
+
angle = rng.uniform(0.0, 2.0 * math.pi)
|
| 91 |
+
box["3D oriented bounding box center coordinates"] = [
|
| 92 |
+
round(center[0] + position_offset_meters * math.cos(angle), 2),
|
| 93 |
+
round(center[1] + position_offset_meters * math.sin(angle), 2),
|
| 94 |
+
center[2],
|
| 95 |
+
]
|
| 96 |
+
box["3D oriented bounding box dimensions"] = [
|
| 97 |
+
round(value * size_scale, 2) for value in box["3D oriented bounding box dimensions"]
|
| 98 |
+
]
|
| 99 |
+
return code, {"class": class_name, "instance": index}
|
corruption/empirical.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Measure the REAL SAM3+DA3 residual distribution and sample corruption from it.
|
| 2 |
+
|
| 3 |
+
H21's central methodological check: iid Gaussian noise is the field's default proxy
|
| 4 |
+
for perception error, but real perception error is structured (per-class biases,
|
| 5 |
+
correlated axis errors, class-dependent miss rates). This module measures the actual
|
| 6 |
+
residuals -- perceived vs. ground-truth compact codes for the same scenes -- and
|
| 7 |
+
provides an ``empirical`` corruption mode that samples from those measured residuals
|
| 8 |
+
instead of a parametric distribution. Comparing the empirical-noise curve against
|
| 9 |
+
the Gaussian curve at matched aggregate magnitude answers: is iid noise even a valid
|
| 10 |
+
proxy for real perception error?
|
| 11 |
+
|
| 12 |
+
Matching is greedy nearest-center within each class (the same convention
|
| 13 |
+
corruption/chimera.py uses), which is deliberate: both modules should agree on what
|
| 14 |
+
"the corresponding instance" means.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
from __future__ import annotations
|
| 18 |
+
|
| 19 |
+
import json
|
| 20 |
+
import math
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _center(instance):
|
| 24 |
+
return instance["3D oriented bounding box"]["3D oriented bounding box center coordinates"]
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _dimensions(instance):
|
| 28 |
+
return instance["3D oriented bounding box"]["3D oriented bounding box dimensions"]
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def measure_residuals(code_pairs):
|
| 32 |
+
"""Measure per-class residuals over (perceived_code, gt_code) compact pairs.
|
| 33 |
+
|
| 34 |
+
Returns {"position_residuals": [[dx, dy, dz], ...], "dimension_ratios":
|
| 35 |
+
[[rx, ry, rz], ...], "matched": n, "missed": n (GT instances with no perceived
|
| 36 |
+
match), "hallucinated": n (perceived instances with no GT match), "miss_rate",
|
| 37 |
+
"hallucination_rate"} pooled across classes -- per-class pooling keeps the
|
| 38 |
+
sample usable at this dataset's per-class instance counts.
|
| 39 |
+
"""
|
| 40 |
+
position_residuals = []
|
| 41 |
+
dimension_ratios = []
|
| 42 |
+
matched = missed = hallucinated = 0
|
| 43 |
+
for perceived_code, gt_code in code_pairs:
|
| 44 |
+
classes = set(perceived_code["objects"]) | set(gt_code["objects"])
|
| 45 |
+
for class_name in classes:
|
| 46 |
+
perceived = list(perceived_code["objects"].get(class_name, []))
|
| 47 |
+
ground_truth = list(gt_code["objects"].get(class_name, []))
|
| 48 |
+
unmatched = list(range(len(perceived)))
|
| 49 |
+
for gt_item in ground_truth:
|
| 50 |
+
if not unmatched:
|
| 51 |
+
missed += 1
|
| 52 |
+
continue
|
| 53 |
+
best = min(
|
| 54 |
+
unmatched,
|
| 55 |
+
key=lambda index: math.dist(_center(perceived[index]), _center(gt_item)),
|
| 56 |
+
)
|
| 57 |
+
unmatched.remove(best)
|
| 58 |
+
matched += 1
|
| 59 |
+
p_center, g_center = _center(perceived[best]), _center(gt_item)
|
| 60 |
+
position_residuals.append(
|
| 61 |
+
[round(p - g, 4) for p, g in zip(p_center, g_center)]
|
| 62 |
+
)
|
| 63 |
+
dimension_ratios.append(
|
| 64 |
+
[
|
| 65 |
+
round(p / g, 4) if g else 1.0
|
| 66 |
+
for p, g in zip(_dimensions(perceived[best]), _dimensions(gt_item))
|
| 67 |
+
]
|
| 68 |
+
)
|
| 69 |
+
hallucinated += len(unmatched)
|
| 70 |
+
gt_total = matched + missed
|
| 71 |
+
perceived_total = matched + hallucinated
|
| 72 |
+
return {
|
| 73 |
+
"position_residuals": position_residuals,
|
| 74 |
+
"dimension_ratios": dimension_ratios,
|
| 75 |
+
"matched": matched,
|
| 76 |
+
"missed": missed,
|
| 77 |
+
"hallucinated": hallucinated,
|
| 78 |
+
"miss_rate": missed / gt_total if gt_total else 0.0,
|
| 79 |
+
"hallucination_rate": hallucinated / perceived_total if perceived_total else 0.0,
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
def empirical_noise(code, residuals, rng, scale=1.0):
|
| 84 |
+
"""Corrupt a compact code by sampling from MEASURED residuals: each surviving
|
| 85 |
+
instance gets a sampled position residual and dimension ratio (both scaled by
|
| 86 |
+
``scale`` -- scale=1.0 is the pipeline's real operating point, the anchor H21's
|
| 87 |
+
prediction test uses); instances are dropped at ``scale`` x the measured miss
|
| 88 |
+
rate and duplicated at ``scale`` x the measured hallucination rate."""
|
| 89 |
+
code = json.loads(json.dumps(code))
|
| 90 |
+
positions = residuals["position_residuals"]
|
| 91 |
+
ratios = residuals["dimension_ratios"]
|
| 92 |
+
miss_rate = min(1.0, residuals["miss_rate"] * scale)
|
| 93 |
+
hallucination_rate = min(1.0, residuals["hallucination_rate"] * scale)
|
| 94 |
+
kept = {}
|
| 95 |
+
for class_name, items in code["objects"].items():
|
| 96 |
+
survivors = []
|
| 97 |
+
for item in items:
|
| 98 |
+
if rng.random() < miss_rate:
|
| 99 |
+
continue
|
| 100 |
+
box = item["3D oriented bounding box"]
|
| 101 |
+
if positions:
|
| 102 |
+
residual = positions[rng.randrange(len(positions))]
|
| 103 |
+
box["3D oriented bounding box center coordinates"] = [
|
| 104 |
+
round(value + delta * scale, 2)
|
| 105 |
+
for value, delta in zip(
|
| 106 |
+
box["3D oriented bounding box center coordinates"], residual
|
| 107 |
+
)
|
| 108 |
+
]
|
| 109 |
+
if ratios:
|
| 110 |
+
ratio = ratios[rng.randrange(len(ratios))]
|
| 111 |
+
box["3D oriented bounding box dimensions"] = [
|
| 112 |
+
round(max(0.01, value * (1.0 + (factor - 1.0) * scale)), 2)
|
| 113 |
+
for value, factor in zip(
|
| 114 |
+
box["3D oriented bounding box dimensions"], ratio
|
| 115 |
+
)
|
| 116 |
+
]
|
| 117 |
+
survivors.append(item)
|
| 118 |
+
if rng.random() < hallucination_rate:
|
| 119 |
+
ghost = json.loads(json.dumps(item))
|
| 120 |
+
ghost_box = ghost["3D oriented bounding box"]
|
| 121 |
+
center = ghost_box["3D oriented bounding box center coordinates"]
|
| 122 |
+
ghost_box["3D oriented bounding box center coordinates"] = [
|
| 123 |
+
round(center[0] + rng.gauss(0.0, 0.5), 2),
|
| 124 |
+
round(center[1] + rng.gauss(0.0, 0.5), 2),
|
| 125 |
+
center[2],
|
| 126 |
+
]
|
| 127 |
+
survivors.append(ghost)
|
| 128 |
+
if survivors:
|
| 129 |
+
kept[class_name] = survivors
|
| 130 |
+
code["objects"] = kept
|
| 131 |
+
return code
|
corruption/launch.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Grid looper for corruption conditions (Step 6.5).
|
| 2 |
+
|
| 3 |
+
Runs every (transform, magnitude) pair in a grid through corruption.run, one
|
| 4 |
+
condition at a time -- solver arm always (free), VLM arm per requested model. The
|
| 5 |
+
question sample comes from the pre-registered sample file (see
|
| 6 |
+
analysis/preregistration.md); pass --sample to enforce it.
|
| 7 |
+
|
| 8 |
+
Example (H21's grid, both 4B models):
|
| 9 |
+
python -m corruption.launch --arm both --models qwen3.5-4b,internvl3.5-4b \\
|
| 10 |
+
--transforms position-jitter,dimension-noise,drop-objects,hallucinate-objects \\
|
| 11 |
+
--magnitudes 0.1,0.25,0.5,1.0 --sample analysis/corruption_sample.json
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from __future__ import annotations
|
| 15 |
+
|
| 16 |
+
import argparse
|
| 17 |
+
import json
|
| 18 |
+
import sys
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
|
| 21 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 22 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 23 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 24 |
+
|
| 25 |
+
from corruption.run import ALL_CONDITIONS, run_solver, run_vlm # noqa: E402
|
| 26 |
+
from harness.A import models as vlm_models # noqa: E402
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def main():
|
| 30 |
+
parser = argparse.ArgumentParser()
|
| 31 |
+
parser.add_argument("--arm", default="both", choices=("vlm", "solver", "both"))
|
| 32 |
+
parser.add_argument(
|
| 33 |
+
"--models", default=None, help="comma-separated (required unless --arm solver)"
|
| 34 |
+
)
|
| 35 |
+
parser.add_argument("--transforms", required=True, help="comma-separated transform names")
|
| 36 |
+
parser.add_argument("--magnitudes", required=True, help="comma-separated magnitudes")
|
| 37 |
+
parser.add_argument(
|
| 38 |
+
"--spatial-code-format", default="explicit", choices=("explicit", "compact"),
|
| 39 |
+
dest="spatial_code_format",
|
| 40 |
+
)
|
| 41 |
+
parser.add_argument("--scenes", default=None, help="comma-separated scenes")
|
| 42 |
+
parser.add_argument("--sample", default=None, help="JSON list of question ids")
|
| 43 |
+
args = parser.parse_args()
|
| 44 |
+
|
| 45 |
+
transforms = [t.strip() for t in args.transforms.split(",") if t.strip()]
|
| 46 |
+
unknown = [t for t in transforms if t not in ALL_CONDITIONS]
|
| 47 |
+
if unknown:
|
| 48 |
+
parser.error(f"unknown transform(s) {unknown}; expected one of {ALL_CONDITIONS}")
|
| 49 |
+
magnitudes = [float(m.strip()) for m in args.magnitudes.split(",") if m.strip()]
|
| 50 |
+
models = []
|
| 51 |
+
if args.arm in ("vlm", "both"):
|
| 52 |
+
if not args.models:
|
| 53 |
+
parser.error(f"--arm {args.arm} requires --models")
|
| 54 |
+
models = [m.strip() for m in args.models.split(",") if m.strip()]
|
| 55 |
+
bad = [m for m in models if m not in vlm_models.available_models()]
|
| 56 |
+
if bad:
|
| 57 |
+
parser.error(f"unknown model(s) {bad}")
|
| 58 |
+
scenes = None
|
| 59 |
+
if args.scenes:
|
| 60 |
+
scenes = list(dict.fromkeys(s.strip() for s in args.scenes.split(",") if s.strip()))
|
| 61 |
+
question_ids = None
|
| 62 |
+
if args.sample:
|
| 63 |
+
with open(args.sample, encoding="utf-8") as stream:
|
| 64 |
+
question_ids = set(json.load(stream))
|
| 65 |
+
|
| 66 |
+
conditions = [(t, m) for t in transforms for m in magnitudes]
|
| 67 |
+
for index, (transform, magnitude) in enumerate(conditions, start=1):
|
| 68 |
+
print(f"=== corruption {index}/{len(conditions)}: {transform}@{magnitude} ===", flush=True)
|
| 69 |
+
if args.arm in ("solver", "both"):
|
| 70 |
+
results = run_solver(
|
| 71 |
+
transform, magnitude, args.spatial_code_format,
|
| 72 |
+
scenes=scenes, question_ids=question_ids,
|
| 73 |
+
)
|
| 74 |
+
print(f" [solver] {len(results)} questions", flush=True)
|
| 75 |
+
for model in models:
|
| 76 |
+
results = run_vlm(
|
| 77 |
+
model, transform, magnitude, args.spatial_code_format,
|
| 78 |
+
scenes=scenes, question_ids=question_ids,
|
| 79 |
+
)
|
| 80 |
+
print(f" [{model}] {len(results)} questions", flush=True)
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
main()
|
corruption/run.py
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Run one corruption condition -- (transform, magnitude) -- through both reasoners.
|
| 2 |
+
|
| 3 |
+
The VLM arm reuses ``harness.D.run.run`` completely unmodified via its
|
| 4 |
+
``code_transform`` hook, so a corrupted code goes through the byte-identical prompt/
|
| 5 |
+
adapter path clean D runs use. The solver arm answers the same corrupted codes with
|
| 6 |
+
``symbolic.solver`` at zero GPU cost. Both write one JSON per question under:
|
| 7 |
+
|
| 8 |
+
results/corruption/<arm>/<transform>/<magnitude>/<model-or-'symbolic'>/<scene>/<question_id>.json
|
| 9 |
+
|
| 10 |
+
Corruption always happens on the COMPACT ground-truth code; the requested format is
|
| 11 |
+
then derived through encoder's own ``_explicit_from_compact``, so corrupted explicit
|
| 12 |
+
and compact codes can never disagree (the clean pipeline's consistency guarantee,
|
| 13 |
+
preserved under corruption).
|
| 14 |
+
|
| 15 |
+
Chimera conditions (H22) additionally load the scene's PERCEIVED compact code (the
|
| 16 |
+
frozen Step-2 config) and are exposed as transform names "chimera-gt-inventory" /
|
| 17 |
+
"chimera-perceived-inventory"; "single-object" is the H6 probe; "wrong-scene" swaps
|
| 18 |
+
in another scene's ground-truth code entirely; "empirical" samples from the measured
|
| 19 |
+
SAM3+DA3 residual distribution (magnitude = scale, 1.0 = the real operating point).
|
| 20 |
+
|
| 21 |
+
``certify_invariant`` is H24's gate: a (scene, transform, magnitude) triple enters
|
| 22 |
+
the invariance analysis only if the solver returns identical answers on the original
|
| 23 |
+
and transformed code for every sampled question of that scene.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
from __future__ import annotations
|
| 27 |
+
|
| 28 |
+
import argparse
|
| 29 |
+
import json
|
| 30 |
+
import random
|
| 31 |
+
import sys
|
| 32 |
+
import zlib
|
| 33 |
+
from pathlib import Path
|
| 34 |
+
|
| 35 |
+
WORKSPACE_ROOT = Path(__file__).resolve().parent.parent
|
| 36 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 37 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 38 |
+
|
| 39 |
+
from corruption import RESULTS_DIR, SAMPLE_SEED # noqa: E402
|
| 40 |
+
from corruption import chimera as chimera_mod # noqa: E402
|
| 41 |
+
from corruption import empirical as empirical_mod # noqa: E402
|
| 42 |
+
from corruption.transforms import INVARIANCE_TRANSFORMS, TRANSFORMS # noqa: E402
|
| 43 |
+
from encoder.geometric import _explicit_from_compact # noqa: E402
|
| 44 |
+
from harness.A.run import _scalar_score, load_questions, vsi_official_eval # noqa: E402
|
| 45 |
+
from harness.B import spatial_codes as perceived_spatial_codes # noqa: E402
|
| 46 |
+
from harness.D import run as harness_d_run # noqa: E402
|
| 47 |
+
from harness.D import spatial_codes as gt_spatial_codes # noqa: E402
|
| 48 |
+
from symbolic import adapters, solver # noqa: E402
|
| 49 |
+
|
| 50 |
+
CHIMERA_CONDITIONS = ("chimera-gt-inventory", "chimera-perceived-inventory")
|
| 51 |
+
SPECIAL_CONDITIONS = CHIMERA_CONDITIONS + ("single-object", "wrong-scene", "empirical")
|
| 52 |
+
ALL_CONDITIONS = tuple(TRANSFORMS) + SPECIAL_CONDITIONS
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _seed_for(scene, transform, magnitude):
|
| 56 |
+
"""One deterministic seed per (scene, transform, magnitude): reproducible codes,
|
| 57 |
+
different randomness across scenes and conditions. crc32, NOT builtin hash() --
|
| 58 |
+
string hashing is randomized per process (PYTHONHASHSEED), which would silently
|
| 59 |
+
break cross-run reproducibility and the pre-registration's guarantee."""
|
| 60 |
+
key = repr((SAMPLE_SEED, scene, transform, magnitude)).encode("utf-8")
|
| 61 |
+
return zlib.crc32(key) & 0x7FFFFFFF
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def load_ground_truth_compact(scene):
|
| 65 |
+
"""Load one scene's ground-truth COMPACT code -- the base every corruption acts on."""
|
| 66 |
+
code, _path = gt_spatial_codes.load_spatial_code(scene, "compact")
|
| 67 |
+
return code
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def corrupted_compact(
|
| 71 |
+
scene, transform, magnitude, perceived_config=None, residuals=None, wrong_scene=None
|
| 72 |
+
):
|
| 73 |
+
"""Return the corrupted COMPACT code for one (scene, transform, magnitude)."""
|
| 74 |
+
rng = random.Random(_seed_for(scene, transform, magnitude))
|
| 75 |
+
if transform == "wrong-scene":
|
| 76 |
+
if wrong_scene is None:
|
| 77 |
+
raise ValueError("wrong-scene requires the substitute scene id")
|
| 78 |
+
return load_ground_truth_compact(wrong_scene)
|
| 79 |
+
code = load_ground_truth_compact(scene)
|
| 80 |
+
if transform in TRANSFORMS:
|
| 81 |
+
return TRANSFORMS[transform](code, magnitude, rng)
|
| 82 |
+
if transform == "single-object":
|
| 83 |
+
perturbed, _info = chimera_mod.perturb_single_object(code, rng)
|
| 84 |
+
return perturbed
|
| 85 |
+
if transform == "empirical":
|
| 86 |
+
if residuals is None:
|
| 87 |
+
raise ValueError("empirical requires measured residuals (corruption.empirical)")
|
| 88 |
+
return empirical_mod.empirical_noise(code, residuals, rng, scale=magnitude)
|
| 89 |
+
if transform in CHIMERA_CONDITIONS:
|
| 90 |
+
if perceived_config is None:
|
| 91 |
+
raise ValueError("chimera conditions require the perceived-code config")
|
| 92 |
+
perceived, _path = perceived_spatial_codes.load_spatial_code(
|
| 93 |
+
scene,
|
| 94 |
+
perceived_config["depth"],
|
| 95 |
+
perceived_config["input_selection"],
|
| 96 |
+
perceived_config["tracking"],
|
| 97 |
+
perceived_config["frame_count"],
|
| 98 |
+
"compact",
|
| 99 |
+
)
|
| 100 |
+
if transform == "chimera-gt-inventory":
|
| 101 |
+
hybrid, _coverage = chimera_mod.gt_inventory_perceived_geometry(code, perceived)
|
| 102 |
+
else:
|
| 103 |
+
hybrid, _coverage = chimera_mod.perceived_inventory_gt_geometry(code, perceived)
|
| 104 |
+
return hybrid
|
| 105 |
+
raise ValueError(f"unknown transform {transform!r}; expected one of {ALL_CONDITIONS}")
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def corrupted_code(scene, transform, magnitude, spatial_code_format, **kwargs):
|
| 109 |
+
"""Corrupt the compact code, then derive the requested format from it -- the same
|
| 110 |
+
derivation path the encoder uses, so both formats stay consistent under corruption."""
|
| 111 |
+
compact = corrupted_compact(scene, transform, magnitude, **kwargs)
|
| 112 |
+
if spatial_code_format == "compact":
|
| 113 |
+
return compact
|
| 114 |
+
explicit, _floor_area = _explicit_from_compact(compact)
|
| 115 |
+
return explicit
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def results_dir_for(arm, transform, magnitude, model):
|
| 119 |
+
"""Return the result root isolated by arm + transform + magnitude + model."""
|
| 120 |
+
return RESULTS_DIR / arm / transform / str(magnitude) / model
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def make_code_transform(transform, magnitude, **kwargs):
|
| 124 |
+
"""Build the ``harness.D.run.run(code_transform=...)`` hook for one condition."""
|
| 125 |
+
|
| 126 |
+
def hook(_loaded_code, scene_id, spatial_code_format):
|
| 127 |
+
return corrupted_code(scene_id, transform, magnitude, spatial_code_format, **kwargs)
|
| 128 |
+
|
| 129 |
+
return hook
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def run_vlm(
|
| 133 |
+
model, transform, magnitude, spatial_code_format="explicit", scenes=None, limit=None,
|
| 134 |
+
question_ids=None, results_dir=None, **kwargs
|
| 135 |
+
):
|
| 136 |
+
"""Answer the sampled questions with one VLM on corrupted codes, through
|
| 137 |
+
harness.D's unmodified path. Returns harness.D-shape records."""
|
| 138 |
+
root = results_dir or results_dir_for("vlm", transform, magnitude, model)
|
| 139 |
+
results = harness_d_run.run(
|
| 140 |
+
model,
|
| 141 |
+
spatial_code_format=spatial_code_format,
|
| 142 |
+
scenes=scenes,
|
| 143 |
+
limit=limit,
|
| 144 |
+
results_dir=root,
|
| 145 |
+
code_transform=make_code_transform(transform, magnitude, **kwargs),
|
| 146 |
+
)
|
| 147 |
+
if question_ids is not None:
|
| 148 |
+
results = [r for r in results if r["question_id"] in question_ids]
|
| 149 |
+
return results
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def run_solver(
|
| 153 |
+
transform, magnitude, spatial_code_format="explicit", scenes=None, limit=None,
|
| 154 |
+
question_ids=None, write_results=True, results_dir=None, **kwargs
|
| 155 |
+
):
|
| 156 |
+
"""Answer the sampled questions with the symbolic solver on the SAME corrupted
|
| 157 |
+
codes -- the zero-GPU second reasoner for every corruption arm."""
|
| 158 |
+
rows = load_questions(None, None, scenes, limit)
|
| 159 |
+
if question_ids is not None:
|
| 160 |
+
rows = [row for row in rows if row["id"] in question_ids]
|
| 161 |
+
root = Path(results_dir or results_dir_for("solver", transform, magnitude, "symbolic"))
|
| 162 |
+
code_cache = {}
|
| 163 |
+
results = []
|
| 164 |
+
for row in rows:
|
| 165 |
+
scene = row["scene_name"]
|
| 166 |
+
if scene not in code_cache:
|
| 167 |
+
code = corrupted_code(scene, transform, magnitude, spatial_code_format, **kwargs)
|
| 168 |
+
code_cache[scene] = adapters.adapt_spatial_code(code)
|
| 169 |
+
answer = solver.answer(
|
| 170 |
+
row["question_type"], row["question"], row["options"], code_cache[scene]
|
| 171 |
+
)
|
| 172 |
+
pred = "" if answer is None else str(answer)
|
| 173 |
+
doc = {"question_type": row["question_type"], "ground_truth": row["ground_truth"]}
|
| 174 |
+
score_doc = vsi_official_eval.vsibench_process_results(doc, [pred])["vsibench_score"]
|
| 175 |
+
metric_name, score = _scalar_score(row["question_type"], score_doc)
|
| 176 |
+
record = {
|
| 177 |
+
"model": "symbolic",
|
| 178 |
+
"condition": f"{transform}:{magnitude}:{spatial_code_format}",
|
| 179 |
+
"transform": transform,
|
| 180 |
+
"magnitude": magnitude,
|
| 181 |
+
"spatial_code_format": spatial_code_format,
|
| 182 |
+
"scene": scene,
|
| 183 |
+
"dataset": row.get("dataset"),
|
| 184 |
+
"question_id": row["id"],
|
| 185 |
+
"question_type": row["question_type"],
|
| 186 |
+
"question": row["question"],
|
| 187 |
+
"options": row.get("options"),
|
| 188 |
+
"answer_expected": row["ground_truth"],
|
| 189 |
+
"answer_given": pred,
|
| 190 |
+
"metric": metric_name,
|
| 191 |
+
"score": score,
|
| 192 |
+
}
|
| 193 |
+
if write_results:
|
| 194 |
+
scene_dir = root / scene
|
| 195 |
+
scene_dir.mkdir(parents=True, exist_ok=True)
|
| 196 |
+
path = scene_dir / f"{row['id']}.json"
|
| 197 |
+
with path.open("w", encoding="utf-8") as stream:
|
| 198 |
+
json.dump(record, stream, indent=1)
|
| 199 |
+
record["result_path"] = str(path)
|
| 200 |
+
else:
|
| 201 |
+
record["result_path"] = None
|
| 202 |
+
results.append(record)
|
| 203 |
+
return results
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def certify_invariant(scene, transform, magnitude, spatial_code_format="explicit"):
|
| 207 |
+
"""H24's gate: True iff the solver returns identical answers on the original and
|
| 208 |
+
transformed code for EVERY question of this scene. Only certified triples enter
|
| 209 |
+
the invariance analysis -- this is the proof the transformation was truly null."""
|
| 210 |
+
if transform not in INVARIANCE_TRANSFORMS:
|
| 211 |
+
raise ValueError(f"{transform!r} is not an invariance transform")
|
| 212 |
+
rows = load_questions(None, scene, None, None)
|
| 213 |
+
original, _path = gt_spatial_codes.load_spatial_code(scene, spatial_code_format)
|
| 214 |
+
transformed = corrupted_code(scene, transform, magnitude, spatial_code_format)
|
| 215 |
+
adapted_original = adapters.adapt_spatial_code(original)
|
| 216 |
+
adapted_transformed = adapters.adapt_spatial_code(transformed)
|
| 217 |
+
for row in rows:
|
| 218 |
+
before = solver.answer(
|
| 219 |
+
row["question_type"], row["question"], row["options"], adapted_original
|
| 220 |
+
)
|
| 221 |
+
after = solver.answer(
|
| 222 |
+
row["question_type"], row["question"], row["options"], adapted_transformed
|
| 223 |
+
)
|
| 224 |
+
if before != after:
|
| 225 |
+
return False
|
| 226 |
+
return True
|
| 227 |
+
|
| 228 |
+
|
| 229 |
+
def main():
|
| 230 |
+
parser = argparse.ArgumentParser()
|
| 231 |
+
parser.add_argument("--arm", required=True, choices=("vlm", "solver", "certify"))
|
| 232 |
+
parser.add_argument("--transform", required=True, choices=ALL_CONDITIONS)
|
| 233 |
+
parser.add_argument("--magnitude", type=float, required=True)
|
| 234 |
+
parser.add_argument("--model", default=None, help="required for --arm vlm")
|
| 235 |
+
parser.add_argument(
|
| 236 |
+
"--spatial-code-format", default="explicit", choices=("explicit", "compact"),
|
| 237 |
+
dest="spatial_code_format",
|
| 238 |
+
)
|
| 239 |
+
parser.add_argument("--scenes", default=None, help="comma-separated scenes")
|
| 240 |
+
parser.add_argument("--limit", type=int, default=None)
|
| 241 |
+
parser.add_argument(
|
| 242 |
+
"--sample", default=None,
|
| 243 |
+
help="path to a JSON list of question ids (the pre-registered sample)",
|
| 244 |
+
)
|
| 245 |
+
parser.add_argument("--results-dir", default=None)
|
| 246 |
+
args = parser.parse_args()
|
| 247 |
+
|
| 248 |
+
scenes = None
|
| 249 |
+
if args.scenes:
|
| 250 |
+
scenes = list(dict.fromkeys(s.strip() for s in args.scenes.split(",") if s.strip()))
|
| 251 |
+
question_ids = None
|
| 252 |
+
if args.sample:
|
| 253 |
+
with open(args.sample, encoding="utf-8") as stream:
|
| 254 |
+
question_ids = set(json.load(stream))
|
| 255 |
+
|
| 256 |
+
if args.arm == "certify":
|
| 257 |
+
if not scenes:
|
| 258 |
+
parser.error("--arm certify requires --scenes")
|
| 259 |
+
for scene in scenes:
|
| 260 |
+
ok = certify_invariant(
|
| 261 |
+
scene, args.transform, args.magnitude, args.spatial_code_format
|
| 262 |
+
)
|
| 263 |
+
print(f"{scene}: {'CERTIFIED' if ok else 'NOT invariant'}")
|
| 264 |
+
return
|
| 265 |
+
|
| 266 |
+
if args.arm == "vlm":
|
| 267 |
+
if not args.model:
|
| 268 |
+
parser.error("--arm vlm requires --model")
|
| 269 |
+
results = run_vlm(
|
| 270 |
+
args.model, args.transform, args.magnitude, args.spatial_code_format,
|
| 271 |
+
scenes=scenes, limit=args.limit, question_ids=question_ids,
|
| 272 |
+
results_dir=args.results_dir,
|
| 273 |
+
)
|
| 274 |
+
else:
|
| 275 |
+
results = run_solver(
|
| 276 |
+
args.transform, args.magnitude, args.spatial_code_format,
|
| 277 |
+
scenes=scenes, limit=args.limit, question_ids=question_ids,
|
| 278 |
+
results_dir=args.results_dir,
|
| 279 |
+
)
|
| 280 |
+
if results:
|
| 281 |
+
mean_score = sum(r["score"] for r in results) / len(results)
|
| 282 |
+
print(f"{len(results)} questions, mean vsibench_score={mean_score:.4f}")
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
if __name__ == "__main__":
|
| 286 |
+
main()
|
corruption/transforms.py
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Parameterized transformations of COMPACT spatial codes.
|
| 2 |
+
|
| 3 |
+
Two families with opposite intent:
|
| 4 |
+
|
| 5 |
+
- NOISE transforms (H21) change the geometry by a controlled magnitude -- they are
|
| 6 |
+
meant to destroy information, and the dose is the experimental variable.
|
| 7 |
+
- INVARIANCE transforms (H24) provably change NOTHING any question depends on
|
| 8 |
+
(translation/rotation act on absolute coordinates no VSI-Bench question type asks
|
| 9 |
+
about; reorder/precision are surface form). "Provably" is enforced downstream:
|
| 10 |
+
corruption.run.certify_invariant() checks the solver returns identical answers on
|
| 11 |
+
the transformed code, and only certified (scene, transform) pairs enter H24.
|
| 12 |
+
|
| 13 |
+
Every transform is a pure function: it deep-copies its input (via JSON round-trip,
|
| 14 |
+
which also guarantees the result is exactly what would be serialized into a prompt)
|
| 15 |
+
and never mutates the original. Randomized transforms take a seeded
|
| 16 |
+
``random.Random`` so every corrupted code is reproducible from
|
| 17 |
+
(scene, transform, magnitude, seed).
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from __future__ import annotations
|
| 21 |
+
|
| 22 |
+
import json
|
| 23 |
+
import math
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _copy(code):
|
| 27 |
+
return json.loads(json.dumps(code))
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _instances(code):
|
| 31 |
+
"""Yield every (class_name, instance) pair in a compact code."""
|
| 32 |
+
for class_name, items in code["objects"].items():
|
| 33 |
+
for item in items:
|
| 34 |
+
yield class_name, item
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _box(instance):
|
| 38 |
+
return instance["3D oriented bounding box"]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _polygons(code):
|
| 42 |
+
return code["room"].get("floor boundary polygons", [])
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# ==========================================================================================
|
| 46 |
+
# NOISE FAMILY (H21) -- magnitude is the dose.
|
| 47 |
+
# ==========================================================================================
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def position_jitter(code, sigma_meters, rng):
|
| 51 |
+
"""Add iid Gaussian noise (std ``sigma_meters``) to every box center coordinate."""
|
| 52 |
+
code = _copy(code)
|
| 53 |
+
for _name, instance in _instances(code):
|
| 54 |
+
box = _box(instance)
|
| 55 |
+
center = box["3D oriented bounding box center coordinates"]
|
| 56 |
+
box["3D oriented bounding box center coordinates"] = [
|
| 57 |
+
round(value + rng.gauss(0.0, sigma_meters), 2) for value in center
|
| 58 |
+
]
|
| 59 |
+
return code
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def dimension_noise(code, relative_sigma, rng):
|
| 63 |
+
"""Scale every box dimension by (1 + Gaussian(0, relative_sigma)), floored at 5%
|
| 64 |
+
of the original so no dimension collapses to zero or goes negative."""
|
| 65 |
+
code = _copy(code)
|
| 66 |
+
for _name, instance in _instances(code):
|
| 67 |
+
box = _box(instance)
|
| 68 |
+
dimensions = box["3D oriented bounding box dimensions"]
|
| 69 |
+
box["3D oriented bounding box dimensions"] = [
|
| 70 |
+
round(value * max(0.05, 1.0 + rng.gauss(0.0, relative_sigma)), 2)
|
| 71 |
+
for value in dimensions
|
| 72 |
+
]
|
| 73 |
+
return code
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def drop_objects(code, fraction, rng):
|
| 77 |
+
"""Delete each instance independently with probability ``fraction`` (simulated
|
| 78 |
+
missed detections). A class whose instances are all dropped disappears entirely,
|
| 79 |
+
exactly as an undetected class would."""
|
| 80 |
+
code = _copy(code)
|
| 81 |
+
kept = {}
|
| 82 |
+
for class_name, items in code["objects"].items():
|
| 83 |
+
remaining = [item for item in items if rng.random() >= fraction]
|
| 84 |
+
if remaining:
|
| 85 |
+
kept[class_name] = remaining
|
| 86 |
+
code["objects"] = kept
|
| 87 |
+
return code
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def hallucinate_objects(code, fraction, rng):
|
| 91 |
+
"""Duplicate each instance with probability ``fraction`` (simulated duplicate/
|
| 92 |
+
phantom detections), displacing the copy by ~0.5 m so it reads as a distinct
|
| 93 |
+
object rather than an exact double."""
|
| 94 |
+
code = _copy(code)
|
| 95 |
+
for class_name, items in code["objects"].items():
|
| 96 |
+
extras = []
|
| 97 |
+
for item in items:
|
| 98 |
+
if rng.random() < fraction:
|
| 99 |
+
ghost = _copy(item)
|
| 100 |
+
box = _box(ghost)
|
| 101 |
+
center = box["3D oriented bounding box center coordinates"]
|
| 102 |
+
box["3D oriented bounding box center coordinates"] = [
|
| 103 |
+
round(center[0] + rng.gauss(0.0, 0.5), 2),
|
| 104 |
+
round(center[1] + rng.gauss(0.0, 0.5), 2),
|
| 105 |
+
center[2],
|
| 106 |
+
]
|
| 107 |
+
extras.append(ghost)
|
| 108 |
+
items.extend(extras)
|
| 109 |
+
return code
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def class_swap(code, fraction, rng):
|
| 113 |
+
"""Swap the labels of ~``fraction`` of class pairs (simulated misclassification):
|
| 114 |
+
the geometry stays exactly where it is, but it is attributed to the wrong class."""
|
| 115 |
+
code = _copy(code)
|
| 116 |
+
names = sorted(code["objects"])
|
| 117 |
+
if len(names) < 2:
|
| 118 |
+
return code
|
| 119 |
+
shuffled = list(names)
|
| 120 |
+
rng.shuffle(shuffled)
|
| 121 |
+
swap_count = max(1, int(round(len(names) * fraction / 2.0))) if fraction > 0 else 0
|
| 122 |
+
objects = code["objects"]
|
| 123 |
+
for index in range(swap_count):
|
| 124 |
+
first, second = shuffled[2 * index], shuffled[2 * index + 1]
|
| 125 |
+
if 2 * index + 1 >= len(shuffled):
|
| 126 |
+
break
|
| 127 |
+
objects[first], objects[second] = objects[second], objects[first]
|
| 128 |
+
return code
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
# ==========================================================================================
|
| 132 |
+
# INVARIANCE FAMILY (H24) -- provably answer-preserving; certified by the solver.
|
| 133 |
+
# ==========================================================================================
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def translate(code, offset_meters, rng=None):
|
| 137 |
+
"""Shift the whole scene's x/y origin by ``offset_meters`` in both axes: box
|
| 138 |
+
centers and floor polygons move together; heights and all relative geometry are
|
| 139 |
+
untouched. No VSI-Bench question type references absolute coordinates."""
|
| 140 |
+
code = _copy(code)
|
| 141 |
+
for _name, instance in _instances(code):
|
| 142 |
+
box = _box(instance)
|
| 143 |
+
center = box["3D oriented bounding box center coordinates"]
|
| 144 |
+
box["3D oriented bounding box center coordinates"] = [
|
| 145 |
+
round(center[0] + offset_meters, 2),
|
| 146 |
+
round(center[1] + offset_meters, 2),
|
| 147 |
+
center[2],
|
| 148 |
+
]
|
| 149 |
+
for polygon in _polygons(code):
|
| 150 |
+
for key in ("outer boundary coordinates", "interior hole boundary coordinates"):
|
| 151 |
+
if key not in polygon:
|
| 152 |
+
continue
|
| 153 |
+
if key == "outer boundary coordinates":
|
| 154 |
+
polygon[key] = [
|
| 155 |
+
[round(x + offset_meters, 2), round(y + offset_meters, 2)]
|
| 156 |
+
for x, y in polygon[key]
|
| 157 |
+
]
|
| 158 |
+
else:
|
| 159 |
+
polygon[key] = [
|
| 160 |
+
[[round(x + offset_meters, 2), round(y + offset_meters, 2)] for x, y in hole]
|
| 161 |
+
for hole in polygon[key]
|
| 162 |
+
]
|
| 163 |
+
return code
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def rotate_z(code, angle_degrees, rng=None):
|
| 167 |
+
"""Rotate the whole scene about the vertical axis: box centers, box orientation
|
| 168 |
+
vectors, and floor polygons rotate together, so every relative relationship is
|
| 169 |
+
exactly preserved."""
|
| 170 |
+
code = _copy(code)
|
| 171 |
+
theta = math.radians(angle_degrees)
|
| 172 |
+
cos, sin = math.cos(theta), math.sin(theta)
|
| 173 |
+
|
| 174 |
+
def rotate_xy(x, y):
|
| 175 |
+
return x * cos - y * sin, x * sin + y * cos
|
| 176 |
+
|
| 177 |
+
for _name, instance in _instances(code):
|
| 178 |
+
box = _box(instance)
|
| 179 |
+
center = box["3D oriented bounding box center coordinates"]
|
| 180 |
+
x, y = rotate_xy(center[0], center[1])
|
| 181 |
+
box["3D oriented bounding box center coordinates"] = [round(x, 2), round(y, 2), center[2]]
|
| 182 |
+
vectors = box["3D oriented bounding box orientation unit vectors"]
|
| 183 |
+
box["3D oriented bounding box orientation unit vectors"] = [
|
| 184 |
+
[round(v, 2) for v in (*rotate_xy(vector[0], vector[1]), vector[2])]
|
| 185 |
+
for vector in vectors
|
| 186 |
+
]
|
| 187 |
+
for polygon in _polygons(code):
|
| 188 |
+
if "outer boundary coordinates" in polygon:
|
| 189 |
+
polygon["outer boundary coordinates"] = [
|
| 190 |
+
[round(v, 2) for v in rotate_xy(x, y)]
|
| 191 |
+
for x, y in polygon["outer boundary coordinates"]
|
| 192 |
+
]
|
| 193 |
+
if "interior hole boundary coordinates" in polygon:
|
| 194 |
+
polygon["interior hole boundary coordinates"] = [
|
| 195 |
+
[[round(v, 2) for v in rotate_xy(x, y)] for x, y in hole]
|
| 196 |
+
for hole in polygon["interior hole boundary coordinates"]
|
| 197 |
+
]
|
| 198 |
+
return code
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def reorder(code, _magnitude, rng):
|
| 202 |
+
"""Shuffle class order and instance order (surface form only -- JSON object order
|
| 203 |
+
is what the model reads, but no geometry changes at all)."""
|
| 204 |
+
code = _copy(code)
|
| 205 |
+
names = list(code["objects"])
|
| 206 |
+
rng.shuffle(names)
|
| 207 |
+
reordered = {}
|
| 208 |
+
for name in names:
|
| 209 |
+
items = list(code["objects"][name])
|
| 210 |
+
rng.shuffle(items)
|
| 211 |
+
reordered[name] = items
|
| 212 |
+
code["objects"] = reordered
|
| 213 |
+
return code
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
def round_precision(code, decimals, rng=None):
|
| 217 |
+
"""Re-round every numeric geometry value to ``decimals`` places. NOT guaranteed
|
| 218 |
+
answer-preserving a priori (aggressive rounding can flip a borderline answer) --
|
| 219 |
+
which is exactly why the solver certification step exists: only (scene, decimals)
|
| 220 |
+
pairs the solver certifies unchanged enter H24."""
|
| 221 |
+
code = _copy(code)
|
| 222 |
+
decimals = int(decimals)
|
| 223 |
+
for _name, instance in _instances(code):
|
| 224 |
+
box = _box(instance)
|
| 225 |
+
for key in (
|
| 226 |
+
"3D oriented bounding box center coordinates",
|
| 227 |
+
"3D oriented bounding box dimensions",
|
| 228 |
+
):
|
| 229 |
+
box[key] = [round(value, decimals) for value in box[key]]
|
| 230 |
+
box["3D oriented bounding box orientation unit vectors"] = [
|
| 231 |
+
[round(value, decimals) for value in vector]
|
| 232 |
+
for vector in box["3D oriented bounding box orientation unit vectors"]
|
| 233 |
+
]
|
| 234 |
+
return code
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
# name -> (callable, family); every callable takes (code, magnitude, rng).
|
| 238 |
+
NOISE_TRANSFORMS = {
|
| 239 |
+
"position-jitter": position_jitter,
|
| 240 |
+
"dimension-noise": dimension_noise,
|
| 241 |
+
"drop-objects": drop_objects,
|
| 242 |
+
"hallucinate-objects": hallucinate_objects,
|
| 243 |
+
"class-swap": class_swap,
|
| 244 |
+
}
|
| 245 |
+
INVARIANCE_TRANSFORMS = {
|
| 246 |
+
"translate": translate,
|
| 247 |
+
"rotate-z": rotate_z,
|
| 248 |
+
"reorder": reorder,
|
| 249 |
+
"round-precision": round_precision,
|
| 250 |
+
}
|
| 251 |
+
TRANSFORMS = {**NOISE_TRANSFORMS, **INVARIANCE_TRANSFORMS}
|
harness/C/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"{
|
| 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/D/launch.py
CHANGED
|
@@ -39,7 +39,7 @@ def _load_run_module():
|
|
| 39 |
|
| 40 |
|
| 41 |
def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
|
| 42 |
-
reasoning_budget, force_budget):
|
| 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"):
|
|
@@ -66,6 +66,7 @@ def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_th
|
|
| 66 |
scene=scene,
|
| 67 |
results_dir=results_dir,
|
| 68 |
adapter=adapter,
|
|
|
|
| 69 |
reasoning_budget=reasoning_budget,
|
| 70 |
force_budget=force_budget,
|
| 71 |
)
|
|
@@ -81,12 +82,13 @@ def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_th
|
|
| 81 |
|
| 82 |
def launch(
|
| 83 |
model, spatial_code_format, selected, results_dir=None, rebuild=False,
|
| 84 |
-
reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
|
| 85 |
):
|
| 86 |
"""Answer every question for ``selected`` scenes, sharded across every visible GPU."""
|
| 87 |
-
|
|
|
|
| 88 |
run = _load_run_module()
|
| 89 |
-
root = run.results_dir_for(model, spatial_code_format, results_dir)
|
| 90 |
pending = []
|
| 91 |
completed = 0
|
| 92 |
for scene in selected:
|
|
@@ -123,7 +125,7 @@ def launch(
|
|
| 123 |
target=_worker,
|
| 124 |
args=(
|
| 125 |
tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
|
| 126 |
-
reasoning_budget, force_budget,
|
| 127 |
),
|
| 128 |
)
|
| 129 |
for gpu in assignments
|
|
@@ -174,6 +176,10 @@ def main():
|
|
| 174 |
)
|
| 175 |
parser.add_argument("--results-dir", default=None)
|
| 176 |
parser.add_argument("--rebuild", action="store_true")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
|
| 178 |
parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
|
| 179 |
args = parser.parse_args()
|
|
@@ -193,6 +199,7 @@ def main():
|
|
| 193 |
launch(
|
| 194 |
args.model, args.spatial_code_format, selected,
|
| 195 |
results_dir=args.results_dir, rebuild=args.rebuild,
|
|
|
|
| 196 |
reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
|
| 197 |
)
|
| 198 |
|
|
|
|
| 39 |
|
| 40 |
|
| 41 |
def _worker(tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
|
| 42 |
+
extended, reasoning_budget, force_budget):
|
| 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"):
|
|
|
|
| 66 |
scene=scene,
|
| 67 |
results_dir=results_dir,
|
| 68 |
adapter=adapter,
|
| 69 |
+
extended=extended,
|
| 70 |
reasoning_budget=reasoning_budget,
|
| 71 |
force_budget=force_budget,
|
| 72 |
)
|
|
|
|
| 82 |
|
| 83 |
def launch(
|
| 84 |
model, spatial_code_format, selected, results_dir=None, rebuild=False,
|
| 85 |
+
extended=True, reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
|
| 86 |
):
|
| 87 |
"""Answer every question for ``selected`` scenes, sharded across every visible GPU."""
|
| 88 |
+
protocol = "extended" if extended else "base"
|
| 89 |
+
condition = f"{model}/{protocol}/{spatial_code_format}"
|
| 90 |
run = _load_run_module()
|
| 91 |
+
root = run.results_dir_for(model, protocol, spatial_code_format, results_dir)
|
| 92 |
pending = []
|
| 93 |
completed = 0
|
| 94 |
for scene in selected:
|
|
|
|
| 125 |
target=_worker,
|
| 126 |
args=(
|
| 127 |
tasks, results, model, spatial_code_format, results_dir, gpu, cpu_threads,
|
| 128 |
+
extended, reasoning_budget, force_budget,
|
| 129 |
),
|
| 130 |
)
|
| 131 |
for gpu in assignments
|
|
|
|
| 176 |
)
|
| 177 |
parser.add_argument("--results-dir", default=None)
|
| 178 |
parser.add_argument("--rebuild", action="store_true")
|
| 179 |
+
parser.add_argument(
|
| 180 |
+
"--base-protocol", action="store_true",
|
| 181 |
+
help="run harness.A's exact fixed 16-token protocol instead of the extended default",
|
| 182 |
+
)
|
| 183 |
parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
|
| 184 |
parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
|
| 185 |
args = parser.parse_args()
|
|
|
|
| 199 |
launch(
|
| 200 |
args.model, args.spatial_code_format, selected,
|
| 201 |
results_dir=args.results_dir, rebuild=args.rebuild,
|
| 202 |
+
extended=not args.base_protocol,
|
| 203 |
reasoning_budget=args.reasoning_budget, force_budget=args.force_budget,
|
| 204 |
)
|
| 205 |
|
harness/D/sweep.py
CHANGED
|
@@ -37,14 +37,21 @@ def build_plan(models, spatial_code_formats):
|
|
| 37 |
]
|
| 38 |
|
| 39 |
|
| 40 |
-
def sweep(
|
|
|
|
|
|
|
|
|
|
| 41 |
"""Run every (model, spatial_code_format) pair across all visible GPUs."""
|
| 42 |
plan = build_plan(models, spatial_code_formats)
|
|
|
|
| 43 |
for index, (model, spatial_code_format) in enumerate(plan, start=1):
|
| 44 |
-
print(
|
|
|
|
|
|
|
|
|
|
| 45 |
harness_launch.launch(
|
| 46 |
model, spatial_code_format, selected_scenes,
|
| 47 |
-
results_dir=results_dir, rebuild=rebuild,
|
| 48 |
)
|
| 49 |
|
| 50 |
|
|
@@ -64,6 +71,11 @@ def main():
|
|
| 64 |
)
|
| 65 |
parser.add_argument("--results-dir", default=None)
|
| 66 |
parser.add_argument("--rebuild", action="store_true")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
args = parser.parse_args()
|
| 68 |
if args.scene and args.scenes:
|
| 69 |
parser.error("positional scene and --scenes cannot be used together")
|
|
@@ -84,7 +96,11 @@ def main():
|
|
| 84 |
else:
|
| 85 |
selected = [args.scene] if args.scene else harness_launch.scenes()
|
| 86 |
|
| 87 |
-
sweep(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
|
| 90 |
if __name__ == "__main__":
|
|
|
|
| 37 |
]
|
| 38 |
|
| 39 |
|
| 40 |
+
def sweep(
|
| 41 |
+
models, spatial_code_formats, selected_scenes, results_dir=None, rebuild=False,
|
| 42 |
+
extended=True,
|
| 43 |
+
):
|
| 44 |
"""Run every (model, spatial_code_format) pair across all visible GPUs."""
|
| 45 |
plan = build_plan(models, spatial_code_formats)
|
| 46 |
+
protocol = "extended" if extended else "base"
|
| 47 |
for index, (model, spatial_code_format) in enumerate(plan, start=1):
|
| 48 |
+
print(
|
| 49 |
+
f"=== sweep {index}/{len(plan)}: {model}/{protocol}/{spatial_code_format} ===",
|
| 50 |
+
flush=True,
|
| 51 |
+
)
|
| 52 |
harness_launch.launch(
|
| 53 |
model, spatial_code_format, selected_scenes,
|
| 54 |
+
results_dir=results_dir, rebuild=rebuild, extended=extended,
|
| 55 |
)
|
| 56 |
|
| 57 |
|
|
|
|
| 71 |
)
|
| 72 |
parser.add_argument("--results-dir", default=None)
|
| 73 |
parser.add_argument("--rebuild", action="store_true")
|
| 74 |
+
parser.add_argument(
|
| 75 |
+
"--base-protocol", action="store_true",
|
| 76 |
+
help="run the whole sweep under harness.A's exact fixed 16-token protocol "
|
| 77 |
+
"instead of the extended 2048-token default",
|
| 78 |
+
)
|
| 79 |
args = parser.parse_args()
|
| 80 |
if args.scene and args.scenes:
|
| 81 |
parser.error("positional scene and --scenes cannot be used together")
|
|
|
|
| 96 |
else:
|
| 97 |
selected = [args.scene] if args.scene else harness_launch.scenes()
|
| 98 |
|
| 99 |
+
sweep(
|
| 100 |
+
models, spatial_code_formats, selected,
|
| 101 |
+
results_dir=args.results_dir, rebuild=args.rebuild,
|
| 102 |
+
extended=not args.base_protocol,
|
| 103 |
+
)
|
| 104 |
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
harness/E/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Harness E: the BLIND floor -- question (and options) only, no video frames, no
|
| 2 |
+
spatial code, no scene information of any kind.
|
| 3 |
+
|
| 4 |
+
VSI-Bench's own paper shows blind LLMs beat chance on several categories through pure
|
| 5 |
+
priors (typical room sizes, typical object sizes), so a question-only floor is what
|
| 6 |
+
separates "the model used the geometry it was given" from "the prompt shifted its
|
| 7 |
+
priors." Every harness A/B/C/D delta is only interpretable against this floor.
|
| 8 |
+
|
| 9 |
+
Reuses harness.A's models, generation protocols (base 16-token by default, --extended
|
| 10 |
+
opt-in, exactly like harness.A), question-type split, and post-prompts. Results are
|
| 11 |
+
written in the identical per-question record shape as every other harness:
|
| 12 |
+
results/E/<model>/<protocol>/<scene>/<question_id>.json.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import os
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
|
| 20 |
+
from harness.A import (
|
| 21 |
+
DO_SAMPLE,
|
| 22 |
+
JSONL,
|
| 23 |
+
MAX_NEW_TOKENS,
|
| 24 |
+
MODEL_PATHS,
|
| 25 |
+
PROTOCOLS,
|
| 26 |
+
TEMPERATURE,
|
| 27 |
+
WORKSPACE_ROOT,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
# One JSON per question: results/E/<model>/<protocol>/<scene>/<question_id>.json
|
| 31 |
+
RESULTS_DIR = Path(
|
| 32 |
+
os.environ.get("VSI_HARNESS_E_RESULTS_DIR", WORKSPACE_ROOT / "results" / "E")
|
| 33 |
+
)
|
harness/E/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (1.52 kB). View file
|
|
|
harness/E/__pycache__/prompts.cpython-311.pyc
ADDED
|
Binary file (1.8 kB). View file
|
|
|
harness/E/__pycache__/run.cpython-311.pyc
ADDED
|
Binary file (11.7 kB). View file
|
|
|
harness/E/__pycache__/sweep.cpython-311.pyc
ADDED
|
Binary file (4.7 kB). View file
|
|
|
harness/E/launch.py
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Keep every visible GPU busy with persistent harness-E (blind floor) workers.
|
| 2 |
+
|
| 3 |
+
Same shape as ``harness.A.launch``: one persistent worker process per visible GPU,
|
| 4 |
+
pulling scenes off a shared queue, each loading its model exactly once and reusing it
|
| 5 |
+
for every scene it's assigned (via ``run.run(..., adapter=...)``). One invocation
|
| 6 |
+
covers one (model, protocol) pair across every requested scene.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from __future__ import annotations
|
| 10 |
+
|
| 11 |
+
import argparse
|
| 12 |
+
import importlib.util
|
| 13 |
+
import multiprocessing as mp
|
| 14 |
+
import os
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
import sys
|
| 17 |
+
import traceback
|
| 18 |
+
|
| 19 |
+
HERE = Path(__file__).resolve().parent
|
| 20 |
+
WORKSPACE_ROOT = HERE.parent.parent
|
| 21 |
+
if str(WORKSPACE_ROOT) not in sys.path:
|
| 22 |
+
sys.path.insert(0, str(WORKSPACE_ROOT))
|
| 23 |
+
|
| 24 |
+
from harness.A import EXTENDED_MAX_NEW_TOKENS, MAX_NEW_TOKENS # noqa: E402
|
| 25 |
+
from harness.A import models as vlm_models # noqa: E402
|
| 26 |
+
from harness.A.launch import scenes # noqa: E402
|
| 27 |
+
from inference.launch import available_cpu_count, visible_gpus # noqa: E402
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _load_run_module():
|
| 31 |
+
spec = importlib.util.spec_from_file_location("_harness_E_run", HERE / "run.py")
|
| 32 |
+
module = importlib.util.module_from_spec(spec)
|
| 33 |
+
sys.modules[spec.name] = module
|
| 34 |
+
spec.loader.exec_module(module)
|
| 35 |
+
return module
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def _worker(tasks, results, model, results_dir, gpu, cpu_threads, extended,
|
| 39 |
+
reasoning_budget, force_budget):
|
| 40 |
+
if gpu is not None:
|
| 41 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = str(gpu)
|
| 42 |
+
for variable in ("OMP_NUM_THREADS", "MKL_NUM_THREADS", "OPENBLAS_NUM_THREADS"):
|
| 43 |
+
os.environ[variable] = str(cpu_threads)
|
| 44 |
+
run = _load_run_module()
|
| 45 |
+
adapter = None
|
| 46 |
+
load_error = None
|
| 47 |
+
try:
|
| 48 |
+
adapter = vlm_models.get_adapter(model)
|
| 49 |
+
adapter.load_model("cuda:0" if gpu is not None else "cpu")
|
| 50 |
+
except Exception:
|
| 51 |
+
load_error = traceback.format_exc()
|
| 52 |
+
while True:
|
| 53 |
+
scene = tasks.get()
|
| 54 |
+
if scene is None:
|
| 55 |
+
return
|
| 56 |
+
if load_error is not None:
|
| 57 |
+
results.put((scene, False, load_error))
|
| 58 |
+
continue
|
| 59 |
+
try:
|
| 60 |
+
answered = run.run(
|
| 61 |
+
model,
|
| 62 |
+
scene=scene,
|
| 63 |
+
results_dir=results_dir,
|
| 64 |
+
adapter=adapter,
|
| 65 |
+
extended=extended,
|
| 66 |
+
reasoning_budget=reasoning_budget,
|
| 67 |
+
force_budget=force_budget,
|
| 68 |
+
)
|
| 69 |
+
mean_score = (
|
| 70 |
+
sum(r["score"] for r in answered) / len(answered) if answered else None
|
| 71 |
+
)
|
| 72 |
+
results.put(
|
| 73 |
+
(scene, True, f"{len(answered)} question(s), mean_score={mean_score}")
|
| 74 |
+
)
|
| 75 |
+
except Exception:
|
| 76 |
+
results.put((scene, False, traceback.format_exc()))
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def launch(
|
| 80 |
+
model, selected, results_dir=None, rebuild=False, extended=False,
|
| 81 |
+
reasoning_budget=EXTENDED_MAX_NEW_TOKENS, force_budget=MAX_NEW_TOKENS,
|
| 82 |
+
):
|
| 83 |
+
"""Answer every question for ``selected`` scenes, sharded across every visible GPU."""
|
| 84 |
+
protocol = "extended" if extended else "base"
|
| 85 |
+
condition = f"{model}/{protocol}"
|
| 86 |
+
run = _load_run_module()
|
| 87 |
+
root = run.results_dir_for(model, protocol, results_dir)
|
| 88 |
+
pending = []
|
| 89 |
+
completed = 0
|
| 90 |
+
for scene in selected:
|
| 91 |
+
rows = run.load_questions(scene=scene)
|
| 92 |
+
answered = all((root / scene / f"{row['id']}.json").is_file() for row in rows)
|
| 93 |
+
if answered and not rebuild:
|
| 94 |
+
completed += 1
|
| 95 |
+
print(f"[{condition} {completed}/{len(selected)}] {scene}: skipped", flush=True)
|
| 96 |
+
else:
|
| 97 |
+
pending.append(scene)
|
| 98 |
+
if not pending:
|
| 99 |
+
print(f"[{condition}] DONE: {len(selected)} ok, 0 failed")
|
| 100 |
+
return
|
| 101 |
+
|
| 102 |
+
gpus = visible_gpus()
|
| 103 |
+
worker_count = min(len(pending), len(gpus) if gpus else 1)
|
| 104 |
+
assignments = gpus[:worker_count] if gpus else [None]
|
| 105 |
+
cpu_count = available_cpu_count()
|
| 106 |
+
cpu_threads = max(1, cpu_count // worker_count)
|
| 107 |
+
print(
|
| 108 |
+
f"[{condition}] starting {worker_count} persistent worker(s); "
|
| 109 |
+
f"GPUs={assignments}; CPU threads/worker={cpu_threads}",
|
| 110 |
+
flush=True,
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
context = mp.get_context("spawn")
|
| 114 |
+
tasks, results = context.Queue(), context.Queue()
|
| 115 |
+
for scene in pending:
|
| 116 |
+
tasks.put(scene)
|
| 117 |
+
for _ in range(worker_count):
|
| 118 |
+
tasks.put(None)
|
| 119 |
+
workers = [
|
| 120 |
+
context.Process(
|
| 121 |
+
target=_worker,
|
| 122 |
+
args=(
|
| 123 |
+
tasks, results, model, results_dir, gpu, cpu_threads, extended,
|
| 124 |
+
reasoning_budget, force_budget,
|
| 125 |
+
),
|
| 126 |
+
)
|
| 127 |
+
for gpu in assignments
|
| 128 |
+
]
|
| 129 |
+
for worker in workers:
|
| 130 |
+
worker.start()
|
| 131 |
+
failed = []
|
| 132 |
+
for finished in range(1, len(pending) + 1):
|
| 133 |
+
scene, ok, detail = results.get()
|
| 134 |
+
if not ok:
|
| 135 |
+
failed.append(scene)
|
| 136 |
+
print(
|
| 137 |
+
f"[{condition} {completed + finished}/{len(selected)}] {scene}: "
|
| 138 |
+
f"{'done' if ok else 'FAILED'}\n{detail}",
|
| 139 |
+
flush=True,
|
| 140 |
+
)
|
| 141 |
+
for worker in workers:
|
| 142 |
+
worker.join()
|
| 143 |
+
print(
|
| 144 |
+
f"[{condition}] DONE: {len(pending) - len(failed)} answered, {completed} skipped, "
|
| 145 |
+
f"{len(failed)} failed"
|
| 146 |
+
)
|
| 147 |
+
if failed:
|
| 148 |
+
raise SystemExit(1)
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def main():
|
| 152 |
+
parser = argparse.ArgumentParser()
|
| 153 |
+
parser.add_argument("scene", nargs="?")
|
| 154 |
+
parser.add_argument(
|
| 155 |
+
"--scenes", help="comma-separated scenes (cannot be combined with positional scene)"
|
| 156 |
+
)
|
| 157 |
+
parser.add_argument("--model", required=True, choices=vlm_models.available_models())
|
| 158 |
+
parser.add_argument("--results-dir", default=None)
|
| 159 |
+
parser.add_argument("--rebuild", action="store_true")
|
| 160 |
+
parser.add_argument(
|
| 161 |
+
"--extended", action="store_true",
|
| 162 |
+
help="use the extended 2048-token protocol instead of the fixed 16-token default",
|
| 163 |
+
)
|
| 164 |
+
parser.add_argument("--reasoning-budget", type=int, default=EXTENDED_MAX_NEW_TOKENS)
|
| 165 |
+
parser.add_argument("--force-budget", type=int, default=MAX_NEW_TOKENS)
|
| 166 |
+
args = parser.parse_args()
|
| 167 |
+
if args.scene and args.scenes:
|
| 168 |
+
parser.error("positional scene and --scenes cannot be used together")
|
| 169 |
+
if args.scenes is not None:
|
| 170 |
+
selected = [scene.strip() for scene in args.scenes.split(",") if scene.strip()]
|
| 171 |
+
if not selected:
|
| 172 |
+
parser.error("--scenes must contain at least one scene")
|
| 173 |
+
selected = list(dict.fromkeys(selected))
|
| 174 |
+
else:
|
| 175 |
+
selected = [args.scene] if args.scene else scenes()
|
| 176 |
+
if args.reasoning_budget < 1:
|
| 177 |
+
parser.error("--reasoning-budget must be positive")
|
| 178 |
+
if args.force_budget < 1:
|
| 179 |
+
parser.error("--force-budget must be positive")
|
| 180 |
+
launch(
|
| 181 |
+
args.model, selected, results_dir=args.results_dir, rebuild=args.rebuild,
|
| 182 |
+
extended=args.extended, reasoning_budget=args.reasoning_budget,
|
| 183 |
+
force_budget=args.force_budget,
|
| 184 |
+
)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
if __name__ == "__main__":
|
| 188 |
+
main()
|
harness/E/prompts.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""VSI-Bench prompt construction with NO scene input at all -- the blind floor.
|
| 2 |
+
|
| 3 |
+
Reuses harness.A.prompts's exact question-type split and post-prompts verbatim. There
|
| 4 |
+
is deliberately NO context line: there are no frames and no spatial code to describe,
|
| 5 |
+
and inventing one ("answer from your general knowledge") would itself be an
|
| 6 |
+
uncontrolled prompt manipulation. The prompt is exactly the question (and options)
|
| 7 |
+
plus the same post-prompt every other harness uses for that question type.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
from harness.A.prompts import MCA_POST_PROMPT, MCA_QUESTION_TYPES, NA_POST_PROMPT, NA_QUESTION_TYPES
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def build_prompt(question_type, question, options=None):
|
| 16 |
+
"""Return the blind text prompt: the question, options (for MCA types), and the
|
| 17 |
+
same VSI-Bench post-prompt harness.A uses for the same question_type."""
|
| 18 |
+
if question_type in NA_QUESTION_TYPES:
|
| 19 |
+
return question + "\n" + NA_POST_PROMPT
|
| 20 |
+
if question_type in MCA_QUESTION_TYPES:
|
| 21 |
+
if not options:
|
| 22 |
+
raise ValueError(f"question_type {question_type!r} requires options")
|
| 23 |
+
options_block = "Options:\n" + "\n".join(options)
|
| 24 |
+
return "\n".join([question, options_block, MCA_POST_PROMPT])
|
| 25 |
+
raise ValueError(
|
| 26 |
+
f"unknown question_type {question_type!r}; "
|
| 27 |
+
f"expected one of {MCA_QUESTION_TYPES + NA_QUESTION_TYPES}"
|
| 28 |
+
)
|
harness/E/sweep.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Sweep any set of models over the blind floor (question-only, no scene input).
|
| 2 |
+
|
| 3 |
+
Every model in the sweep is run through ``harness.E.launch.launch`` in turn, so each
|
| 4 |
+
model individually saturates every visible GPU before the next one starts. The only
|
| 5 |
+
other axis is the generation protocol (--extended), matching harness.A's flag.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
import argparse
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
import sys
|
| 13 |
+
|
| 14 |
+
HERE = Path(__file__).resolve().parent
|
| 15 |
+
WORKSPACE_ROOT = HERE.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 models as vlm_models # noqa: E402
|
| 20 |
+
from harness.A.sweep import _parse_csv_choice # noqa: E402
|
| 21 |
+
from harness.E import launch as harness_launch # noqa: E402
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def sweep(models, selected_scenes, results_dir=None, rebuild=False, extended=False):
|
| 25 |
+
"""Run every model across all visible GPUs."""
|
| 26 |
+
protocol = "extended" if extended else "base"
|
| 27 |
+
for index, model in enumerate(models, start=1):
|
| 28 |
+
print(f"=== sweep {index}/{len(models)}: {model}/{protocol} ===", flush=True)
|
| 29 |
+
harness_launch.launch(
|
| 30 |
+
model, selected_scenes, results_dir=results_dir, rebuild=rebuild,
|
| 31 |
+
extended=extended,
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def main():
|
| 36 |
+
parser = argparse.ArgumentParser()
|
| 37 |
+
parser.add_argument("scene", nargs="?")
|
| 38 |
+
parser.add_argument(
|
| 39 |
+
"--scenes", help="comma-separated scenes (cannot be combined with positional scene)"
|
| 40 |
+
)
|
| 41 |
+
parser.add_argument(
|
| 42 |
+
"--models", required=True,
|
| 43 |
+
help=f"comma-separated models (or 'all'); one of {vlm_models.available_models()}",
|
| 44 |
+
)
|
| 45 |
+
parser.add_argument("--results-dir", default=None)
|
| 46 |
+
parser.add_argument("--rebuild", action="store_true")
|
| 47 |
+
parser.add_argument(
|
| 48 |
+
"--extended", action="store_true",
|
| 49 |
+
help="run the whole sweep under the extended 2048-token protocol instead of "
|
| 50 |
+
"the fixed 16-token default",
|
| 51 |
+
)
|
| 52 |
+
args = parser.parse_args()
|
| 53 |
+
if args.scene and args.scenes:
|
| 54 |
+
parser.error("positional scene and --scenes cannot be used together")
|
| 55 |
+
|
| 56 |
+
try:
|
| 57 |
+
models = _parse_csv_choice(args.models, vlm_models.available_models(), "--models")
|
| 58 |
+
except ValueError as exc:
|
| 59 |
+
parser.error(str(exc))
|
| 60 |
+
|
| 61 |
+
if args.scenes is not None:
|
| 62 |
+
selected = [scene.strip() for scene in args.scenes.split(",") if scene.strip()]
|
| 63 |
+
if not selected:
|
| 64 |
+
parser.error("--scenes must contain at least one scene")
|
| 65 |
+
selected = list(dict.fromkeys(selected))
|
| 66 |
+
else:
|
| 67 |
+
from harness.A.launch import scenes
|
| 68 |
+
|
| 69 |
+
selected = [args.scene] if args.scene else scenes()
|
| 70 |
+
|
| 71 |
+
sweep(
|
| 72 |
+
models, selected, results_dir=args.results_dir, rebuild=args.rebuild,
|
| 73 |
+
extended=args.extended,
|
| 74 |
+
)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
if __name__ == "__main__":
|
| 78 |
+
main()
|
tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc
CHANGED
|
Binary files a/tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc and b/tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc differ
|
|
|
tests/test_A/__pycache__/test_run.cpython-311-pytest-8.3.5.pyc.323807
ADDED
|
File without changes
|
tests/test_A/test_run.py
CHANGED
|
@@ -41,6 +41,7 @@ _FAKE_ROW = {
|
|
| 41 |
}
|
| 42 |
|
| 43 |
_FAKE_FRAME_INFO = {
|
|
|
|
| 44 |
"video_path": "/root/data/VSI-Bench/scannet/scene0001_00.mp4",
|
| 45 |
"frame_timestamps": [0.0, 1.0, 2.0],
|
| 46 |
"frame_indices": [0, 30, 60],
|
|
@@ -100,12 +101,18 @@ def test_scalar_score_rejects_unknown_question_type():
|
|
| 100 |
|
| 101 |
|
| 102 |
def test_results_dir_for_matches_established_dimension_nesting():
|
| 103 |
-
root = harness_run.results_dir_for("qwen3.5-4b", "selective", 32)
|
| 104 |
-
assert root == A.RESULTS_DIR / "qwen3.5-4b" / "selective" / "32"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
|
| 107 |
def test_results_dir_for_honors_explicit_override(tmp_path):
|
| 108 |
-
assert harness_run.results_dir_for("qwen3.5-4b", "uniform", 16, tmp_path) == tmp_path
|
| 109 |
|
| 110 |
|
| 111 |
def test_build_record_preserves_every_field_untruncated():
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
_FAKE_FRAME_INFO = {
|
| 44 |
+
"protocol": "base",
|
| 45 |
"video_path": "/root/data/VSI-Bench/scannet/scene0001_00.mp4",
|
| 46 |
"frame_timestamps": [0.0, 1.0, 2.0],
|
| 47 |
"frame_indices": [0, 30, 60],
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
def test_results_dir_for_matches_established_dimension_nesting():
|
| 104 |
+
root = harness_run.results_dir_for("qwen3.5-4b", "base", "selective", 32)
|
| 105 |
+
assert root == A.RESULTS_DIR / "qwen3.5-4b" / "base" / "selective" / "32"
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def test_results_dir_for_isolates_the_two_protocols():
|
| 109 |
+
base = harness_run.results_dir_for("qwen3.5-4b", "base", "selective", 32)
|
| 110 |
+
extended = harness_run.results_dir_for("qwen3.5-4b", "extended", "selective", 32)
|
| 111 |
+
assert base != extended
|
| 112 |
|
| 113 |
|
| 114 |
def test_results_dir_for_honors_explicit_override(tmp_path):
|
| 115 |
+
assert harness_run.results_dir_for("qwen3.5-4b", "base", "uniform", 16, tmp_path) == tmp_path
|
| 116 |
|
| 117 |
|
| 118 |
def test_build_record_preserves_every_field_untruncated():
|
tests/test_symbolic/__pycache__/test_solver.cpython-311-pytest-8.3.5.pyc
CHANGED
|
Binary files a/tests/test_symbolic/__pycache__/test_solver.cpython-311-pytest-8.3.5.pyc and b/tests/test_symbolic/__pycache__/test_solver.cpython-311-pytest-8.3.5.pyc differ
|
|
|
tests/test_symbolic/test_solver.py
CHANGED
|
@@ -121,3 +121,58 @@ def test_dispatch_returns_none_for_unknown_or_missing_data(spatial_code):
|
|
| 121 |
)
|
| 122 |
assert solver.pairwise_swap_distance(["a", "b", "c"], ["b", "a", "c"]) == 1
|
| 123 |
assert solver.pairwise_swap_distance(["a"], ["b"]) is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
)
|
| 122 |
assert solver.pairwise_swap_distance(["a", "b", "c"], ["b", "a", "c"]) == 1
|
| 123 |
assert solver.pairwise_swap_distance(["a"], ["b"]) is None
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def test_answer_snapshots_operation_counts_per_question():
|
| 127 |
+
"""H25 instrumentation: LAST_ANSWER_OPS reflects only the LAST question, and a
|
| 128 |
+
multi-step distance question costs strictly more operations than a pure count
|
| 129 |
+
lookup. Counting must never change any answer (every other test in this file
|
| 130 |
+
still passing is the guarantee)."""
|
| 131 |
+
from symbolic import adapters, solver
|
| 132 |
+
|
| 133 |
+
code = adapters.adapt_spatial_code(
|
| 134 |
+
{
|
| 135 |
+
"spatial code schema": {},
|
| 136 |
+
"objects": {
|
| 137 |
+
"chair": [
|
| 138 |
+
{
|
| 139 |
+
"3D oriented bounding box": {
|
| 140 |
+
"3D oriented bounding box center coordinates": [0.0, 0.0, 0.5],
|
| 141 |
+
"3D oriented bounding box dimensions": [1.0, 1.0, 1.0],
|
| 142 |
+
"3D oriented bounding box orientation unit vectors": [
|
| 143 |
+
[1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
|
| 144 |
+
],
|
| 145 |
+
},
|
| 146 |
+
"first visible time": 0.0,
|
| 147 |
+
}
|
| 148 |
+
],
|
| 149 |
+
"table": [
|
| 150 |
+
{
|
| 151 |
+
"3D oriented bounding box": {
|
| 152 |
+
"3D oriented bounding box center coordinates": [3.0, 0.0, 0.5],
|
| 153 |
+
"3D oriented bounding box dimensions": [2.0, 1.0, 1.0],
|
| 154 |
+
"3D oriented bounding box orientation unit vectors": [
|
| 155 |
+
[1.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, -1.0, 0.0],
|
| 156 |
+
],
|
| 157 |
+
},
|
| 158 |
+
"first visible time": 1.0,
|
| 159 |
+
}
|
| 160 |
+
],
|
| 161 |
+
},
|
| 162 |
+
"room": {"floor boundary polygons": []},
|
| 163 |
+
}
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
solver.answer("object_counting", "How many chair(s) are in this room?", None, code)
|
| 167 |
+
counting_ops = dict(solver.LAST_ANSWER_OPS)
|
| 168 |
+
assert counting_ops["total"] >= 1
|
| 169 |
+
|
| 170 |
+
solver.answer(
|
| 171 |
+
"object_abs_distance",
|
| 172 |
+
"Measuring from the closest point of each object, what is the direct distance "
|
| 173 |
+
"between the chair and the table (in meters)?",
|
| 174 |
+
None,
|
| 175 |
+
code,
|
| 176 |
+
)
|
| 177 |
+
distance_ops = dict(solver.LAST_ANSWER_OPS)
|
| 178 |
+
assert distance_ops["total"] > counting_ops["total"]
|