Auto-sync: 2026-06-28 23:11:20 (part 3)
Browse files
scripts/slurm/smoke_retrieval_metric_unit.sbatch
CHANGED
|
@@ -171,10 +171,83 @@ case_task_relative = _RolloutCase(
|
|
| 171 |
retrieval_metric="task_relative",
|
| 172 |
)
|
| 173 |
assert task_relative_attached.candidate_source_group_id == "train_actor_match", task_relative_attached
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
print({
|
| 175 |
"status": "ok",
|
| 176 |
"raw": raw_attached.candidate_source_group_id,
|
| 177 |
"zscore": zscore_attached.candidate_source_group_id,
|
| 178 |
"task_relative": task_relative_attached.candidate_source_group_id,
|
|
|
|
| 179 |
})
|
| 180 |
PY
|
|
|
|
| 171 |
retrieval_metric="task_relative",
|
| 172 |
)
|
| 173 |
assert task_relative_attached.candidate_source_group_id == "train_actor_match", task_relative_attached
|
| 174 |
+
|
| 175 |
+
def record_progress(group_id, candidate_type, action_value, progress, feature):
|
| 176 |
+
return SimpleNamespace(
|
| 177 |
+
group_id=group_id,
|
| 178 |
+
task_id="PickCube-v1",
|
| 179 |
+
candidate_type=candidate_type,
|
| 180 |
+
record_id=f"{group_id}-{candidate_type}-{action_value}",
|
| 181 |
+
observation_inline={"features": feature},
|
| 182 |
+
reward=SimpleNamespace(progress=progress, terminal_success=progress >= 1.0),
|
| 183 |
+
action_chunk=ActionChunk(
|
| 184 |
+
representation="continuous",
|
| 185 |
+
horizon=1,
|
| 186 |
+
values=[[action_value, 0.0]],
|
| 187 |
+
),
|
| 188 |
+
)
|
| 189 |
+
|
| 190 |
+
groups_progress = {
|
| 191 |
+
"train_a": [
|
| 192 |
+
record_progress("train_a", "expert", 1.0, 1.0, [0.0, 0.0]),
|
| 193 |
+
record_progress("train_a", "no_op", 1.2, 0.8, [0.0, 0.0]),
|
| 194 |
+
record_progress("train_a", "wrong_gripper", 1.4, 0.2, [0.0, 0.0]),
|
| 195 |
+
],
|
| 196 |
+
"train_b": [
|
| 197 |
+
record_progress("train_b", "expert", 2.0, 1.0, [10.0, 0.0]),
|
| 198 |
+
record_progress("train_b", "no_op", 2.2, 0.8, [10.0, 0.0]),
|
| 199 |
+
record_progress("train_b", "wrong_gripper", 2.4, 0.8, [10.0, 0.0]),
|
| 200 |
+
],
|
| 201 |
+
"heldout_a": [record_progress("heldout_a", "expert", 9.0, 1.0, [0.0, 0.0])],
|
| 202 |
+
"heldout_b": [record_progress("heldout_b", "expert", 9.0, 1.0, [10.0, 0.0])],
|
| 203 |
+
}
|
| 204 |
+
dataset_progress = SimpleNamespace(
|
| 205 |
+
group_ids=list(groups_progress),
|
| 206 |
+
get_group=lambda group_id: groups_progress[group_id],
|
| 207 |
+
)
|
| 208 |
+
progress_cases = [
|
| 209 |
+
_RolloutCase(
|
| 210 |
+
group_id=group_id,
|
| 211 |
+
task_id="PickCube-v1",
|
| 212 |
+
source_dataset=Path("."),
|
| 213 |
+
state={},
|
| 214 |
+
observation={"features": feature},
|
| 215 |
+
instruction="pick",
|
| 216 |
+
oracle_score=1.0,
|
| 217 |
+
oracle_success=True,
|
| 218 |
+
expert_score=1.0,
|
| 219 |
+
expert_success=True,
|
| 220 |
+
best_action_values=[[9.9, 0.0]],
|
| 221 |
+
candidate_action_values=[],
|
| 222 |
+
candidate_types=[],
|
| 223 |
+
)
|
| 224 |
+
for group_id, feature in [("heldout_a", [0.0, 0.0]), ("heldout_b", [10.0, 0.0])]
|
| 225 |
+
]
|
| 226 |
+
progress_attached = _attach_retrieved_residual_candidates(
|
| 227 |
+
dataset_progress,
|
| 228 |
+
progress_cases,
|
| 229 |
+
heldout_group_ids=["heldout_a", "heldout_b"],
|
| 230 |
+
obs_dim=2,
|
| 231 |
+
observation_mode="state",
|
| 232 |
+
retrieval_neighbors=1,
|
| 233 |
+
retrieval_residual_min_source_progress=0.5,
|
| 234 |
+
)
|
| 235 |
+
assert [len(case.candidate_action_values) for case in progress_attached] == [3, 3], progress_attached
|
| 236 |
+
assert progress_attached[0].candidate_types == [
|
| 237 |
+
"policy_residual",
|
| 238 |
+
"residual_no_op",
|
| 239 |
+
"policy_residual",
|
| 240 |
+
], progress_attached[0].candidate_types
|
| 241 |
+
assert progress_attached[1].candidate_types == [
|
| 242 |
+
"policy_residual",
|
| 243 |
+
"residual_no_op",
|
| 244 |
+
"residual_wrong_gripper",
|
| 245 |
+
], progress_attached[1].candidate_types
|
| 246 |
print({
|
| 247 |
"status": "ok",
|
| 248 |
"raw": raw_attached.candidate_source_group_id,
|
| 249 |
"zscore": zscore_attached.candidate_source_group_id,
|
| 250 |
"task_relative": task_relative_attached.candidate_source_group_id,
|
| 251 |
+
"source_progress_lengths": [len(case.candidate_action_values) for case in progress_attached],
|
| 252 |
})
|
| 253 |
PY
|