Auto-sync: 2026-06-28 00:54:07 (part 3)
Browse filesFiles changed (10)
- results/h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_v2_summary.mdAdded+19
- results/paper_core_results.md+12-8
- results/paper_story_memo.md+19-21
- results/paper_table_status.json+14-54
- results/paper_table_status.md+4-8
- scripts/build_paper_table_status.py+24-22
- scripts/export_field_selected_policy_targets.pyAdded+159
- scripts/slurm/train_dovla_h16_policy_ckpt.sbatch+5
- scripts/train_dovla.py+8
- tests/test_trainer.py+37
12345678910111213141516171819# h=16 Best-Policy Checkpoint Rollout
Run root: `/scratch/knguy52/dovla/experiments/dovla_h16_policy_ckpt_runs`Objective: `near_miss_policy_bc5`Result file: `retrieval_residual_v2_rollout.json`Completed seeds: 3Baseline h=4 policy success: 29.67%Baseline h=16 rank-checkpoint success: 29.74%
Mean success: 32.12% +/- 1.26%Gain vs h=16 rank checkpoint: +2.38%Mean progress: 54.83%Mean action MSE to best: 0.559
| seed | mode | k | retrieval K | sigma | opt steps | trust | success | progress | oracle | action MSE ||---:|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|| 0 | retrieval_residual | 16 | 1 | 0.00 | 0 | 0.00 | 31.48% | 53.24% | 85.74% | 0.633 || 1 | retrieval_residual | 16 | 1 | 0.00 | 0 | 0.00 | 31.30% | 54.83% | 86.96% | 0.508 || 2 | retrieval_residual | 16 | 1 | 0.00 | 0 | 0.00 | 33.57% | 56.41% | 87.65% | 0.538 |17 unmodified lines181920212223248 unmodified lines33343536373839404142434445464717 unmodified lines| Trust-region field optimization | No | No | 25.39% | -4.35 pp | Differentiable field ascent is a negative diagnostic; the field is not a generic action optimizer || Best non-expert proposal policy | No | No | 27.88% | -1.86 pp | Broadening BC targets beyond near-miss does not solve proposal generation || Best non-expert proposal + field | No | No | 26.49% | -3.25 pp | The field still needs local counterfactual proposal geometry || Train-state residual retrieval | No | No | Pending | Pending | Fixed v2 jobs are running; tests whether transferable counterfactual tangent directions bridge the clean gap || Lattice, no expert/no near-miss | Yes | No | 25.57% | -4.17 pp | Non-local negatives do not help || Lattice, near-miss only | Yes | No | 55.94% | +26.20 pp | Local counterfactual proposals carry the gain || Lattice, no expert | Yes | No | 56.99% | +27.25 pp | Reviewer-safe main result |8 unmodified lines4. Near-miss proposal + field, BC x5 field checkpoint5. Trust-region field optimization6. Best non-expert proposal + field7. Lattice, near-miss only8. Lattice, no expert9. Lattice, full10. Oracle ceilingSuggested claim:> DoVLA-CIL is not a better behavior-cloning policy; it is a local counterfactual action> selection rule. A deployment-clean near-miss proposal policy plus the field gives a small> gain, while field-gradient ascent and broader non-expert BC targets both fail. The large> effect appears only when the field is queried on same-state intervention proposals, and> the mechanism is isolated to near-miss counterfactuals.17 unmodified lines1819202122232425268 unmodified lines353637383940414243444546474849505117 unmodified lines| Trust-region field optimization | No | No | 25.39% | -4.35 pp | Differentiable field ascent is a negative diagnostic; the field is not a generic action optimizer || Best non-expert proposal policy | No | No | 27.88% | -1.86 pp | Broadening BC targets beyond near-miss does not solve proposal generation || Best non-expert proposal + field | No | No | 26.49% | -3.25 pp | The field still needs local counterfactual proposal geometry || Train-state residual retrieval | No | No | 32.12% | +2.38 pp | Transferred counterfactual residuals are a positive clean bridge but do not beat the near-miss proposal policy || KNN train-state residual retrieval | No | No | 29.91% | +0.17 pp | Adding more retrieved tangent neighborhoods dilutes the signal || Train-state near-miss residual retrieval | No | No | 14.06% smoke | -15.68 pp | Restricting to transferred near-miss residuals failed in smoke; full jobs canceled || Lattice, no expert/no near-miss | Yes | No | 25.57% | -4.17 pp | Non-local negatives do not help || Lattice, near-miss only | Yes | No | 55.94% | +26.20 pp | Local counterfactual proposals carry the gain || Lattice, no expert | Yes | No | 56.99% | +27.25 pp | Reviewer-safe main result |8 unmodified lines4. Near-miss proposal + field, BC x5 field checkpoint5. Trust-region field optimization6. Best non-expert proposal + field7. Train-state residual retrieval8. Lattice, near-miss only9. Lattice, no expert10. Lattice, full11. Oracle ceilingSuggested claim:> DoVLA-CIL is not a better behavior-cloning policy; it is a local counterfactual action> selection rule. A deployment-clean near-miss proposal policy plus the field gives a small> gain, and transferred counterfactual residuals nearly match it, while field-gradient ascent,> KNN residual retrieval, and broader non-expert BC targets fail. The large effect appears only> when the field is queried on same-state intervention proposals, and the mechanism is isolated> to near-miss counterfactuals.
61 unmodified lines6263646566676814 unmodified lines838485868788899091929394959697989910010110210310410510610710861 unmodified lines## Active JobsLast checked: `2026-06-28 04:44 UTC`.- `14842523`: GPU smoke for `selection_mode=field_optim`.- `14842557`: low-resource CPU unit smoke for the pure action-optimization helper.14 unmodified lines- `14842619`: KNN4 `retrieval_residual` summary.- `14842646`: CPU unit smoke for the KNN residual helper. Completed.- `14857111`: fixed nearest-1 `retrieval_residual` smoke.- `14857112`: fixed nearest-1 `retrieval_residual` full rollout.- `14857113`: fixed nearest-1 `retrieval_residual` summary.- `14857114`: fixed KNN4 `retrieval_residual` smoke.- `14857115`: fixed KNN4 `retrieval_residual` full rollout.- `14857116`: fixed KNN4 `retrieval_residual` summary.- `14857117`: rebuild `paper_table_status.*` after fixed residual summaries.- `14857692`: smoke nearest-1 transferred near-miss residual retrieval.- `14857693`: full nearest-1 transferred near-miss residual retrieval.- `14857694`: summary nearest-1 transferred near-miss residual retrieval.- `14857695`: smoke KNN4 transferred near-miss residual retrieval.- `14857696`: full KNN4 transferred near-miss residual retrieval.- `14857697`: summary KNN4 transferred near-miss residual retrieval.- `14857698`: rebuild `paper_table_status.*` after near-miss residual summaries.Current scheduler state: `field_optim` and `nonexpert_policy_bc5` jobs completed.The first residual rollout smokes failed on a missing `retrieval_neighbors`argument; fixed v2 residual jobs `14857111`-`14857117` are pending onpriority/dependencies. The fixed smokes passed and full rollouts are running;near-miss-only residual diagnostics `14857692`-`14857698` are also running ordependency-held.## Decision Rule For Field Optim Jobs61 unmodified lines6263646566676814 unmodified lines838485868788899091929394959697989910010110210310410510661 unmodified lines## Active JobsLast checked: `2026-06-28 04:51 UTC`.- `14842523`: GPU smoke for `selection_mode=field_optim`.- `14842557`: low-resource CPU unit smoke for the pure action-optimization helper.14 unmodified lines- `14842619`: KNN4 `retrieval_residual` summary.- `14842646`: CPU unit smoke for the KNN residual helper. Completed.- `14857111`: fixed nearest-1 `retrieval_residual` smoke.- `14857112`: fixed nearest-1 `retrieval_residual` full rollout. Completed.- `14857113`: fixed nearest-1 `retrieval_residual` summary. Completed.- `14857114`: fixed KNN4 `retrieval_residual` smoke. Completed.- `14857115`: fixed KNN4 `retrieval_residual` full rollout. Completed.- `14857116`: fixed KNN4 `retrieval_residual` summary. Completed.- `14857117`: rebuild `paper_table_status.*` after fixed residual summaries. Completed.- `14857692`: smoke nearest-1 transferred near-miss residual retrieval. Completed.- `14857693`: full nearest-1 transferred near-miss residual retrieval. Canceled.- `14857694`: summary nearest-1 transferred near-miss residual retrieval. Canceled.- `14857695`: smoke KNN4 transferred near-miss residual retrieval. Completed.- `14857696`: full KNN4 transferred near-miss residual retrieval. Canceled.- `14857697`: summary KNN4 transferred near-miss residual retrieval. Canceled.- `14857698`: rebuild `paper_table_status.*` after near-miss residual summaries. Canceled.Current scheduler state: no tracked jobs are active. `field_optim`,`nonexpert_policy_bc5`, and residual v2 jobs completed. Residual nearest-1 is apositive clean bridge at 32.12%, KNN4 residual is 29.91%, and near-miss-onlyresidual smoke was weak enough to cancel its full jobs.## Decision Rule For Field Optim Jobs
157 unmodified lines1581591601611621631641651661671681691701715 unmodified lines177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228120 unmodified lines349350351352353354355356357157 unmodified lines"story_role": "pending transferable local tangent proposal","fallback_success": null,"pending_job": "14857111/14857112/14857113","path_exists": false,"status": "pending","success": null,"std_success": null,"completed_seeds": null,"num_completed": null,"best_config": null,"gain_vs_h16_policy": null},{"key": "retrieval_residual_knn4",5 unmodified lines"story_role": "pending KNN tangent proposal","fallback_success": null,"pending_job": "14857114/14857115/14857116","path_exists": false,"status": "pending","success": null,"std_success": null,"completed_seeds": null,"num_completed": null,"best_config": null,"gain_vs_h16_policy": null},{"key": "retrieval_residual_nearmiss","label": "Train-state near-miss residual retrieval","path": "h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_nearmiss_v2_summary.json","clean_deployment": "yes","same_state_proposals": "no","expert_proposal": "no","story_role": "pending transferable near-miss tangent proposal","fallback_success": null,"pending_job": "14857692/14857693/14857694","path_exists": false,"status": "pending","success": null,"std_success": null,"completed_seeds": null,"num_completed": null,"best_config": null,"gain_vs_h16_policy": null},{"key": "retrieval_residual_nearmiss_knn4","label": "KNN near-miss residual retrieval","path": "h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_nearmiss_knn4_v2_summary.json","clean_deployment": "yes","same_state_proposals": "no","expert_proposal": "no","story_role": "pending KNN near-miss tangent proposal","fallback_success": null,"pending_job": "14857695/14857696/14857697","path_exists": false,"status": "pending","success": null,"std_success": null,"completed_seeds": null,"num_completed": null,"best_config": null,"gain_vs_h16_policy": null},{"key": "near_miss_only_lattice",120 unmodified lines"Do not claim external SOTA from this table alone; add current external baselines separately.","Current best clean deployment row is Near-miss proposal policy + field at 32.93%.","Trust-region field optimization should be framed as a negative/diagnostic ablation.","Train-state counterfactual residual retrieval is pending (14857111/14857112/14857113).","KNN counterfactual residual retrieval is pending (14857114/14857115/14857116).","Train-state near-miss residual retrieval is pending (14857692/14857693/14857694).","KNN near-miss residual retrieval is pending (14857695/14857696/14857697)."]}157 unmodified lines1581591601611621631641651661671681691701715 unmodified lines177178179180181182183184185186187188189190120 unmodified lines311312313314315316317157 unmodified lines"story_role": "pending transferable local tangent proposal","fallback_success": null,"pending_job": "14857111/14857112/14857113","path_exists": true,"status": "complete","success": 0.32115942028985506,"std_success": 0.012581179370556922,"completed_seeds": null,"num_completed": 3,"best_config": null,"gain_vs_h16_policy": 0.02376811594202899},{"key": "retrieval_residual_knn4",5 unmodified lines"story_role": "pending KNN tangent proposal","fallback_success": null,"pending_job": "14857114/14857115/14857116","path_exists": true,"status": "complete","success": 0.2991304347826087,"std_success": 0.02005663059942746,"completed_seeds": null,"num_completed": 3,"best_config": null,"gain_vs_h16_policy": 0.001739130434782632},{"key": "near_miss_only_lattice",120 unmodified lines"Do not claim external SOTA from this table alone; add current external baselines separately.","Current best clean deployment row is Near-miss proposal policy + field at 32.93%.","Trust-region field optimization should be framed as a negative/diagnostic ablation.","Train-state counterfactual residual retrieval is a positive clean bridge but remains below the current clean best.","KNN counterfactual residual retrieval is a positive clean bridge but remains below the current clean best."]}
10 unmodified lines111213141516171819206 unmodified lines2728293031323310 unmodified lines| field_optim | Trust-region field optimization | complete k32_sigma0.50 | 25.39% | -4.35 pp | yes | no | no | differentiable field-ascent diagnostic || nonexpert_policy_bc5 | Best non-expert proposal policy | complete | 27.88% | -1.86 pp | yes | no | no | pending broader non-expert proposal model || nonexpert_policy_bc5_field | Best non-expert proposal policy + field | complete k64_sigma0.50 | 26.49% | -3.25 pp | yes | no | no | pending broader proposal-field bridge || retrieval_residual | Train-state counterfactual residual retrieval | pending 14857111/14857112/14857113 | pending | pending | yes | no | no | pending transferable local tangent proposal || retrieval_residual_knn4 | KNN counterfactual residual retrieval | pending 14857114/14857115/14857116 | pending | pending | yes | no | no | pending KNN tangent proposal || retrieval_residual_nearmiss | Train-state near-miss residual retrieval | pending 14857692/14857693/14857694 | pending | pending | yes | no | no | pending transferable near-miss tangent proposal || retrieval_residual_nearmiss_knn4 | KNN near-miss residual retrieval | pending 14857695/14857696/14857697 | pending | pending | yes | no | no | pending KNN near-miss tangent proposal || near_miss_only_lattice | Same-state lattice, near-miss only | complete | 55.94% | +26.20 pp | no | yes | no | minimal mechanism result || no_expert_lattice | Same-state lattice, no expert | complete | 56.99% | +27.25 pp | no | yes | no | main conservative mechanism result || no_near_miss_no_expert_lattice | Same-state lattice, no expert/no near-miss | complete | 25.57% | -4.17 pp | no | yes | no | mechanism knockout |6 unmodified lines- Do not claim external SOTA from this table alone; add current external baselines separately.- Current best clean deployment row is Near-miss proposal policy + field at 32.93%.- Trust-region field optimization should be framed as a negative/diagnostic ablation.- Train-state counterfactual residual retrieval is pending (14857111/14857112/14857113).- KNN counterfactual residual retrieval is pending (14857114/14857115/14857116).- Train-state near-miss residual retrieval is pending (14857692/14857693/14857694).- KNN near-miss residual retrieval is pending (14857695/14857696/14857697).10 unmodified lines11121314151617186 unmodified lines252627282910 unmodified lines| field_optim | Trust-region field optimization | complete k32_sigma0.50 | 25.39% | -4.35 pp | yes | no | no | differentiable field-ascent diagnostic || nonexpert_policy_bc5 | Best non-expert proposal policy | complete | 27.88% | -1.86 pp | yes | no | no | pending broader non-expert proposal model || nonexpert_policy_bc5_field | Best non-expert proposal policy + field | complete k64_sigma0.50 | 26.49% | -3.25 pp | yes | no | no | pending broader proposal-field bridge || retrieval_residual | Train-state counterfactual residual retrieval | complete | 32.12% | +2.38 pp | yes | no | no | pending transferable local tangent proposal || retrieval_residual_knn4 | KNN counterfactual residual retrieval | complete | 29.91% | +0.17 pp | yes | no | no | pending KNN tangent proposal || near_miss_only_lattice | Same-state lattice, near-miss only | complete | 55.94% | +26.20 pp | no | yes | no | minimal mechanism result || no_expert_lattice | Same-state lattice, no expert | complete | 56.99% | +27.25 pp | no | yes | no | main conservative mechanism result || no_near_miss_no_expert_lattice | Same-state lattice, no expert/no near-miss | complete | 25.57% | -4.17 pp | no | yes | no | mechanism knockout |6 unmodified lines- Do not claim external SOTA from this table alone; add current external baselines separately.- Current best clean deployment row is Near-miss proposal policy + field at 32.93%.- Trust-region field optimization should be framed as a negative/diagnostic ablation.- Train-state counterfactual residual retrieval is a positive clean bridge but remains below the current clean best.- KNN counterfactual residual retrieval is a positive clean bridge but remains below the current clean best.
95 unmodified lines96979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139147 unmodified lines2872882892902912922932942 unmodified lines29729829930030130295 unmodified linespending_job="14842574/14842577/14842617",),ResultSpec(key="retrieval_residual",label="Train-state counterfactual residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending transferable local tangent proposal",pending_job="14857111/14857112/14857113",),ResultSpec(key="retrieval_residual_knn4",label="KNN counterfactual residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_knn4_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending KNN tangent proposal",pending_job="14857114/14857115/14857116",),ResultSpec(key="retrieval_residual_nearmiss",label="Train-state near-miss residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_nearmiss_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending transferable near-miss tangent proposal",pending_job="14857692/14857693/14857694",),ResultSpec(key="retrieval_residual_nearmiss_knn4",label="KNN near-miss residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_nearmiss_knn4_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending KNN near-miss tangent proposal",pending_job="14857695/14857696/14857697",),ResultSpec(key="near_miss_only_lattice",147 unmodified lines"field_optim","retrieval_residual","retrieval_residual_knn4","retrieval_residual_nearmiss","retrieval_residual_nearmiss_knn4",):row = by_key[key]if row["success"] is None:2 unmodified linesnotes.append(f"{row['label']} is strong enough to promote as a clean bridge.")elif row["success"] > 0.3293:notes.append(f"{row['label']} improves the clean bridge but is not yet the main result.")else:notes.append(f"{row['label']} should be framed as a negative/diagnostic ablation.")return notes95 unmodified lines96979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139147 unmodified lines2872882892902912922 unmodified lines29529629729829930030130230330495 unmodified linespending_job="14842574/14842577/14842617",),ResultSpec(key="field_selected_noexpert_policy",label="Field-selected no-expert distillation policy",path="h16_policy_ckpt_field_selected_noexpert_bc5_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending student of field-on-lattice teacher",pending_job="14858327/14858328/14858329/14858330",),ResultSpec(key="field_selected_noexpert_policy_field",label="Field-selected no-expert distillation + field",path="h16_policy_ckpt_field_selected_noexpert_bc5_bestpt_field_sweep_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending student proposal with field scoring",pending_job="14858327/14858328/14858331/14858332",),ResultSpec(key="retrieval_residual",label="Train-state counterfactual residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending transferable local tangent proposal",pending_job="14857111/14857112/14857113",),ResultSpec(key="retrieval_residual_knn4",label="KNN counterfactual residual retrieval",path="h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_knn4_v2_summary.json",clean_deployment="yes",same_state_proposals="no",expert_proposal="no",story_role="pending KNN tangent proposal",pending_job="14857114/14857115/14857116",),ResultSpec(key="near_miss_only_lattice",147 unmodified lines"field_optim","retrieval_residual","retrieval_residual_knn4",):row = by_key[key]if row["success"] is None:2 unmodified linesnotes.append(f"{row['label']} is strong enough to promote as a clean bridge.")elif row["success"] > 0.3293:notes.append(f"{row['label']} improves the clean bridge but is not yet the main result.")elif row["success"] > BASELINE_H16_POLICY:notes.append(f"{row['label']} is a positive clean bridge but remains below the current clean best.")else:notes.append(f"{row['label']} should be framed as a negative/diagnostic ablation.")return notes
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159#!/usr/bin/env pythonfrom __future__ import annotations
import argparseimport jsonimport sysfrom pathlib import Pathfrom typing import Any
PROJECT_ROOT = Path(__file__).resolve().parents[1]if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT))
from dovla_cil.data.datasets import CILDataset # noqa: E402from dovla_cil.eval.lattice_eval import _validation_group_ids # noqa: E402from dovla_cil.eval.maniskill_policy_rollout import _numeric_action_values # noqa: E402from dovla_cil.models.dovla import ( # noqa: E402 DoVLAConfig, DoVLAModel, load_model_state, vectorize_toy_observation,)
def main(argv: list[str] | None = None) -> int: parser = argparse.ArgumentParser( description="Export policy BC targets chosen by a trained field on CIL action lattices." ) parser.add_argument("--checkpoint", type=Path, required=True) parser.add_argument("--dataset", type=Path, required=True) parser.add_argument("--out", type=Path, required=True) parser.add_argument("--device", default="auto") parser.add_argument("--split", choices=("train", "val", "all"), default="train") parser.add_argument("--batch-groups", type=int, default=32) parser.add_argument( "--exclude-types", default="expert", help="Comma-separated candidate_type values to exclude before field selection.", ) parser.add_argument("--max-groups", type=int, default=None) args = parser.parse_args(argv)
if args.batch_groups <= 0: parser.error("--batch-groups must be positive") if args.max_groups is not None and args.max_groups <= 0: parser.error("--max-groups must be positive when provided")
try: import torch except ImportError as exc: # pragma: no cover raise ImportError("export_field_selected_policy_targets.py requires torch") from exc
checkpoint = torch.load( args.checkpoint, map_location=_resolve_device(args.device), weights_only=False, ) model_config = DoVLAConfig(**checkpoint["model_config"]) if model_config.observation_mode != "state": raise ValueError("field-selected target export currently supports state observations only") device = _resolve_device(args.device) model = DoVLAModel(model_config).to(device) load_model_state(model, checkpoint) model.eval()
dataset = CILDataset(args.dataset) trainer_config = checkpoint.get("trainer_config", {}) val_ids = set( _validation_group_ids( dataset.group_ids, val_fraction=float(trainer_config.get("val_fraction", 0.2)), seed=int(trainer_config.get("seed", 0)), ) ) if args.split == "train": group_ids = [group_id for group_id in dataset.group_ids if group_id not in val_ids] elif args.split == "val": group_ids = [group_id for group_id in dataset.group_ids if group_id in val_ids] else: group_ids = list(dataset.group_ids) if args.max_groups is not None: group_ids = group_ids[: args.max_groups]
excluded = {item.strip() for item in args.exclude_types.split(",") if item.strip()} targets: dict[str, dict[str, Any]] = {} counts: dict[str, int] = {} with torch.no_grad(): for start in range(0, len(group_ids), args.batch_groups): for group_id in group_ids[start : start + args.batch_groups]: records = [ record for record in dataset.get_group(group_id) if record.candidate_type not in excluded ] if not records: records = dataset.get_group(group_id) if not records: continue obs = torch.tensor( [ vectorize_toy_observation( records[0].observation_inline or {}, obs_dim=model_config.obs_dim, ) ] * len(records), dtype=torch.float32, device=device, ) actions = torch.tensor( [_numeric_action_values(record) for record in records], dtype=torch.float32, device=device, ) field = model.forward_field( obs, [record.instruction for record in records], actions, ) best_idx = int(torch.argmax(field["potential"].reshape(len(records))).item()) best = records[best_idx] counts[best.candidate_type] = counts.get(best.candidate_type, 0) + 1 targets[group_id] = { "record_id": best.record_id, "candidate_type": best.candidate_type, "task_id": best.task_id, "score": float(best.reward.score), "rank_within_group": best.rank_within_group, }
payload = { "checkpoint": str(args.checkpoint), "dataset": str(args.dataset), "split": args.split, "excluded_candidate_types": sorted(excluded), "num_groups": len(group_ids), "num_targets": len(targets), "selected_candidate_type_counts": counts, "targets": targets, } args.out.parent.mkdir(parents=True, exist_ok=True) args.out.write_text(json.dumps(payload, indent=2) + "\n") print(json.dumps({k: v for k, v in payload.items() if k != "targets"}, indent=2)) print(f"Wrote {args.out}") return 0
def _resolve_device(device: str) -> str: if device != "auto": return device try: import torch except ImportError: # pragma: no cover return "cpu" return "cuda" if torch.cuda.is_available() else "cpu"
if __name__ == "__main__": raise SystemExit(main())25 unmodified lines26272829303118 unmodified lines5051525354556 unmodified lines62636465666725 unmodified linesRUN_ROOT="${RUN_ROOT:-$SCRATCH_ROOT/experiments/dovla_h16_policy_ckpt_runs}"OBJECTIVE="${OBJECTIVE:-base}"POLICY_TARGET_TYPES="${POLICY_TARGET_TYPES:-}"SEED=$SLURM_ARRAY_TASK_IDOUT_DIR="$RUN_ROOT/$OBJECTIVE/seed_$SEED"18 unmodified linesif [[ -n "$POLICY_TARGET_TYPES" ]]; thenTRAIN_EXTRA_ARGS+=(--policy-target-types "$POLICY_TARGET_TYPES")fiif [[ -n "${EXTRA_TRAIN_ARGS:-}" ]]; then# shellcheck disable=SC2206EXTRA_SPLIT=($EXTRA_TRAIN_ARGS)6 unmodified linesecho "Dataset: $DATASET"echo "Output: $OUT_DIR"echo "Policy target types: ${POLICY_TARGET_TYPES:-<best-any>}"echo "==================================================""${PYTHON_CMD[@]}" -c "25 unmodified lines2627282930313218 unmodified lines5152535455565758596 unmodified lines6667686970717225 unmodified linesRUN_ROOT="${RUN_ROOT:-$SCRATCH_ROOT/experiments/dovla_h16_policy_ckpt_runs}"OBJECTIVE="${OBJECTIVE:-base}"POLICY_TARGET_TYPES="${POLICY_TARGET_TYPES:-}"POLICY_TARGET_MAP="${POLICY_TARGET_MAP:-}"SEED=$SLURM_ARRAY_TASK_IDOUT_DIR="$RUN_ROOT/$OBJECTIVE/seed_$SEED"18 unmodified linesif [[ -n "$POLICY_TARGET_TYPES" ]]; thenTRAIN_EXTRA_ARGS+=(--policy-target-types "$POLICY_TARGET_TYPES")fiif [[ -n "$POLICY_TARGET_MAP" ]]; thenTRAIN_EXTRA_ARGS+=(--policy-target-map "$POLICY_TARGET_MAP")fiif [[ -n "${EXTRA_TRAIN_ARGS:-}" ]]; then# shellcheck disable=SC2206EXTRA_SPLIT=($EXTRA_TRAIN_ARGS)6 unmodified linesecho "Dataset: $DATASET"echo "Output: $OUT_DIR"echo "Policy target types: ${POLICY_TARGET_TYPES:-<best-any>}"echo "Policy target map: ${POLICY_TARGET_MAP:-<none>}"echo "==================================================""${PYTHON_CMD[@]}" -c "
84 unmodified lines85868788899038 unmodified lines12913013113213313484 unmodified lineshelp="Comma-separated candidate_type filter for policy BC targets. ""Empty means best action from every group.",)parser.add_argument("--loss-weight",action="append",38 unmodified linespolicy_target_types=tuple(item.strip() for item in args.policy_target_types.split(",") if item.strip()),losses=loss_weights,)result = DoVLATrainer(config).train()84 unmodified lines8586878889909192939495969738 unmodified lines13613713813914014114284 unmodified lineshelp="Comma-separated candidate_type filter for policy BC targets. ""Empty means best action from every group.",)parser.add_argument("--policy-target-map",type=Path,default=None,help="JSON mapping group_id to policy BC target record_id. Missing groups fall back ""to --policy-target-types or best-in-group.",)parser.add_argument("--loss-weight",action="append",38 unmodified linespolicy_target_types=tuple(item.strip() for item in args.policy_target_types.split(",") if item.strip()),policy_target_map=args.policy_target_map,losses=loss_weights,)result = DoVLATrainer(config).train()
140 unmodified lines141142143140 unmodified lines"g0": "near","g1": "fallback",}140 unmodified lines141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180140 unmodified lines"g0": "near","g1": "fallback",}def test_policy_target_map_overrides_group_target_with_fallback() -> None:records = [SimpleNamespace(group_id="g0",candidate_type="expert",reward=SimpleNamespace(score=2.0),rank_within_group=0,record_id="expert",),SimpleNamespace(group_id="g0",candidate_type="near_miss",reward=SimpleNamespace(score=1.5),rank_within_group=1,record_id="field_choice",),SimpleNamespace(group_id="g1",candidate_type="near_miss",reward=SimpleNamespace(score=0.7),rank_within_group=1,record_id="fallback",),]selected = _best_records_by_group(records,candidate_types=("near_miss",),target_record_ids={"g0": "field_choice"},)assert {record.group_id: record.record_id for record in selected} == {"g0": "field_choice","g1": "fallback",}
results/h16_policy_ckpt_near_miss_policy_bc5_bestpt_retrieval_residual_v2_summary.mdAdded+19
results/paper_core_results.md+12-8
results/paper_story_memo.md+19-21
results/paper_table_status.json+14-54
results/paper_table_status.md+4-8
scripts/build_paper_table_status.py+24-22
scripts/export_field_selected_policy_targets.pyAdded+159
scripts/slurm/train_dovla_h16_policy_ckpt.sbatch+5
scripts/train_dovla.py+8
tests/test_trainer.py+37