anhtld commited on
Commit
a25d8fa
·
verified ·
1 Parent(s): 3fd10a8

Auto-sync: 2026-06-27 10:45:23 (part 2)

Browse files
scripts/slurm/train_dovla_h16_policy_ckpt.sbatch CHANGED
@@ -25,6 +25,7 @@ CONTAINER_PYTHON="${PYTHON:-$SCRATCH_ROOT/envs/maniskill/bin/python}"
25
  DATASET="${DATASET:-$SCRATCH_ROOT/experiments/h16_merged_dataset}"
26
  RUN_ROOT="${RUN_ROOT:-$SCRATCH_ROOT/experiments/dovla_h16_policy_ckpt_runs}"
27
  OBJECTIVE="${OBJECTIVE:-base}"
 
28
  SEED=$SLURM_ARRAY_TASK_ID
29
  OUT_DIR="$RUN_ROOT/$OBJECTIVE/seed_$SEED"
30
 
@@ -45,11 +46,22 @@ PYTHON_CMD=(
45
  "$SIF" "$CONTAINER_PYTHON"
46
  )
47
 
 
 
 
 
 
 
 
 
 
 
48
  echo "=================================================="
49
  echo "Train DoVLAModel h=16 with best_policy checkpoint"
50
  echo "Seed: $SEED"
51
  echo "Dataset: $DATASET"
52
  echo "Output: $OUT_DIR"
 
53
  echo "=================================================="
54
 
55
  "${PYTHON_CMD[@]}" -c "
@@ -77,7 +89,8 @@ assert len(ds.group_ids) == 2873
77
  --lr 0.001 \
78
  --device cuda \
79
  --seed "$SEED" \
80
- --objective lattice_field
 
81
 
82
  test -f "$OUT_DIR/best.pt"
83
  test -f "$OUT_DIR/best_policy.pt"
 
25
  DATASET="${DATASET:-$SCRATCH_ROOT/experiments/h16_merged_dataset}"
26
  RUN_ROOT="${RUN_ROOT:-$SCRATCH_ROOT/experiments/dovla_h16_policy_ckpt_runs}"
27
  OBJECTIVE="${OBJECTIVE:-base}"
28
+ POLICY_TARGET_TYPES="${POLICY_TARGET_TYPES:-}"
29
  SEED=$SLURM_ARRAY_TASK_ID
30
  OUT_DIR="$RUN_ROOT/$OBJECTIVE/seed_$SEED"
31
 
 
46
  "$SIF" "$CONTAINER_PYTHON"
47
  )
48
 
49
+ TRAIN_EXTRA_ARGS=()
50
+ if [[ -n "$POLICY_TARGET_TYPES" ]]; then
51
+ TRAIN_EXTRA_ARGS+=(--policy-target-types "$POLICY_TARGET_TYPES")
52
+ fi
53
+ if [[ -n "${EXTRA_TRAIN_ARGS:-}" ]]; then
54
+ # shellcheck disable=SC2206
55
+ EXTRA_SPLIT=($EXTRA_TRAIN_ARGS)
56
+ TRAIN_EXTRA_ARGS+=("${EXTRA_SPLIT[@]}")
57
+ fi
58
+
59
  echo "=================================================="
60
  echo "Train DoVLAModel h=16 with best_policy checkpoint"
61
  echo "Seed: $SEED"
62
  echo "Dataset: $DATASET"
63
  echo "Output: $OUT_DIR"
64
+ echo "Policy target types: ${POLICY_TARGET_TYPES:-<best-any>}"
65
  echo "=================================================="
66
 
67
  "${PYTHON_CMD[@]}" -c "
 
89
  --lr 0.001 \
90
  --device cuda \
91
  --seed "$SEED" \
92
+ --objective lattice_field \
93
+ "${TRAIN_EXTRA_ARGS[@]}"
94
 
95
  test -f "$OUT_DIR/best.pt"
96
  test -f "$OUT_DIR/best_policy.pt"
scripts/train_dovla.py CHANGED
@@ -79,6 +79,12 @@ def main(argv: list[str] | None = None) -> int:
79
  default="same_state",
80
  help="Choose whether legacy ranking pairs share the exact simulator state.",
81
  )
 
 
 
 
 
 
82
  parser.add_argument(
83
  "--loss-weight",
84
  action="append",
@@ -120,6 +126,9 @@ def main(argv: list[str] | None = None) -> int:
120
  objective=args.objective,
121
  lattice_neighbors=args.lattice_neighbors,
122
  pair_scope=args.pair_scope,
 
 
 
123
  losses=loss_weights,
124
  )
125
  result = DoVLATrainer(config).train()
 
79
  default="same_state",
80
  help="Choose whether legacy ranking pairs share the exact simulator state.",
81
  )
82
+ parser.add_argument(
83
+ "--policy-target-types",
84
+ default="",
85
+ help="Comma-separated candidate_type filter for policy BC targets. "
86
+ "Empty means best action from every group.",
87
+ )
88
  parser.add_argument(
89
  "--loss-weight",
90
  action="append",
 
126
  objective=args.objective,
127
  lattice_neighbors=args.lattice_neighbors,
128
  pair_scope=args.pair_scope,
129
+ policy_target_types=tuple(
130
+ item.strip() for item in args.policy_target_types.split(",") if item.strip()
131
+ ),
132
  losses=loss_weights,
133
  )
134
  result = DoVLATrainer(config).train()
tests/test_trainer.py CHANGED
@@ -9,6 +9,7 @@ from dovla_cil.tasks.library import built_in_toy_tasks
9
  from dovla_cil.training.trainer import (
10
  DoVLATrainer,
11
  TrainerConfig,
 
12
  _cross_state_pair_indices,
13
  _reward_utility_values,
14
  )
@@ -107,3 +108,36 @@ def test_cross_state_scope_rejects_lattice_field_objective(tmp_path: Path) -> No
107
  raise AssertionError(
108
  "cross-state pairs cannot silently leave same-state field edges active"
109
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  from dovla_cil.training.trainer import (
10
  DoVLATrainer,
11
  TrainerConfig,
12
+ _best_records_by_group,
13
  _cross_state_pair_indices,
14
  _reward_utility_values,
15
  )
 
108
  raise AssertionError(
109
  "cross-state pairs cannot silently leave same-state field edges active"
110
  )
111
+
112
+
113
+ def test_policy_target_type_filter_selects_best_allowed_candidate() -> None:
114
+ records = [
115
+ SimpleNamespace(
116
+ group_id="g0",
117
+ candidate_type="expert",
118
+ reward=SimpleNamespace(score=2.0),
119
+ rank_within_group=0,
120
+ record_id="expert",
121
+ ),
122
+ SimpleNamespace(
123
+ group_id="g0",
124
+ candidate_type="near_miss",
125
+ reward=SimpleNamespace(score=1.5),
126
+ rank_within_group=1,
127
+ record_id="near",
128
+ ),
129
+ SimpleNamespace(
130
+ group_id="g1",
131
+ candidate_type="expert",
132
+ reward=SimpleNamespace(score=1.0),
133
+ rank_within_group=0,
134
+ record_id="fallback",
135
+ ),
136
+ ]
137
+
138
+ selected = _best_records_by_group(records, candidate_types=("near_miss",))
139
+
140
+ assert {record.group_id: record.record_id for record in selected} == {
141
+ "g0": "near",
142
+ "g1": "fallback",
143
+ }