File size: 25,130 Bytes
dd7bc9c
 
 
0c06379
dd7bc9c
0c06379
 
 
dd7bc9c
0c06379
 
 
 
 
 
 
 
 
 
 
dd7bc9c
 
0c06379
dd7bc9c
3088e15
dd7bc9c
0c06379
 
 
 
 
dd7bc9c
0c06379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42eaaea
3088e15
42eaaea
 
3088e15
 
 
 
 
0c06379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd7bc9c
0c06379
dd7bc9c
0c06379
dd7bc9c
0c06379
 
 
 
 
 
 
 
 
 
 
 
dd7bc9c
 
0c06379
dd7bc9c
 
0c06379
dd7bc9c
0c06379
dd7bc9c
0c06379
dd7bc9c
0c06379
dd7bc9c
0c06379
 
 
 
dd7bc9c
0c06379
 
 
 
 
584d7b1
3088e15
584d7b1
3088e15
584d7b1
3088e15
42eaaea
3088e15
 
42eaaea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1666b69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9b136d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
---
license: mit
language: en
size_categories: 1K<n<10K
task_categories:
  - question-answering
  - video-classification
  - multiple-choice
tags:
  - physics
  - pendulum
  - causal-reasoning
  - causal-interventions
  - clevrer
  - clevrer-style
  - world-model
  - cjepa
  - video-qa
  - vqa
  - synthetic
---

# Pendulum C-JEPA 3K + Causal Interventions (`intervened/`)

Combined repository uniting the full **3,000-video Pendulum C-JEPA 3K parental dataset** at the repository root (`pendulum-cjepa-3k-new`) with the **240-video causal intervention subset** under [`intervened/`](intervened/) (`light_shift` and `torque_push` interventions at frame 96 / `t = 8.0 s`, plus v2 intervention-focused CLEVRER-style QA), and the pretrained Videosaur DINOv2 model under [`model/`](model/).

| subset | path | videos | questions | WebDataset shards | description |
| --- | --- | --- | --- | --- | --- |
| **Parental `train`** | root (`videos/train/`, `timeseries/`, `questions/questions_train.json`, `wds/train/`) | 2,400 (`video_00000`–`video_02399`) | 19,200 (8 / video) | 19 shards (`pendulum-train-000000.tar`..`000018.tar`) | In-distribution nonlinear physical pendulum |
| **Parental `val` (OOD)** | root (`videos/val/`, `timeseries/`, `questions/questions_val.json`, `wds/val/`) | 600 (`video_10000`–`video_10599`, 6 regimes × 100) | 4,800 (8 / video) | 5 shards (`pendulum-val-000000.tar`..`000004.tar`) | Out-of-distribution physics validation regimes |
| **Intervened subset** | [`intervened/`](intervened/) (`intervened/videos/train/`, `intervened/timeseries/`, `intervened/questions/questions_train.json`, `intervened/wds/train/`) | 240 (`video_00000, video_00010, …, video_02390`) | 3,360 (14 / video, v2) | 2 shards (`pendulum-train-000000.tar`..`000001.tar`) | Frame-96 (`t = 8.0 s`) `light_shift` (120) & `torque_push` (120) interventions matched to parental `train` IDs |

---

## Repository Layout

