anhtld commited on
Commit
eb7cf88
·
verified ·
1 Parent(s): 78ac1a6

auto-sync 2026-07-02T20:07:13Z workspace

Browse files
workspace/docs/cil_format.md CHANGED
@@ -81,6 +81,24 @@ Learned generator targets:
81
  endpoint, midpoint, gripper, lift, and approach-axis summaries. This is the
82
  first training artifact for V2/V3 CVAE or flow-matching generators in
83
  object-centric spline tangent space.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
  JSONL shards should preserve complete groups. A group may exceed the target shard size, but it
86
  should never be split across shards unless an explicit future streaming mode opts into that tradeoff.
 
81
  endpoint, midpoint, gripper, lift, and approach-axis summaries. This is the
82
  first training artifact for V2/V3 CVAE or flow-matching generators in
83
  object-centric spline tangent space.
84
+ - `scripts/eval_positive_tangent_memory.py` is a leakage-checked diagnostic
85
+ baseline: train-only positive tangents become diverse task-level prototypes,
86
+ and heldout groups report PTR proxy, negative-near rate, and whether the
87
+ nearest proposal is closer to a hidden positive than to hidden negatives. It
88
+ should be reported as support evidence, not as the final learned generator.
89
+ - `scripts/train_positive_tangent_cvae.py` trains a first raw-action CVAE over
90
+ train-only positive tangents. The companion
91
+ `scripts/summarize_positive_tangent_cvae_sweep.py` ranks temperature/beta
92
+ sweeps by heldout PTR and negative-near rates. This baseline is useful for
93
+ falsifying raw action-chunk likelihood as the final geometry.
94
+ - `scripts/train_positive_tangent_spline_cvae.py` trains a keyframe-spline CVAE
95
+ over start/midpoint/endpoint residual codes and decodes samples back into
96
+ full action chunks before evaluation. This is the first chart-geometry
97
+ baseline and a bridge toward object-centric flow matching.
98
+ - `scripts/train_positive_tangent_spline_flow.py` trains conditional flow
99
+ matching in the same keyframe tangent space. Current results should be read
100
+ as a falsification of unguided density flow: useful as a stepping stone, but
101
+ not the final utility-guided atlas generator.
102
 
103
  JSONL shards should preserve complete groups. A group may exceed the target shard size, but it
104
  should never be split across shards unless an explicit future streaming mode opts into that tradeoff.
