Auto-sync: 2026-06-30 02:40:05 (part 5)
Browse files
tests/test_maniskill_policy_rollout.py
CHANGED
|
@@ -97,6 +97,7 @@ def test_policy_rollout_summary_includes_candidate_oracle_when_present() -> None
|
|
| 97 |
"candidate_oracle_score": 1.8,
|
| 98 |
"candidate_oracle_regret": 0.2,
|
| 99 |
"candidate_oracle_score_gain_over_selected": 1.7,
|
|
|
|
| 100 |
"candidate_oracle_improves_selected": True,
|
| 101 |
"candidate_oracle_selected_branch_success": False,
|
| 102 |
"candidate_oracle_selected_branch_progress": 0.1,
|
|
@@ -117,6 +118,7 @@ def test_policy_rollout_summary_includes_candidate_oracle_when_present() -> None
|
|
| 117 |
"candidate_oracle_score": 1.9,
|
| 118 |
"candidate_oracle_regret": 0.0,
|
| 119 |
"candidate_oracle_score_gain_over_selected": 0.0,
|
|
|
|
| 120 |
"candidate_oracle_improves_selected": False,
|
| 121 |
"candidate_oracle_selected_branch_success": True,
|
| 122 |
"candidate_oracle_selected_branch_progress": 0.9,
|
|
@@ -130,6 +132,7 @@ def test_policy_rollout_summary_includes_candidate_oracle_when_present() -> None
|
|
| 130 |
assert summary["candidate_oracle_success_rate"] == 1.0
|
| 131 |
assert np.isclose(summary["candidate_oracle_progress"], 0.85)
|
| 132 |
assert np.isclose(summary["candidate_oracle_score_gain_over_selected"], 0.85)
|
|
|
|
| 133 |
assert summary["candidate_oracle_improvement_rate"] == 0.5
|
| 134 |
assert summary["candidate_oracle_restore_max_error"] == 3e-7
|
| 135 |
assert summary["candidate_oracle_type_counts"] == {
|
|
@@ -300,7 +303,7 @@ def test_candidate_oracle_prefix_keeps_deployed_candidate_first() -> None:
|
|
| 300 |
dtype=torch.float32,
|
| 301 |
)
|
| 302 |
|
| 303 |
-
indices = _diagnostic_candidate_indices(
|
| 304 |
potentials,
|
| 305 |
np.asarray([0, 1], dtype=np.int64),
|
| 306 |
candidate_oracle_rollouts=3,
|
|
@@ -308,6 +311,36 @@ def test_candidate_oracle_prefix_keeps_deployed_candidate_first() -> None:
|
|
| 308 |
)
|
| 309 |
|
| 310 |
assert indices.tolist() == [[0, 1, 2], [1, 2, 1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
|
| 313 |
def test_field_mode_scores_clamped_candidates() -> None:
|
|
|
|
| 97 |
"candidate_oracle_score": 1.8,
|
| 98 |
"candidate_oracle_regret": 0.2,
|
| 99 |
"candidate_oracle_score_gain_over_selected": 1.7,
|
| 100 |
+
"candidate_oracle_unique_count": 4,
|
| 101 |
"candidate_oracle_improves_selected": True,
|
| 102 |
"candidate_oracle_selected_branch_success": False,
|
| 103 |
"candidate_oracle_selected_branch_progress": 0.1,
|
|
|
|
| 118 |
"candidate_oracle_score": 1.9,
|
| 119 |
"candidate_oracle_regret": 0.0,
|
| 120 |
"candidate_oracle_score_gain_over_selected": 0.0,
|
| 121 |
+
"candidate_oracle_unique_count": 2,
|
| 122 |
"candidate_oracle_improves_selected": False,
|
| 123 |
"candidate_oracle_selected_branch_success": True,
|
| 124 |
"candidate_oracle_selected_branch_progress": 0.9,
|
|
|
|
| 132 |
assert summary["candidate_oracle_success_rate"] == 1.0
|
| 133 |
assert np.isclose(summary["candidate_oracle_progress"], 0.85)
|
| 134 |
assert np.isclose(summary["candidate_oracle_score_gain_over_selected"], 0.85)
|
| 135 |
+
assert summary["candidate_oracle_unique_count"] == 3.0
|
| 136 |
assert summary["candidate_oracle_improvement_rate"] == 0.5
|
| 137 |
assert summary["candidate_oracle_restore_max_error"] == 3e-7
|
| 138 |
assert summary["candidate_oracle_type_counts"] == {
|
|
|
|
| 303 |
dtype=torch.float32,
|
| 304 |
)
|
| 305 |
|
| 306 |
+
indices, valid = _diagnostic_candidate_indices(
|
| 307 |
potentials,
|
| 308 |
np.asarray([0, 1], dtype=np.int64),
|
| 309 |
candidate_oracle_rollouts=3,
|
|
|
|
| 311 |
)
|
| 312 |
|
| 313 |
assert indices.tolist() == [[0, 1, 2], [1, 2, 1]]
|
| 314 |
+
assert valid.tolist() == [[True, True, True], [True, True, False]]
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
def test_candidate_oracle_prefix_skips_duplicate_actions() -> None:
|
| 318 |
+
import torch
|
| 319 |
+
|
| 320 |
+
potentials = torch.tensor([[0.1, 0.5, 0.4, 0.3]], dtype=torch.float32)
|
| 321 |
+
actions = torch.tensor(
|
| 322 |
+
[
|
| 323 |
+
[
|
| 324 |
+
[[0.0]],
|
| 325 |
+
[[0.0]],
|
| 326 |
+
[[0.2]],
|
| 327 |
+
[[0.2 + 5.0e-7]],
|
| 328 |
+
]
|
| 329 |
+
],
|
| 330 |
+
dtype=torch.float32,
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
indices, valid = _diagnostic_candidate_indices(
|
| 334 |
+
potentials,
|
| 335 |
+
np.asarray([0], dtype=np.int64),
|
| 336 |
+
candidate_actions=actions,
|
| 337 |
+
candidate_oracle_rollouts=4,
|
| 338 |
+
unique_tolerance=1.0e-6,
|
| 339 |
+
torch=torch,
|
| 340 |
+
)
|
| 341 |
+
|
| 342 |
+
assert indices.tolist() == [[0, 2, 0, 0]]
|
| 343 |
+
assert valid.tolist() == [[True, True, False, False]]
|
| 344 |
|
| 345 |
|
| 346 |
def test_field_mode_scores_clamped_candidates() -> None:
|