```
.
├── videos/
│   ├── train/video_00000.mp4 ... video_02399.mp4   # 2,400 parental train clips
│   └── val/video_10000.mp4 ... video_10599.mp4     # 600 parental OOD val clips
├── timeseries/video_XXXXX.csv                      # 3,000 frame-aligned label CSVs
├── questions/
│   ├── questions_train.json                        # 19,200 parental train questions
│   ├── questions_val.json                          # 4,800 parental OOD val questions
│   └── taxonomy.json                               # question-type registry
├── wds/
│   ├── train/pendulum-train-000000.tar ... 000018.tar  # 19 train WebDataset shards (128/shard)
│   └── val/pendulum-val-000000.tar ... 000004.tar      # 5 val WebDataset shards (128/shard)
├── model/                                          # Videosaur DINOv2 model checkpoints, logs & extracted slots
│   └── pendulum-videosaur-20261022-194905/
│       ├── extraction/
│       │   └── pendulum_videosaur_4slots_step=100000.pkl  # Extracted 4-slot embeddings (train + val)
│       └── videosaur_pendulum/20261022-194905_pendulum_dinov2/
│           ├── checkpoints/                        # step=34000.ckpt, step=100000.ckpt
│           ├── metrics/                            # version_1/metrics.csv, version_2/metrics.csv
│           ├── tb/                                 # TensorBoard event logs & hparams.yaml
│           └── settings.yaml                       # training configuration
├── index.csv                                       # per-video params, split, regime (3,000 rows)
├── metadata.json                                   # parental simulation & dataset metadata
├── sample_sheet.png                                # parental sample overview
├── README_original.md                              # verbatim parental dataset README
├── scripts/                                        # generator, QA, wds/cjepa prep, verification scripts
│   ├── pendulum_gen.py
│   ├── questions.py
│   ├── run_generate.py
│   ├── verify_dataset.py
│   ├── audit_answers.py
│   ├── make_preview.py
│   ├── prepare_cjepa_root.sh
│   └── upload_to_hf.py
└── intervened/                                     # 240-video causal intervention subset
    ├── videos/train/video_XXXXX.mp4                # 240 intervened videos (every 10th train ID)
    ├── timeseries/video_XXXXX.csv                  # 240 intervened frame-aligned CSVs
    ├── questions/
    │   ├── questions_train.json                    # 3,360 v2 questions (14/video incl. 6 intervention Qs)
    │   └── taxonomy.json                           # extended taxonomy with v2 intervention templates
    ├── wds/train/pendulum-train-000000.tar .. 01   # 2 WebDataset shards (128 + 112 videos)
    ├── index_intervention.csv                      # 240 rows: original params + intervention_type/cut_frame/params
    ├── intervention_log.json                       # per-video intervention details + post-cut stats
    ├── preview_before_after.mp4                    # side-by-side original vs intervened preview
    ├── contact_sheet.png                           # static pre/post-cut comparison grid
    ├── README.md                                   # original shift-2 v2 dataset card
    └── README_intervention.md                      # full intervention reproduction notes
```

*(Note: Paths inside `index.csv` and `questions/*.json` at root are relative to the repository root, while paths inside `intervened/index_intervention.csv` and `intervened/questions/questions_train.json` are relative to `intervened/` so either root can be mounted directly as a drop-in dataset directory.)*

---

## Part 1: Parental Dataset (`pendulum-cjepa-3k-new` at Root)

**3,000 silent H.264 MP4s of a nonlinear physical pendulum** (160 frames @ 12 fps = 13.33 s, 196×196 px), with frame-aligned CSV labels and **24,000 CLEVRER-style questions** (descriptive / explanatory / predictive / counterfactual) derived from ground-truth 28 s RK4 simulations.

### OOD Validation Regimes (`videos/val/`)

| regime | what changes vs train | why it is a causal test |
| --- | --- | --- |
| `val_high_damp` | γ ∈ U(0.55, 0.90) s⁻¹ (train: 0.15–0.50) | envelope time-constant τ=2/γ as low as 2.2 s, shorter than anything seen |
| `val_low_damp` | γ ∈ U(0, 0.08) s⁻¹ | near-conservative dynamics; amplitude/energy almost constant |
| `val_large_angle` | θ₀ = ±(45–80)° (train: ±15–40°) | strong nonlinearity: period elongated up to ~30%, visibly non-sinusoidal |
| `val_gravity` | g ∈ {1.62 Moon, 3.71 Mars, 24.79 Jupiter} m/s² | period shifts by up to 2.5× both directions |
| `val_quad_damping` | drag = −β·ω·\|ω\|, β ∈ U(0.10, 0.35); γ = 0 | **new force law**: amplitude envelope decays ~linearly, not exponentially |
| `val_driven` | periodic torque A·cos(2πf t+φ), A ∈ U(0.35, 1.0) rad/s², f ∈ U(0.35, 0.65) Hz | **new causal mechanism**: beats / resonant growth around ~0.5 Hz natural frequency |

### Physics

```
theta'' = -(g/L)·sin(theta) - gamma·theta' - beta·theta'·|theta'| + A·cos(2π f_d t + φ)
```

RK4 at `fps × 8 = 96 Hz`. Train: `g=9.81`, `L=1.0`, `γ ∈ U(0.15, 0.50)`, `β=0`, `A=0`, `θ₀ = ±U(15, 40)°`, `ω₀ = U(−0.2, 0.2)`, light mean `U(70, 110)°`, light amp `U(0, 15)°`, light freq `U(0.04, 0.12)` Hz, random phase. Frame `n` ↔ CSV row `frame=n` ↔ `time_s = n/12`.