workspace/dovla_cil/generation/tangent_cvae.py ADDED
@@ -0,0 +1,653 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import math
5
+ from collections import Counter, defaultdict
6
+ from collections.abc import Sequence
7
+ from dataclasses import asdict, dataclass
8
+ from typing import Any
9
+
10
+ from dovla_cil.generation.tangent_memory import TangentExample
11
+
12
+ try:
13
+ import torch
14
+ from torch import nn
15
+ from torch.utils.data import DataLoader, TensorDataset
16
+ except ImportError: # pragma: no cover - login shells may not have torch
17
+ torch = None
18
+ nn = None
19
+ DataLoader = None
20
+ TensorDataset = None
21
+
22
+
23
+ @dataclass(frozen=True)
24
+ class TangentCVAEConfig:
25
+ obs_dim: int = 96
26
+ text_dim: int = 64
27
+ hidden_dim: int = 256
28
+ latent_dim: int = 24
29
+ batch_size: int = 128
30
+ epochs: int = 300
31
+ learning_rate: float = 1.0e-3
32
+ beta: float = 0.02
33
+ val_fraction: float = 0.2
34
+ seed: int = 0
35
+ diversity_temperature: float = 1.0
36
+
37
+ def __post_init__(self) -> None:
38
+ if self.obs_dim <= 0:
39
+ raise ValueError("obs_dim must be positive")
40
+ if self.text_dim <= 0:
41
+ raise ValueError("text_dim must be positive")
42
+ if self.hidden_dim <= 0:
43
+ raise ValueError("hidden_dim must be positive")
44
+ if self.latent_dim <= 0:
45
+ raise ValueError("latent_dim must be positive")
46
+ if self.batch_size <= 0:
47
+ raise ValueError("batch_size must be positive")
48
+ if self.epochs <= 0:
49
+ raise ValueError("epochs must be positive")
50
+ if self.learning_rate <= 0:
51
+ raise ValueError("learning_rate must be positive")
52
+ if self.beta < 0:
53
+ raise ValueError("beta must be non-negative")
54
+ if not 0.0 < self.val_fraction < 1.0:
55
+ raise ValueError("val_fraction must be in (0, 1)")
56
+ if self.diversity_temperature <= 0:
57
+ raise ValueError("diversity_temperature must be positive")
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class TangentCVAERow:
62
+ example: TangentExample
63
+ condition: list[float]
64
+ delta: list[float]
65
+
66
+
67
+ if nn is not None:
68
+
69
+ class PositiveTangentCVAE(nn.Module):
70
+ def __init__(
71
+ self,
72
+ *,
73
+ condition_dim: int,
74
+ action_dim: int,
75
+ hidden_dim: int,
76
+ latent_dim: int,
77
+ ) -> None:
78
+ super().__init__()
79
+ self.condition_dim = int(condition_dim)
80
+ self.action_dim = int(action_dim)
81
+ self.latent_dim = int(latent_dim)
82
+ self.encoder = nn.Sequential(
83
+ nn.Linear(self.condition_dim + self.action_dim, hidden_dim),
84
+ nn.LayerNorm(hidden_dim),
85
+ nn.GELU(),
86
+ nn.Linear(hidden_dim, hidden_dim),
87
+ nn.GELU(),
88
+ )
89
+ self.mu = nn.Linear(hidden_dim, self.latent_dim)
90
+ self.logvar = nn.Linear(hidden_dim, self.latent_dim)
91
+ self.decoder = nn.Sequential(
92
+ nn.Linear(self.condition_dim + self.latent_dim, hidden_dim),
93
+ nn.LayerNorm(hidden_dim),
94
+ nn.GELU(),
95
+ nn.Linear(hidden_dim, hidden_dim),
96
+ nn.GELU(),
97
+ nn.Linear(hidden_dim, self.action_dim),
98
+ )
99
+
100
+ def encode(self, condition, delta):
101
+ hidden = self.encoder(torch.cat([condition, delta], dim=-1))
102
+ return self.mu(hidden), self.logvar(hidden).clamp(min=-8.0, max=8.0)
103
+
104
+ def reparameterize(self, mu, logvar):
105
+ std = torch.exp(0.5 * logvar)
106
+ return mu + torch.randn_like(std) * std
107
+
108
+ def decode(self, condition, latent):
109
+ return self.decoder(torch.cat([condition, latent], dim=-1))
110
+
111
+ def forward(self, condition, delta):
112
+ mu, logvar = self.encode(condition, delta)
113
+ latent = self.reparameterize(mu, logvar)
114
+ return self.decode(condition, latent), mu, logvar
115
+
116
+ else: # pragma: no cover - exercised only when torch is absent
117
+ PositiveTangentCVAE = None
118
+
119
+
120
+ def build_tangent_cvae_rows(
121
+ targets: Sequence[dict[str, Any]],
122
+ *,
123
+ obs_dim: int = 96,
124
+ text_dim: int = 64,
125
+ task_ids: Sequence[str] | None = None,
126
+ ) -> tuple[list[TangentCVAERow], list[str], int]:
127
+ tasks = (
128
+ sorted({str(item.get("task_id", "unknown")) for item in targets})
129
+ if task_ids is None
130
+ else [str(task_id) for task_id in task_ids]
131
+ )
132
+ task_to_index = {task_id: index for index, task_id in enumerate(tasks)}
133
+ action_dim = 0
134
+ rows: list[TangentCVAERow] = []
135
+ for item in targets:
136
+ delta_action = item.get("delta_action", [])
137
+ if not _is_numeric_matrix(delta_action):
138
+ continue
139
+ flat_delta = [float(value) for row in delta_action for value in row]
140
+ action_dim = max(action_dim, len(flat_delta))
141
+ example = TangentExample(
142
+ group_id=str(item["group_id"]),
143
+ task_id=str(item.get("task_id", "unknown")),
144
+ candidate_type=str(item.get("candidate_type", "unknown")),
145
+ tangent_label=str(item.get("tangent_label", "unknown")),
146
+ delta_utility=float(item.get("delta_utility", 0.0)),
147
+ delta_action=[[float(value) for value in row] for row in delta_action],
148
+ )
149
+ rows.append(
150
+ TangentCVAERow(
151
+ example=example,
152
+ condition=condition_vector(
153
+ item,
154
+ task_to_index=task_to_index,
155
+ obs_dim=obs_dim,
156
+ text_dim=text_dim,
157
+ ),
158
+ delta=flat_delta,
159
+ )
160
+ )
161
+ return rows, tasks, action_dim
162
+
163
+
164
+ def condition_vector(
165
+ item: dict[str, Any],
166
+ *,
167
+ task_to_index: dict[str, int],
168
+ obs_dim: int,
169
+ text_dim: int,
170
+ ) -> list[float]:
171
+ observation = item.get("observation_inline") or {}
172
+ obs_values = observation.get("features") if isinstance(observation, dict) else None
173
+ obs = _pad_or_truncate(
174
+ [
175
+ float(value)
176
+ for value in (obs_values or [])
177
+ if isinstance(value, (int, float)) and math.isfinite(float(value))
178
+ ],
179
+ obs_dim,
180
+ )
181
+ text = hash_bow(str(item.get("instruction", "")), text_dim)
182
+ task = [0.0 for _ in task_to_index]
183
+ task_index = task_to_index.get(str(item.get("task_id", "unknown")))
184
+ if task_index is not None:
185
+ task[task_index] = 1.0
186
+ return obs + text + task
187
+
188
+
189
+ def hash_bow(text: str, dim: int) -> list[float]:
190
+ if dim <= 0:
191
+ raise ValueError("dim must be positive")
192
+ features = [0.0 for _ in range(dim)]
193
+ tokens = [token for token in text.lower().replace(".", " ").split() if token]
194
+ if not tokens:
195
+ return features
196
+ for token in tokens:
197
+ digest = hashlib.sha256(token.encode("utf-8")).digest()
198
+ index = int.from_bytes(digest[:4], "big") % dim
199
+ sign = 1.0 if digest[4] % 2 == 0 else -1.0
200
+ features[index] += sign
201
+ scale = math.sqrt(sum(value * value for value in features)) or 1.0
202
+ return [value / scale for value in features]
203
+
204
+
205
+ def train_and_evaluate_tangent_cvae(
206
+ targets: Sequence[dict[str, Any]],
207
+ *,
208
+ config: TangentCVAEConfig | None = None,
209
+ k_values: Sequence[int] = (1, 2, 4, 8, 16),
210
+ thresholds: Sequence[float] = (0.05, 0.1, 0.2, 0.4),
211
+ device: str = "auto",
212
+ ) -> tuple[dict[str, Any], dict[str, Any]]:
213
+ if torch is None or nn is None or DataLoader is None or TensorDataset is None:
214
+ raise RuntimeError("PyTorch is required to train the tangent CVAE")
215
+ config = config or TangentCVAEConfig()
216
+ _validate_eval_args(k_values, thresholds)
217
+ rows, task_ids, action_dim = build_tangent_cvae_rows(
218
+ targets,
219
+ obs_dim=config.obs_dim,
220
+ text_dim=config.text_dim,
221
+ )
222
+ if not rows:
223
+ raise ValueError("no usable tangent rows")
224
+ split = _split_rows(rows, val_fraction=config.val_fraction, seed=config.seed)
225
+ train_positive = [
226
+ row for row in split["train"]
227
+ if row.example.tangent_label == "positive"
228
+ ]
229
+ if not train_positive:
230
+ raise ValueError("no train positive tangents")
231
+ condition_dim = len(rows[0].condition)
232
+ resolved_device = _resolve_device(device)
233
+ model = PositiveTangentCVAE(
234
+ condition_dim=condition_dim,
235
+ action_dim=action_dim,
236
+ hidden_dim=config.hidden_dim,
237
+ latent_dim=config.latent_dim,
238
+ ).to(resolved_device)
239
+ train_condition, train_delta = _rows_to_tensors(
240
+ train_positive,
241
+ action_dim=action_dim,
242
+ device=resolved_device,
243
+ )
244
+ stats = _normalization_stats(train_condition, train_delta)
245
+ train_condition = _normalize(train_condition, stats["condition_mean"], stats["condition_std"])
246
+ train_delta = _normalize(train_delta, stats["delta_mean"], stats["delta_std"])
247
+ generator = torch.Generator(device="cpu")
248
+ generator.manual_seed(int(config.seed))
249
+ dataset = TensorDataset(train_condition, train_delta)
250
+ loader = DataLoader(
251
+ dataset,
252
+ batch_size=config.batch_size,
253
+ shuffle=True,
254
+ generator=generator,
255
+ )
256
+ optimizer = torch.optim.AdamW(model.parameters(), lr=config.learning_rate)
257
+ history: list[dict[str, float]] = []
258
+ for epoch in range(1, config.epochs + 1):
259
+ model.train()
260
+ loss_sum = 0.0
261
+ recon_sum = 0.0
262
+ kl_sum = 0.0
263
+ count = 0
264
+ for condition_batch, delta_batch in loader:
265
+ optimizer.zero_grad(set_to_none=True)
266
+ recon, mu, logvar = model(condition_batch, delta_batch)
267
+ recon_loss = torch.mean((recon - delta_batch) ** 2)
268
+ kl = -0.5 * torch.mean(1.0 + logvar - mu.pow(2) - logvar.exp())
269
+ loss = recon_loss + config.beta * kl
270
+ loss.backward()
271
+ optimizer.step()
272
+ batch_size = int(condition_batch.shape[0])
273
+ loss_sum += float(loss.detach()) * batch_size
274
+ recon_sum += float(recon_loss.detach()) * batch_size
275
+ kl_sum += float(kl.detach()) * batch_size
276
+ count += batch_size
277
+ if epoch == 1 or epoch == config.epochs or epoch % max(1, config.epochs // 10) == 0:
278
+ history.append(
279
+ {
280
+ "epoch": float(epoch),
281
+ "loss": loss_sum / max(count, 1),
282
+ "reconstruction_mse": recon_sum / max(count, 1),
283
+ "kl": kl_sum / max(count, 1),
284
+ }
285
+ )
286
+ report = evaluate_tangent_cvae_support(
287
+ model,
288
+ rows,
289
+ split=split,
290
+ task_ids=task_ids,
291
+ action_dim=action_dim,
292
+ stats=stats,
293
+ config=config,
294
+ k_values=k_values,
295
+ thresholds=thresholds,
296
+ device=resolved_device,
297
+ )
298
+ report["train_history"] = history
299
+ artifact = {
300
+ "config": asdict(config),
301
+ "task_ids": task_ids,
302
+ "condition_dim": condition_dim,
303
+ "action_dim": action_dim,
304
+ "stats": {key: value.detach().cpu().tolist() for key, value in stats.items()},
305
+ "model_state_dict": model.state_dict(),
306
+ }
307
+ return report, artifact
308
+
309
+
310
+ def evaluate_tangent_cvae_support(
311
+ model: Any,
312
+ rows: Sequence[TangentCVAERow],
313
+ *,
314
+ split: dict[str, list[TangentCVAERow]],
315
+ task_ids: Sequence[str],
316
+ action_dim: int,
317
+ stats: dict[str, Any],
318
+ config: TangentCVAEConfig,
319
+ k_values: Sequence[int],
320
+ thresholds: Sequence[float],
321
+ device: Any,
322
+ ) -> dict[str, Any]:
323
+ max_k = max(int(k) for k in k_values)
324
+ val_by_group: dict[str, list[TangentCVAERow]] = defaultdict(list)
325
+ for row in split["val"]:
326
+ val_by_group[row.example.group_id].append(row)
327
+ model.eval()
328
+ groups: list[dict[str, Any]] = []
329
+ with torch.no_grad():
330
+ for group_id, group_rows in sorted(val_by_group.items()):
331
+ positives = [
332
+ row.example for row in group_rows
333
+ if row.example.tangent_label == "positive"
334
+ ]
335
+ if not positives:
336
+ continue
337
+ negatives = [
338
+ row.example for row in group_rows
339
+ if row.example.tangent_label == "negative"
340
+ ]
341
+ condition = torch.tensor(
342
+ [group_rows[0].condition],
343
+ dtype=torch.float32,
344
+ device=device,
345
+ )
346
+ condition = _normalize(
347
+ condition,
348
+ stats["condition_mean"],
349
+ stats["condition_std"],
350
+ )
351
+ proposal_deltas = _sample_proposals(
352
+ model,
353
+ condition,
354
+ count=max_k,
355
+ config=config,
356
+ stats=stats,
357
+ action_dim=action_dim,
358
+ group_id=group_id,
359
+ device=device,
360
+ )
361
+ groups.append(
362
+ _evaluate_generated_group(
363
+ group_id,
364
+ task_id=group_rows[0].example.task_id,
365
+ proposals=proposal_deltas,
366
+ positives=positives,
367
+ negatives=negatives,
368
+ k_values=k_values,
369
+ thresholds=thresholds,
370
+ )
371
+ )
372
+ positive_groups = groups
373
+ return {
374
+ "report_type": "positive_tangent_cvae_generator_eval",
375
+ "metric_scope": "offline_support_proxy",
376
+ "note": (
377
+ "CVAE proposals are sampled from a train-only positive tangent model "
378
+ "and evaluated against hidden heldout same-state positives."
379
+ ),
380
+ "config": asdict(config),
381
+ "task_ids": list(task_ids),
382
+ "num_examples": len(rows),
383
+ "num_groups": len({row.example.group_id for row in rows}),
384
+ "num_train_examples": len(split["train"]),
385
+ "num_val_examples": len(split["val"]),
386
+ "num_train_positive": sum(
387
+ 1 for row in split["train"] if row.example.tangent_label == "positive"
388
+ ),
389
+ "num_val_groups_with_positive": len(positive_groups),
390
+ "label_counts": dict(Counter(row.example.tangent_label for row in rows)),
391
+ "train_positive_by_task": {
392
+ task_id: sum(
393
+ 1 for row in split["train"]
394
+ if row.example.task_id == task_id
395
+ and row.example.tangent_label == "positive"
396
+ )
397
+ for task_id in task_ids
398
+ },
399
+ "overall": _aggregate_rows(positive_groups, k_values=k_values, thresholds=thresholds),
400
+ "per_task": {
401
+ task_id: _aggregate_rows(
402
+ [group for group in positive_groups if group["task_id"] == task_id],
403
+ k_values=k_values,
404
+ thresholds=thresholds,
405
+ )
406
+ for task_id in task_ids
407
+ },
408
+ "groups": positive_groups,
409
+ }
410
+
411
+
412
+ def _sample_proposals(
413
+ model: Any,
414
+ condition: Any,
415
+ *,
416
+ count: int,
417
+ config: TangentCVAEConfig,
418
+ stats: dict[str, Any],
419
+ action_dim: int,
420
+ group_id: str,
421
+ device: Any,
422
+ ) -> list[list[float]]:
423
+ generator = torch.Generator(device=device.type if hasattr(device, "type") else "cpu")
424
+ seed = int(_stable_uniform(group_id, seed=config.seed) * (2**31 - 1))
425
+ generator.manual_seed(seed)
426
+ repeated_condition = condition.repeat(count, 1)
427
+ latent = torch.randn(
428
+ (count, config.latent_dim),
429
+ generator=generator,
430
+ device=device,
431
+ dtype=repeated_condition.dtype,
432
+ )
433
+ latent = latent * float(config.diversity_temperature)
434
+ decoded = model.decode(repeated_condition, latent)
435
+ decoded = _denormalize(decoded, stats["delta_mean"], stats["delta_std"])
436
+ decoded = decoded[:, :action_dim].detach().cpu().tolist()
437
+ return [[float(value) for value in row] for row in decoded]
438
+
439
+
440
+ def _evaluate_generated_group(
441
+ group_id: str,
442
+ *,
443
+ task_id: str,
444
+ proposals: Sequence[Sequence[float]],
445
+ positives: Sequence[TangentExample],
446
+ negatives: Sequence[TangentExample],
447
+ k_values: Sequence[int],
448
+ thresholds: Sequence[float],
449
+ ) -> dict[str, Any]:
450
+ row: dict[str, Any] = {
451
+ "group_id": group_id,
452
+ "task_id": task_id,
453
+ "num_positive_targets": len(positives),
454
+ "num_negative_targets": len(negatives),
455
+ "num_proposals": len(proposals),
456
+ }
457
+ for k in k_values:
458
+ prefix = list(proposals[: int(k)])
459
+ pos_dist = _min_generated_distance(prefix, positives)
460
+ neg_dist = _min_generated_distance(prefix, negatives)
461
+ row[f"positive_min_rms_l2_at_{k}"] = pos_dist
462
+ row[f"negative_min_rms_l2_at_{k}"] = neg_dist
463
+ row[f"positive_closer_than_negative_at_{k}"] = (
464
+ None if pos_dist is None or neg_dist is None else pos_dist < neg_dist
465
+ )
466
+ for threshold in thresholds:
467
+ key = _threshold_key(threshold)
468
+ row[f"ptr_proxy_at_{k}_thr_{key}"] = (
469
+ None if pos_dist is None else pos_dist <= threshold
470
+ )
471
+ row[f"negative_near_at_{k}_thr_{key}"] = (
472
+ None if neg_dist is None else neg_dist <= threshold
473
+ )
474
+ return row
475
+
476
+
477
+ def _aggregate_rows(
478
+ rows: Sequence[dict[str, Any]],
479
+ *,
480
+ k_values: Sequence[int],
481
+ thresholds: Sequence[float],
482
+ ) -> dict[str, Any]:
483
+ output: dict[str, Any] = {"num_groups": len(rows)}
484
+ for k in k_values:
485
+ distances = [
486
+ float(row[f"positive_min_rms_l2_at_{k}"])
487
+ for row in rows
488
+ if row.get(f"positive_min_rms_l2_at_{k}") is not None
489
+ ]
490
+ output[f"mean_positive_min_rms_l2_at_{k}"] = _mean(distances)
491
+ output[f"median_positive_min_rms_l2_at_{k}"] = _median(distances)
492
+ closer = [
493
+ bool(row[f"positive_closer_than_negative_at_{k}"])
494
+ for row in rows
495
+ if row.get(f"positive_closer_than_negative_at_{k}") is not None
496
+ ]
497
+ output[f"positive_closer_than_negative_rate_at_{k}"] = _bool_rate(closer)
498
+ for threshold in thresholds:
499
+ key = _threshold_key(threshold)
500
+ output[f"ptr_proxy_at_{k}_thr_{key}"] = _bool_rate(
501
+ [
502
+ row[f"ptr_proxy_at_{k}_thr_{key}"]
503
+ for row in rows
504
+ if row.get(f"ptr_proxy_at_{k}_thr_{key}") is not None
505
+ ]
506
+ )
507
+ output[f"negative_near_at_{k}_thr_{key}"] = _bool_rate(
508
+ [
509
+ row[f"negative_near_at_{k}_thr_{key}"]
510
+ for row in rows
511
+ if row.get(f"negative_near_at_{k}_thr_{key}") is not None
512
+ ]
513
+ )
514
+ return output
515
+
516
+
517
+ def _split_rows(
518
+ rows: Sequence[TangentCVAERow],
519
+ *,
520
+ val_fraction: float,
521
+ seed: int,
522
+ ) -> dict[str, list[TangentCVAERow]]:
523
+ train: list[TangentCVAERow] = []
524
+ val: list[TangentCVAERow] = []
525
+ for row in rows:
526
+ if _stable_uniform(row.example.group_id, seed=seed) < val_fraction:
527
+ val.append(row)
528
+ else:
529
+ train.append(row)
530
+ return {"train": train, "val": val}
531
+
532
+
533
+ def _rows_to_tensors(
534
+ rows: Sequence[TangentCVAERow],
535
+ *,
536
+ action_dim: int,
537
+ device: Any,
538
+ ) -> tuple[Any, Any]:
539
+ conditions = [row.condition for row in rows]
540
+ deltas = [_pad_or_truncate(row.delta, action_dim) for row in rows]
541
+ return (
542
+ torch.tensor(conditions, dtype=torch.float32, device=device),
543
+ torch.tensor(deltas, dtype=torch.float32, device=device),
544
+ )
545
+
546
+
547
+ def _normalization_stats(condition: Any, delta: Any) -> dict[str, Any]:
548
+ condition_mean = condition.mean(dim=0, keepdim=True)
549
+ condition_std = condition.std(dim=0, keepdim=True, unbiased=False).clamp(min=1.0e-4)
550
+ delta_mean = delta.mean(dim=0, keepdim=True)
551
+ delta_std = delta.std(dim=0, keepdim=True, unbiased=False).clamp(min=1.0e-4)
552
+ return {
553
+ "condition_mean": condition_mean,
554
+ "condition_std": condition_std,
555
+ "delta_mean": delta_mean,
556
+ "delta_std": delta_std,
557
+ }
558
+
559
+
560
+ def _normalize(value: Any, mean: Any, std: Any) -> Any:
561
+ return (value - mean) / std
562
+
563
+
564
+ def _denormalize(value: Any, mean: Any, std: Any) -> Any:
565
+ return value * std + mean
566
+
567
+
568
+ def _min_generated_distance(
569
+ generated: Sequence[Sequence[float]],
570
+ targets: Sequence[TangentExample],
571
+ ) -> float | None:
572
+ if not generated or not targets:
573
+ return None
574
+ return min(
575
+ _rms_l2(generated_delta, target.flat_delta)
576
+ for generated_delta in generated
577
+ for target in targets
578
+ )
579
+
580
+
581
+ def _rms_l2(left: Sequence[float], right: Sequence[float]) -> float:
582
+ if len(left) != len(right):
583
+ size = min(len(left), len(right))
584
+ left = list(left[:size])
585
+ right = list(right[:size])
586
+ if not left:
587
+ return 0.0
588
+ return math.sqrt(
589
+ sum((float(a) - float(b)) ** 2 for a, b in zip(left, right, strict=True))
590
+ / len(left)
591
+ )
592
+
593
+
594
+ def _pad_or_truncate(values: Sequence[float], size: int) -> list[float]:
595
+ output = [float(value) for value in values[:size]]
596
+ output.extend([0.0] * max(0, size - len(output)))
597
+ return output
598
+
599
+
600
+ def _stable_uniform(value: str, *, seed: int) -> float:
601
+ digest = hashlib.sha256(f"{seed}:{value}".encode("utf-8")).digest()
602
+ integer = int.from_bytes(digest[:8], "big")
603
+ return integer / float(2**64 - 1)
604
+
605
+
606
+ def _threshold_key(value: float) -> str:
607
+ return f"{value:g}".replace(".", "p")
608
+
609
+
610
+ def _mean(values: Sequence[float]) -> float | None:
611
+ return sum(values) / len(values) if values else None
612
+
613
+
614
+ def _median(values: Sequence[float]) -> float | None:
615
+ if not values:
616
+ return None
617
+ ordered = sorted(values)
618
+ mid = len(ordered) // 2
619
+ if len(ordered) % 2:
620
+ return ordered[mid]
621
+ return 0.5 * (ordered[mid - 1] + ordered[mid])
622
+
623
+
624
+ def _bool_rate(values: Sequence[bool]) -> float | None:
625
+ return sum(bool(value) for value in values) / len(values) if values else None
626
+
627
+
628
+ def _validate_eval_args(k_values: Sequence[int], thresholds: Sequence[float]) -> None:
629
+ if any(k <= 0 for k in k_values):
630
+ raise ValueError("k_values must be positive")
631
+ if any(threshold < 0 for threshold in thresholds):
632
+ raise ValueError("thresholds must be non-negative")
633
+
634
+
635
+ def _resolve_device(device: str) -> Any:
636
+ if device == "auto":
637
+ return torch.device("cuda" if torch.cuda.is_available() else "cpu")
638
+ resolved = torch.device(device)
639
+ if resolved.type == "cuda" and not torch.cuda.is_available():
640
+ raise RuntimeError("CUDA requested but not available")
641
+ return resolved
642
+
643
+
644
+ def _is_numeric_matrix(value: Any) -> bool:
645
+ return (
646
+ isinstance(value, list)
647
+ and bool(value)
648
+ and all(
649
+ isinstance(row, list)
650
+ and all(isinstance(item, (int, float)) for item in row)
651
+ for row in value
652
+ )
653
+ )
workspace/dovla_cil/generation/tangent_memory.py ADDED
@@ -0,0 +1,380 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import hashlib
4
+ import json
5
+ import math
6
+ from collections import Counter, defaultdict
7
+ from collections.abc import Sequence
8
+ from dataclasses import dataclass
9
+ from pathlib import Path
10
+ from typing import Any
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class TangentExample:
15
+ group_id: str
16
+ task_id: str
17
+ candidate_type: str
18
+ tangent_label: str
19
+ delta_utility: float
20
+ delta_action: list[list[float]]
21
+
22
+ @property
23
+ def flat_delta(self) -> list[float]:
24
+ return [float(value) for row in self.delta_action for value in row]
25
+
26
+
27
+ def load_tangent_targets(path: str | Path) -> list[TangentExample]:
28
+ payload = json.loads(Path(path).read_text())
29
+ examples: list[TangentExample] = []
30
+ for item in payload.get("targets", []):
31
+ delta_action = item.get("delta_action", [])
32
+ if not _is_numeric_matrix(delta_action):
33
+ continue
34
+ examples.append(
35
+ TangentExample(
36
+ group_id=str(item["group_id"]),
37
+ task_id=str(item["task_id"]),
38
+ candidate_type=str(item.get("candidate_type", "unknown")),
39
+ tangent_label=str(item["tangent_label"]),
40
+ delta_utility=float(item["delta_utility"]),
41
+ delta_action=[
42
+ [float(value) for value in row]
43
+ for row in delta_action
44
+ ],
45
+ )
46
+ )
47
+ return examples
48
+
49
+
50
+ def evaluate_tangent_memory_generator(
51
+ examples: Sequence[TangentExample],
52
+ *,
53
+ k_values: Sequence[int] = (1, 2, 4, 8),
54
+ thresholds: Sequence[float] = (0.05, 0.1, 0.2, 0.4),
55
+ val_fraction: float = 0.2,
56
+ seed: int = 0,
57
+ diversity_weight: float = 0.25,
58
+ ) -> dict[str, Any]:
59
+ """Evaluate a nonparametric positive-tangent generator.
60
+
61
+ The generator sees only train-split positive tangents and proposes a small diverse
62
+ memory set per task. Evaluation asks whether the proposals are close to hidden
63
+ same-state positive tangents in heldout groups. This is an offline support metric,
64
+ not a simulator rollout claim.
65
+ """
66
+
67
+ if not 0.0 < val_fraction < 1.0:
68
+ raise ValueError("val_fraction must be in (0, 1)")
69
+ if any(k <= 0 for k in k_values):
70
+ raise ValueError("k_values must be positive")
71
+ if any(threshold < 0 for threshold in thresholds):
72
+ raise ValueError("thresholds must be non-negative")
73
+ if diversity_weight < 0:
74
+ raise ValueError("diversity_weight must be non-negative")
75
+
76
+ group_ids = sorted({example.group_id for example in examples})
77
+ val_groups = {
78
+ group_id
79
+ for group_id in group_ids
80
+ if _stable_uniform(group_id, seed=seed) < val_fraction
81
+ }
82
+ train = [example for example in examples if example.group_id not in val_groups]
83
+ val = [example for example in examples if example.group_id in val_groups]
84
+ max_k = max(int(k) for k in k_values)
85
+ positive_train_by_task: dict[str, list[TangentExample]] = defaultdict(list)
86
+ global_positive_train: list[TangentExample] = []
87
+ for example in train:
88
+ if example.tangent_label == "positive":
89
+ positive_train_by_task[example.task_id].append(example)
90
+ global_positive_train.append(example)
91
+
92
+ proposals_by_task = {
93
+ task_id: _select_diverse_prototypes(
94
+ positive_train_by_task.get(task_id, []),
95
+ fallback_examples=global_positive_train,
96
+ max_k=max_k,
97
+ diversity_weight=diversity_weight,
98
+ )
99
+ for task_id in sorted({example.task_id for example in examples})
100
+ }
101
+
102
+ val_by_group: dict[str, list[TangentExample]] = defaultdict(list)
103
+ for example in val:
104
+ val_by_group[example.group_id].append(example)
105
+
106
+ groups = []
107
+ for group_id, group_examples in sorted(val_by_group.items()):
108
+ task_id = group_examples[0].task_id
109
+ positives = [
110
+ example for example in group_examples
111
+ if example.tangent_label == "positive"
112
+ ]
113
+ negatives = [
114
+ example for example in group_examples
115
+ if example.tangent_label == "negative"
116
+ ]
117
+ proposals = proposals_by_task.get(task_id, [])
118
+ groups.append(
119
+ _evaluate_group(
120
+ group_id,
121
+ task_id=task_id,
122
+ positives=positives,
123
+ negatives=negatives,
124
+ proposals=proposals,
125
+ k_values=k_values,
126
+ thresholds=thresholds,
127
+ )
128
+ )
129
+
130
+ return _aggregate_report(
131
+ examples,
132
+ train=train,
133
+ val=val,
134
+ val_groups=val_groups,
135
+ proposals_by_task=proposals_by_task,
136
+ groups=groups,
137
+ k_values=k_values,
138
+ thresholds=thresholds,
139
+ val_fraction=val_fraction,
140
+ seed=seed,
141
+ diversity_weight=diversity_weight,
142
+ )
143
+
144
+
145
+ def _select_diverse_prototypes(
146
+ task_examples: Sequence[TangentExample],
147
+ *,
148
+ fallback_examples: Sequence[TangentExample],
149
+ max_k: int,
150
+ diversity_weight: float,
151
+ ) -> list[TangentExample]:
152
+ pool = list(task_examples) or list(fallback_examples)
153
+ if not pool:
154
+ return []
155
+ selected: list[TangentExample] = []
156
+ remaining = sorted(
157
+ pool,
158
+ key=lambda example: (-example.delta_utility, example.group_id, example.candidate_type),
159
+ )
160
+ while remaining and len(selected) < max_k:
161
+ if not selected:
162
+ chosen = remaining[0]
163
+ else:
164
+ chosen = max(
165
+ remaining,
166
+ key=lambda example: (
167
+ example.delta_utility
168
+ + diversity_weight * _nearest_distance(example, selected),
169
+ example.delta_utility,
170
+ ),
171
+ )
172
+ selected.append(chosen)
173
+ remaining = [example for example in remaining if example is not chosen]
174
+ return selected
175
+
176
+
177
+ def _evaluate_group(
178
+ group_id: str,
179
+ *,
180
+ task_id: str,
181
+ positives: Sequence[TangentExample],
182
+ negatives: Sequence[TangentExample],
183
+ proposals: Sequence[TangentExample],
184
+ k_values: Sequence[int],
185
+ thresholds: Sequence[float],
186
+ ) -> dict[str, Any]:
187
+ row: dict[str, Any] = {
188
+ "group_id": group_id,
189
+ "task_id": task_id,
190
+ "num_positive_targets": len(positives),
191
+ "num_negative_targets": len(negatives),
192
+ "has_positive": bool(positives),
193
+ "num_proposals": len(proposals),
194
+ }
195
+ for k in k_values:
196
+ prefix = list(proposals[: int(k)])
197
+ pos_dist = _min_pair_distance(prefix, positives)
198
+ neg_dist = _min_pair_distance(prefix, negatives)
199
+ row[f"positive_min_rms_l2_at_{k}"] = pos_dist
200
+ row[f"negative_min_rms_l2_at_{k}"] = neg_dist
201
+ row[f"positive_closer_than_negative_at_{k}"] = (
202
+ None if pos_dist is None or neg_dist is None else pos_dist < neg_dist
203
+ )
204
+ for threshold in thresholds:
205
+ key = _threshold_key(threshold)
206
+ row[f"ptr_proxy_at_{k}_thr_{key}"] = (
207
+ None if pos_dist is None else pos_dist <= threshold
208
+ )
209
+ row[f"negative_near_at_{k}_thr_{key}"] = (
210
+ None if neg_dist is None else neg_dist <= threshold
211
+ )
212
+ return row
213
+
214
+
215
+ def _aggregate_report(
216
+ examples: Sequence[TangentExample],
217
+ *,
218
+ train: Sequence[TangentExample],
219
+ val: Sequence[TangentExample],
220
+ val_groups: set[str],
221
+ proposals_by_task: dict[str, list[TangentExample]],
222
+ groups: Sequence[dict[str, Any]],
223
+ k_values: Sequence[int],
224
+ thresholds: Sequence[float],
225
+ val_fraction: float,
226
+ seed: int,
227
+ diversity_weight: float,
228
+ ) -> dict[str, Any]:
229
+ positive_groups = [group for group in groups if group["has_positive"]]
230
+ report: dict[str, Any] = {
231
+ "report_type": "positive_tangent_memory_generator_eval",
232
+ "metric_scope": "offline_support_proxy",
233
+ "note": (
234
+ "PTR proxy measures whether train-only positive tangent memory proposals "
235
+ "fall within an RMS-L2 threshold of a hidden heldout positive tangent."
236
+ ),
237
+ "seed": seed,
238
+ "val_fraction": val_fraction,
239
+ "diversity_weight": diversity_weight,
240
+ "num_examples": len(examples),
241
+ "num_train_examples": len(train),
242
+ "num_val_examples": len(val),
243
+ "num_groups": len({example.group_id for example in examples}),
244
+ "num_val_groups": len(val_groups),
245
+ "num_eval_groups": len(groups),
246
+ "num_eval_groups_with_positive": len(positive_groups),
247
+ "label_counts": dict(Counter(example.tangent_label for example in examples)),
248
+ "train_positive_by_task": {
249
+ task_id: sum(
250
+ 1 for example in train
251
+ if example.task_id == task_id and example.tangent_label == "positive"
252
+ )
253
+ for task_id in sorted({example.task_id for example in examples})
254
+ },
255
+ "proposal_count_by_task": {
256
+ task_id: len(proposals)
257
+ for task_id, proposals in sorted(proposals_by_task.items())
258
+ },
259
+ "overall": _aggregate_rows(positive_groups, k_values=k_values, thresholds=thresholds),
260
+ "per_task": {
261
+ task_id: _aggregate_rows(
262
+ [group for group in positive_groups if group["task_id"] == task_id],
263
+ k_values=k_values,
264
+ thresholds=thresholds,
265
+ )
266
+ for task_id in sorted({group["task_id"] for group in groups})
267
+ },
268
+ "groups": list(groups),
269
+ }
270
+ return report
271
+
272
+
273
+ def _aggregate_rows(
274
+ rows: Sequence[dict[str, Any]],
275
+ *,
276
+ k_values: Sequence[int],
277
+ thresholds: Sequence[float],
278
+ ) -> dict[str, Any]:
279
+ output: dict[str, Any] = {"num_groups": len(rows)}
280
+ for k in k_values:
281
+ distances = [
282
+ float(row[f"positive_min_rms_l2_at_{k}"])
283
+ for row in rows
284
+ if row.get(f"positive_min_rms_l2_at_{k}") is not None
285
+ ]
286
+ output[f"mean_positive_min_rms_l2_at_{k}"] = _mean(distances)
287
+ output[f"median_positive_min_rms_l2_at_{k}"] = _median(distances)
288
+ closer = [
289
+ bool(row[f"positive_closer_than_negative_at_{k}"])
290
+ for row in rows
291
+ if row.get(f"positive_closer_than_negative_at_{k}") is not None
292
+ ]
293
+ output[f"positive_closer_than_negative_rate_at_{k}"] = _bool_rate(closer)
294
+ for threshold in thresholds:
295
+ key = _threshold_key(threshold)
296
+ output[f"ptr_proxy_at_{k}_thr_{key}"] = _bool_rate(
297
+ [
298
+ row[f"ptr_proxy_at_{k}_thr_{key}"]
299
+ for row in rows
300
+ if row.get(f"ptr_proxy_at_{k}_thr_{key}") is not None
301
+ ]
302
+ )
303
+ output[f"negative_near_at_{k}_thr_{key}"] = _bool_rate(
304
+ [
305
+ row[f"negative_near_at_{k}_thr_{key}"]
306
+ for row in rows
307
+ if row.get(f"negative_near_at_{k}_thr_{key}") is not None
308
+ ]
309
+ )
310
+ return output
311
+
312
+
313
+ def _nearest_distance(example: TangentExample, references: Sequence[TangentExample]) -> float:
314
+ value = _min_pair_distance([example], references)
315
+ return 0.0 if value is None else value
316
+
317
+
318
+ def _min_pair_distance(
319
+ left: Sequence[TangentExample],
320
+ right: Sequence[TangentExample],
321
+ ) -> float | None:
322
+ if not left or not right:
323
+ return None
324
+ best = min(
325
+ _rms_l2(left_item.flat_delta, right_item.flat_delta)
326
+ for left_item in left
327
+ for right_item in right
328
+ )
329
+ return best
330
+
331
+
332
+ def _rms_l2(left: Sequence[float], right: Sequence[float]) -> float:
333
+ if len(left) != len(right):
334
+ return float("inf")
335
+ if not left:
336
+ return 0.0
337
+ return math.sqrt(
338
+ sum((float(a) - float(b)) ** 2 for a, b in zip(left, right, strict=True))
339
+ / len(left)
340
+ )
341
+
342
+
343
+ def _stable_uniform(value: str, *, seed: int) -> float:
344
+ digest = hashlib.sha256(f"{seed}:{value}".encode("utf-8")).digest()
345
+ integer = int.from_bytes(digest[:8], "big")
346
+ return integer / float(2**64 - 1)
347
+
348
+
349
+ def _threshold_key(value: float) -> str:
350
+ return f"{value:g}".replace(".", "p")
351
+
352
+
353
+ def _mean(values: Sequence[float]) -> float | None:
354
+ return sum(values) / len(values) if values else None
355
+
356
+
357
+ def _median(values: Sequence[float]) -> float | None:
358
+ if not values:
359
+ return None
360
+ ordered = sorted(values)
361
+ mid = len(ordered) // 2
362
+ if len(ordered) % 2:
363
+ return ordered[mid]
364
+ return 0.5 * (ordered[mid - 1] + ordered[mid])
365
+
366
+
367
+ def _bool_rate(values: Sequence[bool]) -> float | None:
368
+ return sum(bool(value) for value in values) / len(values) if values else None
369
+
370
+
371
+ def _is_numeric_matrix(value: Any) -> bool:
372
+ return (
373
+ isinstance(value, list)
374
+ and bool(value)
375
+ and all(
376
+ isinstance(row, list)
377
+ and all(isinstance(item, (int, float)) for item in row)
378
+ for row in value
379
+ )
380
+ )
workspace/latex/main.aux CHANGED
@@ -30,9 +30,9 @@
30
  \@writefile{lot}{\contentsline {table}{\numberline {2}{\ignorespaces Causal Action Regret decomposition on the current six-task diagnostic. Support is the proposal-generation gap to the hidden same-state no-expert oracle; selector is the clean proposal-oracle headroom left by the deployed selector.}}{4}{table.2}\protected@file@percent }
31
  \newlabel{tab:car-decomposition}{{2}{4}{Causal Action Regret decomposition on the current six-task diagnostic. Support is the proposal-generation gap to the hidden same-state no-expert oracle; selector is the clean proposal-oracle headroom left by the deployed selector}{table.2}{}}
32
  \@writefile{toc}{\contentsline {section}{\numberline {6}Roadmap to the Full Paper}{4}{section.6}\protected@file@percent }
33
- \@writefile{toc}{\contentsline {section}{\numberline {7}Limitations}{4}{section.7}\protected@file@percent }
34
  \@writefile{lot}{\contentsline {table}{\numberline {3}{\ignorespaces Train-source score prior sensitivity for the current K6 transported residual field. A very small prior calibrates the selector; stronger priors tie or degrade success.}}{5}{table.3}\protected@file@percent }
35
  \newlabel{tab:source-score-sweep}{{3}{5}{Train-source score prior sensitivity for the current K6 transported residual field. A very small prior calibrates the selector; stronger priors tie or degrade success}{table.3}{}}
36
  \@writefile{lot}{\contentsline {table}{\numberline {4}{\ignorespaces Selector calibration ablations on the current K6 transported residual field. All rows are deployment-clean and use only train-split calibration signals.}}{5}{table.4}\protected@file@percent }
37
  \newlabel{tab:selector-calibration}{{4}{5}{Selector calibration ablations on the current K6 transported residual field. All rows are deployment-clean and use only train-split calibration signals}{table.4}{}}
 
38
  \gdef \@abspage@last{5}
 
30
  \@writefile{lot}{\contentsline {table}{\numberline {2}{\ignorespaces Causal Action Regret decomposition on the current six-task diagnostic. Support is the proposal-generation gap to the hidden same-state no-expert oracle; selector is the clean proposal-oracle headroom left by the deployed selector.}}{4}{table.2}\protected@file@percent }
31
  \newlabel{tab:car-decomposition}{{2}{4}{Causal Action Regret decomposition on the current six-task diagnostic. Support is the proposal-generation gap to the hidden same-state no-expert oracle; selector is the clean proposal-oracle headroom left by the deployed selector}{table.2}{}}
32
  \@writefile{toc}{\contentsline {section}{\numberline {6}Roadmap to the Full Paper}{4}{section.6}\protected@file@percent }
 
33
  \@writefile{lot}{\contentsline {table}{\numberline {3}{\ignorespaces Train-source score prior sensitivity for the current K6 transported residual field. A very small prior calibrates the selector; stronger priors tie or degrade success.}}{5}{table.3}\protected@file@percent }
34
  \newlabel{tab:source-score-sweep}{{3}{5}{Train-source score prior sensitivity for the current K6 transported residual field. A very small prior calibrates the selector; stronger priors tie or degrade success}{table.3}{}}
35
  \@writefile{lot}{\contentsline {table}{\numberline {4}{\ignorespaces Selector calibration ablations on the current K6 transported residual field. All rows are deployment-clean and use only train-split calibration signals.}}{5}{table.4}\protected@file@percent }
36
  \newlabel{tab:selector-calibration}{{4}{5}{Selector calibration ablations on the current K6 transported residual field. All rows are deployment-clean and use only train-split calibration signals}{table.4}{}}
37
+ \@writefile{toc}{\contentsline {section}{\numberline {7}Limitations}{5}{section.7}\protected@file@percent }
38
  \gdef \@abspage@last{5}
workspace/latex/main.log CHANGED
@@ -1,4 +1,4 @@
1
- This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021 Gentoo Linux) (preloaded format=pdflatex 2023.8.23) 2 JUL 2026 15:30
2
  entering extended mode