---

## Part 2: Causal Intervention Subset (`intervened/`)

For a deterministic subset of **240 parental train videos** (every 10th: `video_00000, video_00010, …, video_02390`), each video was re-simulated and re-rendered with `scripts/pendulum_gen.py` with an intervention applied at **frame 96 (`t = 8.0 s`)** of the 13.3 s clip. Frames 0–95 match the parental videos (`videos/train/video_XXXXX.mp4`) up to pure H.264 encoder noise, allowing direct paired comparison between factual (`videos/train/video_XXXXX.mp4`) and intervened (`intervened/videos/train/video_XXXXX.mp4`) rollouts.

| type | count | what changes | what stays the same |
| --- | --- | --- | --- |
| **`light_shift`** | 120 videos | At frame 96 the light source trajectory smoothly switches (6-frame smoothstep ramp) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). | Pendulum physics byte-identical (`theta_deg` diff = 0.0). |
| **`torque_push`** | 120 videos | External torque impulse `A·exp(−(t−t_push)²/2σ²)` (`σ = 0.15 s`, `A ∈ [2.0, 4.5] rad/s²`, gated for `t ≥ 8.0 s`) alters the bob's motion post-push (`Δθ` up to ~6°, `Δω` up to ~0.34 rad/s). | Light trajectory unchanged. |

### Intervened Questions v2 (`intervened/questions/questions_train.json`)

- **3,360 questions total** (14 per video): 1,920 regenerated standard CLEVRER-style questions + **1,440 intervention-focused questions** (6 per video) probing what changed at frame 96 (`t = 8 s`), which quantities remain invariant, causal mechanisms (`light_shift` vs `torque_push`), and counterfactuals without the intervention.

---

## Part 3: Pretrained Model (`model/`)

Trained **Videosaur** (`dinov2`) object-centric video model on the pendulum dataset (`model/pendulum-videosaur-20261022-194905/videosaur_pendulum/20261022-194905_pendulum_dinov2/`):

- **Checkpoints**: `checkpoints/step=34000.ckpt`, `checkpoints/step=100000.ckpt`
- **Extracted Slots**: `extraction/pendulum_videosaur_4slots_step=100000.pkl` (4-slot embeddings for parental `train` + `val`)
- **Config**: `settings.yaml`
- **Logs**: `metrics/version_1/metrics.csv`, `metrics/version_2/metrics.csv`, and TensorBoard event logs under `tb/`

---

## Part 4: CLEVRER-style Descriptive Questions (v2)

Drop-in replacement for the **descriptive** questions in `jimchen2/temp-jimchen2-pendulum-shift`, covering both the parental dataset (`questions/`) and the causal-intervention subset (`intervened/questions/`). Explanatory / predictive / counterfactual questions are **untouched** — copied byte-identical from the shipped files.

### What changed

The shipped descriptive questions had three defects:

1. **38.8% were multiple choice** despite `info.answer_convention` declaring descriptive = free-form string.
2. **Four phrasings had exactly one possible answer dataset-wide**, including both counting questions (always `"13"`, because `length_m` and `gravity_m_s2` are pinned for all 2,400 train videos).
3. **No `question_subtype` / `question_family_index`**, so CLEVRER tooling cannot group or analyse them.

Result: a model that never watched a video scored **65.6%** on train descriptive.

### Result

| split | n | no-video baseline before | after | families | phrasings |
| --- | --- | --- | --- | --- | --- |
| root/train | 4,800 | 65.6% | **44.3%** | 12 | 36 |
| root/val | 1,200 | 64.0% | **43.0%** | 12 | 36 |
| intervened/train | 1,200 | 59.7% | **49.1%** | 14 | 36 |
| **CLEVRER descriptive (reference)** | 54,990 | — | **41.6%** | — | 7,475 |

### New schema

```json
{ "question_type": "descriptive",
  "question_subtype": "query_light",
  "question_family_index": 9,
  "question_family": "query_light_travel",
  "question": "How far does the orange light source travel during the video?",
  "answer": "medium",
  "question_id": 0 }
```

No `choices`. Every answer is one token from `answer_vocab.json` (44 tokens). Each family carries 3 paraphrases, mirroring CLEVRER's multiple text templates per question family.

### Families

Sub-types follow CLEVRER's (`count` / `exist` / `query_*`):

| family | subtype | answers |
| --- | --- | --- |
| `count_swing_wide` | count | `0`–`15` |
| `count_swing_very_wide` | count | `0`–`13` |
| `count_turning_points` | count | `0`–`22` |
| `query_release_side` | query_side | left / right |
| `query_initial_direction` | query_direction | left / right / still |
| `query_release_amplitude` | query_amplitude | small / medium / large |
| `query_mid_amplitude` | query_amplitude | small / medium / large |
| `query_end_direction` | query_direction | left / right / still |
| `query_end_side` | query_position | left / right |
| `query_light_travel` | query_light | small / medium / large |
| `query_light_direction` | query_direction | left / right |
| `exist_still_swinging` | exist | yes / no |
| `query_intervention_target` | query_type | light / bob *(intervened only)* |
| `query_intervention_invariant` | query_invariant | bob / light *(intervened only)* |
| `query_energy_at_cut` | query_energy | smooth / jumps *(intervened only)* |

#### Dropped

- `q_shadow_direction` — the shadow always moves with the bob. One answer, 652×.
- `q_fastest_point` — the bob is always fastest at the bottom. One answer, 628×.
- `q_bottom_passes` — always `"13"`; the period is fixed because `length_m = 1.0` and `g = 9.81` for every train video. Replaced by `count_swing_wide` / `count_swing_very_wide`, which count swings above an amplitude threshold and therefore **do** vary with damping (13–15 distinct answers).
- `query_energy_end` — every train video loses 86–99.9% of its energy (γ ∈ 0.15–0.50), so the answer is near-constant.

### How it was built

No videos were downloaded or re-rendered. Re-simulating from `index.csv` with the repo's own `pendulum_gen.simulate` reproduces the shipped timeseries CSVs **bit-exactly** (max abs diff `0.0` on `theta_rad`, `theta_deg`, `omega_rad_s`, `light_angle_deg`, `energy_j_per_kg`, `bob_x_world`, `shadow_left_world`, `mid`), so parental facts are exact. For the intervened subset the shipped `intervened/timeseries/*.csv` are used directly, because the `torque_push` impulse could not be reproduced to better than 0.30° from `intervention_params` alone.

Intervention facts are computed on frames **0–95 only** (pre-intervention), and `exist_still_swinging` is gated off for that window — over 8 s the bob is always still swinging, which would make the answer constant.

Answers are balanced by a greedy sampler that prefers the currently least-represented `(family, answer)` pair across the split. Thresholds that produce a binary answer are set at the empirical train median (`OMEGA_STILL = 0.196` rad/s) rather than a round number, which is what makes `exist_still_swinging` exactly 50/50.

A `MARGIN_DEG = 0.25` / `MARGIN_OMEGA = 0.01` gate skips any question whose deciding value sits within the margin of a threshold; without it `video_10595` flipped `count_swing_very_wide` between 4 and 5 at 96 vs 192 Hz.

### Files

```
questions_v2.py            family definitions + balanced sampler
regenerate_descriptive.py  writes out/**
verify_descriptive.py      schema / vocab / balance gates
crosscheck_answers.py      answers vs independent ground truth
resolution_check.py        answers vs 2x integration resolution
balance_report.json        per-family distribution, per split
```

Reproduce:

```bash
python3 regenerate_descriptive.py
python3 verify_descriptive.py
python3 crosscheck_answers.py
python3 resolution_check.py
```

### Verification

| check | result |
| --- | --- |
| question count per video unchanged (8 / 8 / 14) | PASS |
| non-descriptive questions byte-identical | PASS, 0 videos differ |
| no descriptive question has `choices` | PASS (7,200) |
| all answers single-word and in vocabulary | PASS |
| all have `question_subtype` + `question_family_index` | PASS |
| no family 100% guessable | PASS (worst: 54.7%) |
| answers vs independent recomputation from CSVs | 0 mismatches / 1,280 |
| answers vs 2× integration resolution (192 Hz) | 0 changed / 7,200 |

The independent recomputation deliberately does not import `questions_v2`; it derives velocity by finite-differencing the angle series rather than using the integrated `omega_rad_s` column, so agreement is real evidence. It initially disagreed on 69 answers, all off-by-one counts — the checker was wrong, not the generator: a bob released at max displacement with a small outward velocity turns around *inside the first frame interval* (e.g. `video_00150`, turn at frame 0.2, amplitude 33.32°), which a pure-difference detector cannot see.