3
  restricted \write18 enabled.
4
  %&-line parsing enabled.
@@ -491,7 +491,7 @@ Package rerunfilecheck Info: File `main.out' has not changed.
491
  Here is how much of TeX's memory you used:
492
  9899 strings out of 480884
493
  146741 string characters out of 5900692
494
- 458545 words of memory out of 5000000
495
  26980 multiletter control sequences out of 15000+600000
496
  414083 words of font info for 68 fonts, out of 8000000 for 9000
497
  36 hyphenation exceptions out of 8191
@@ -524,7 +524,7 @@ mf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></cvmfs/soft.computecanada.ca/
524
  gentoo/2023/x86-64-v3/usr/share/texmf-dist/fonts/type1/public/amsfonts/symbols/
525
  msbm10.pfb></cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/share/texmf-
526
  dist/fonts/type1/public/cm-super/sfrm1000.pfb>
527
- Output written on main.pdf (5 pages, 210908 bytes).
528
  PDF statistics:
529
  154 PDF objects out of 1000 (max. 8388607)
530
  127 compressed objects within 2 object streams
 
1
+ This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021 Gentoo Linux) (preloaded format=pdflatex 2023.8.23) 2 JUL 2026 16:27
2
  entering extended mode
3
  restricted \write18 enabled.
4
  %&-line parsing enabled.
 
491
  Here is how much of TeX's memory you used:
492
  9899 strings out of 480884
493
  146741 string characters out of 5900692
494
+ 460545 words of memory out of 5000000
495
  26980 multiletter control sequences out of 15000+600000
496
  414083 words of font info for 68 fonts, out of 8000000 for 9000
497
  36 hyphenation exceptions out of 8191
 
524
  gentoo/2023/x86-64-v3/usr/share/texmf-dist/fonts/type1/public/amsfonts/symbols/
525
  msbm10.pfb></cvmfs/soft.computecanada.ca/gentoo/2023/x86-64-v3/usr/share/texmf-
526
  dist/fonts/type1/public/cm-super/sfrm1000.pfb>
527
+ Output written on main.pdf (5 pages, 212366 bytes).
528
  PDF statistics:
529
  154 PDF objects out of 1000 (max. 8388607)
530
  127 compressed objects within 2 object streams
workspace/latex/main.pdf CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b630e3e60c3af10aaabb2b880b246a3394ccbd3626422a4acbd5865410c2fe3f
3
- size 210609
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ebbdde77ca6b02ef025b3b754f737a96a9eb5a73331321f829aa5ac3dfe6d78
3
+ size 212144
workspace/latex/main.tex CHANGED
@@ -236,6 +236,24 @@ the remaining support gap. A first utility-weighted Generator V1 sweep reaches
236
  train residuals is not the missing idea. The paper should move residual
237
  transport and small source priors to the role of diagnostic baselines, then
238
  make the main method a learned generator of positive causal tangent support.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
  \section{Roadmap to the Full Paper}
241
 
@@ -244,9 +262,10 @@ large ManiSkill3 core benchmark, add one external long-horizon or embodiment
244
  benchmark, and include real robot near-miss recovery. Method development should
245
  proceed in the order implied by the decomposition: evaluate Generator V1,
246
  export measured positive/negative tangent targets from the current charts,
247
- then replace retrieval with a positive-tangent CVAE or flow-matching generator
248
- in object-centric spline tangent space, trained with pairwise/listwise utility
249
- field losses and calibrated dominance. The acceptance bar is selected clean
 
250
  success above 47--50\% on the current tasks, generator top-8 oracle above 50\%,
251
  selector gap below 3 points, and a real near-miss recovery gain of at least
252
  15--25 points over the base policy.
 
236
  train residuals is not the missing idea. The paper should move residual
237
  transport and small source priors to the role of diagnostic baselines, then
238
  make the main method a learned generator of positive causal tangent support.
239
+ We now also export 43,095 measured tangent targets from 2,873 charts. A
240
+ train-only positive-tangent memory diagnostic reaches 11.83\% PTR proxy at
241
+ K=16 under a strict 0.20 RMS-L2 threshold and 41.94\% under a looser 0.40
242
+ threshold, with positives closer than negatives in 61.33\% of covered heldout
243
+ charts. A first raw-action CVAE improves the safety side of the proxy---0.00\%
244
+ negative-near at the 0.20 threshold and 65.33\% positives-closer-than-negatives
245
+ at K=16---but covers less positive support (7.53\% PTR at 0.20, 34.41\% at
246
+ 0.40). A 21D keyframe spline-CVAE decoded back to full $16\times 7$ chunks
247
+ recovers more strict support than the raw CVAE (9.68\% PTR at 0.20) while
248
+ keeping negative-near low (1.33\%). A vanilla spline flow-matching baseline is
249
+ even safer (0.00\% negative-near) but collapses support (1.08\% PTR at 0.20),
250
+ showing that flow matching must be utility- and geometry-guided rather than
251
+ merely density matching positive keyframes. This is not yet the method result.
252
+ It is a useful failure mode: positive support is structured, but prototypes,
253
+ raw chunk likelihood, simple keyframe splines, and unguided flows still miss
254
+ much of the chart. The full generator should therefore model object-centric
255
+ positive tangent flows with utility contrast, not just replay or compress action
256
+ chunks.
257
 
258
  \section{Roadmap to the Full Paper}
259
 
 
262
  benchmark, and include real robot near-miss recovery. Method development should
263
  proceed in the order implied by the decomposition: evaluate Generator V1,
264
  export measured positive/negative tangent targets from the current charts,
265
+ use train-only memory as the leakage-checked support diagnostic, then replace
266
+ retrieval with a positive-tangent flow-matching generator in object-centric
267
+ spline tangent space, trained with pairwise/listwise utility field losses,
268
+ negative support contrast, and calibrated dominance. The acceptance bar is selected clean
269
  success above 47--50\% on the current tasks, generator top-8 oracle above 50\%,
270
  selector gap below 3 points, and a real near-miss recovery gain of at least
271
  15--25 points over the base policy.