### Known limitation

The counting questions still cannot reach CLEVRER's answer diversity, because `length_m` and `gravity_m_s2` are constant across train. Fixing that needs a re-render: one line in `pendulum_gen.sample_config` (`cfg.length_m = rng.uniform(0.5, 2.0)` in the `ID` branch) would spread the swing period and therefore every count. Note that `scene_geometry` draws the arm at the constant `DRAW_LENGTH = 8.0` and never reads `length_m`, so the pixels would be unchanged while the labels' `bob_x_m` / `energy_j_per_kg` would acquire an `L` dependence — decide whether to scale `DRAW_LENGTH` too before doing it.

Functional programs (`program` / `my_program`) are still absent. Adding them requires a DSL and executor over pendulum state and is out of scope here.

## Intervention

# Pendulum C-JEPA 3K — Intervention Subset

Data-generating interventions added to **240 videos**
Everything else in the dataset is untouched.

## What was done

For a deterministic subset of 240 train videos (every 10th: `video_00000,
video_00010, … video_02390`), each video was **re-simulated and re-rendered with
the repo's own `pendulum_gen.py`** with an intervention applied at
**frame 96 (t = 8.0 s)** of the 13.3 s clip. Frames 0–95 are identical to the
originals (verified: max pixel diff ≤ 29, i.e. pure H.264 encoder noise), so the
intervention boundary is clean.

Two intervention types, 120 videos each:

| type | what changes | what stays the same |
|---|---|---|
| **`light_shift`** | At frame 96 the light source trajectory is smoothly switched (smoothstep ramp over 6 frames) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). The sun and its shadow sweep differently for the last ~5 s of the video. | Pendulum physics is byte-identical — theta/omega/energy are unchanged (verified: `theta_deg` diff = 0.0). This is the "light moves differently towards the end" intervention. |
| **`torque_push`** | A genuine physical intervention: an external torque impulse `A·exp(−(t−t_push)²/2σ²)` (σ = 0.15 s, `A ∈ [2.0, 4.5] rad/s²`, hard-gated on for `t ≥ 8.0 s`) is applied to the pendulum. The bob's motion genuinely deviates after the push (verified: Δθ up to ~6°, Δω up to ~0.34 rad/s). | The light trajectory is unchanged. |

Per-video intervention parameters (cut frame, new light params / push amplitude)
are stored in `intervention_log.json` and the `intervention_*` columns of
`index_intervention.csv`. All generated videos passed the original scene
validator (`|θ| ≤ 85°`, sun/bob/shadow inside the world bounds).

## Layout

```
intervened/
├── videos/train/video_XXXXX.mp4       240 intervened videos (same ids as originals)
├── timeseries/video_XXXXX.csv         240 frame-aligned labels, same schema as original
├── index_intervention.csv             240 rows: original index + intervention_type/cut_frame/params
├── intervention_log.json              per-video intervention details + post-cut stats
├── preview_before_after.mp4           side-by-side original vs intervened (4 examples)
└── contact_sheet.png                  static pre/post-cut comparison grid
```

The CSVs keep the original schema (`frame,time_s,theta_rad,…,light_angle_deg,
light_x_world,shadow_left_world,shadow_right_world,shade,mid,…`); for
`light_shift` the light/shadow columns change post-cut while physics columns
stay identical, for `torque_push` the physics columns change post-push.

## Reproduce

```bash
python3 intervene.py        # regenerates everything (skips existing outputs)
python3 make_preview.py     # rebuilds the preview mp4 / contact sheet
```

Selection and intervention parameters are deterministic (`SEED=20261118`,
`EVERY=10`, `CUT_FRAME=96` in `intervene.py`).

## Why this is useful for C-JEPA / Lfuture eval

- `light_shift` is a clean **nuisance-factor intervention**: the observable
  video changes (light + shadow motion) while the pendulum state evolution is
  exactly the same. A model that predicts future slots must capture the
  light→shadow causal link, not just copy the pendulum's dynamics.
- `torque_push` is a **physical intervention**: the future pendulum motion
  genuinely deviates from the non-intervened continuation, so Lfuture on the
  post-push frames measures whether the model predicts the response to an
  external force.
- Because frames 0–95 match the originals exactly, you can train/evaluate on the
  pre-intervention prefix and measure prediction quality on the post-intervention
  suffix directly.


## Interventions

Each of the 240 videos was re-simulated and re-rendered with the source repo's
own `pendulum_gen.py`, with an intervention applied at **frame 96 (t = 8.0 s)**
of the 13.3 s clip. Frames 0–95 are identical to the originals (verified: max
pixel diff ≤ 29, i.e. pure H.264 encoder noise).

| type | what changes | what stays the same |
|---|---|---|
| **`light_shift`** (120 videos) | At frame 96 the light source trajectory is smoothly switched (smoothstep ramp over 6 frames) to a new mean/amplitude/frequency/phase (`Δmean ∈ ±20°`, `amp ∈ [5,30]°`, `f ∈ [0.15,0.40] Hz`). The sun and its shadow sweep differently for the last ~5 s. | Pendulum physics byte-identical (`theta_deg` diff = 0.0). |
| **`torque_push`** (120 videos) | A physical intervention: an external torque impulse `A·exp(−(t−t_push)²/2σ²)` (σ = 0.15 s, `A ∈ [2.0,4.5] rad/s²`) is applied at 8 s; the bob's motion genuinely deviates afterwards (Δθ up to ~6°, Δω up to ~0.34 rad/s). | Light trajectory unchanged. |

All videos passed the original scene validator (`|θ| ≤ 85°`, sun/bob/shadow
inside world bounds).

## Layout

```
videos/train/video_XXXXX.mp4       240 intervened videos (same ids as originals)
timeseries/video_XXXXX.csv         240 frame-aligned labels, same schema as original
questions/questions_train.json     1,920 CLEVRER-style questions (8 per video), regenerated
                                   from the intervened 28 s simulations (same RNG selection
                                   seed as the source: [20261014, index, 777])
questions/taxonomy.json            question-type registry (same as source)
wds/train/pendulum-train-000000.tar  WebDataset shard (128 videos: *.video.mp4 + *.meta.json)
wds/train/pendulum-train-000001.tar  WebDataset shard (112 videos)
index_intervention.csv             240 rows: original index + intervention_type/cut_frame/params
intervention_log.json              per-video intervention details + post-cut stats
README_intervention.md             full documentation + reproduction instructions
preview_before_after.mp4           side-by-side original vs intervened (4 examples)
contact_sheet.png                  static pre/post-cut comparison grid
```

WebDataset shards follow the source format exactly: each tar holds
`video_XXXXX.video.mp4` + `video_XXXXX.meta.json` (`{"split","filename"}`),
128 videos per shard, ordered by video id — drop-in compatible with the
source dataset's wds loader.

CSVs keep the original schema; for `light_shift` the light/shadow columns change
post-cut while physics columns stay identical, for `torque_push` the physics
columns change post-push.

## Use with C-JEPA / VideoSAUR

Run VideoSAUR slot extraction on these videos, then evaluate Lfuture on the
post-cut suffix (frames 96–159). `light_shift` tests prediction of the
light→shadow causal link (nuisance-factor intervention); `torque_push` tests
prediction of the physical response to an external force.

## Reproduce

```bash
python3 intervene.py        # regenerates the intervened set (resumable)
python3 make_preview.py     # rebuilds preview mp4 / contact sheet
```

Selection and parameters are deterministic (`SEED=20261118`, `EVERY=10`,
`CUT_FRAME=96` in `intervene.py`).

## Questions v2 (intervention-focused)

- **3,360 questions total** (14 per video): the original 1,920 plus **1,440 new
  intervention-focused questions** (6 per video).
- New questions ask what changed at **frame 96 / t = 8 s**, which quantities
  stay invariant, why the shadow or bob responds, and what would have happened
  without the `light_shift` or `torque_push`.
- Corrections to the original questions:
  - 19 `light_shift` clips whose “the shadow would settle to one spot” answer
    was wrong — the light keeps sweeping, so the shadow keeps moving.
  - The “shadow always moves with the bob” and “what mainly causes the shadow
    sweep” questions are now explicitly scoped to the first 8 s (before the
    light switch), where that answer is true.
  - The light-invariance counterfactual now says **ONLY** the light changes.
- New question template IDs are recorded in `questions/taxonomy.json`.
The generation script and the v1 backup are kept in the workspace used to
build this copy, not in the dataset itself.