Auto-sync: 2026-06-30 15:00:21 (part 4)
Browse files
tests/test_maniskill_policy_rollout.py
CHANGED
|
@@ -26,12 +26,14 @@ from dovla_cil.eval.maniskill_policy_rollout import (
|
|
| 26 |
_lattice_candidate_mask,
|
| 27 |
_lattice_candidate_type_bonus,
|
| 28 |
_load_state_archive,
|
|
|
|
| 29 |
_numeric_action_values,
|
| 30 |
_reduce_residual_candidates_by_type,
|
| 31 |
_select_action_chunk,
|
| 32 |
_selected_candidate_type,
|
| 33 |
_selected_residual_scale,
|
| 34 |
_summarize_rows,
|
|
|
|
| 35 |
_task_limited_challenger_mask,
|
| 36 |
)
|
| 37 |
|
|
@@ -675,6 +677,19 @@ def test_lattice_candidate_include_mask_uses_exact_candidate_types() -> None:
|
|
| 675 |
assert mask.tolist() == [[False, True, False]]
|
| 676 |
|
| 677 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 678 |
def test_task_limited_challenger_mask_respects_task_gate() -> None:
|
| 679 |
import torch
|
| 680 |
|
|
@@ -719,6 +734,66 @@ def test_task_limited_challenger_mask_respects_task_gate() -> None:
|
|
| 719 |
assert unrestricted.tolist() == [[False, True, True, False]]
|
| 720 |
|
| 721 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
def test_expand_residual_lattice_mask_can_limit_challenger_scales() -> None:
|
| 723 |
import torch
|
| 724 |
|
|
|
|
| 26 |
_lattice_candidate_mask,
|
| 27 |
_lattice_candidate_type_bonus,
|
| 28 |
_load_state_archive,
|
| 29 |
+
_normalize_residual_candidate_type_name,
|
| 30 |
_numeric_action_values,
|
| 31 |
_reduce_residual_candidates_by_type,
|
| 32 |
_select_action_chunk,
|
| 33 |
_selected_candidate_type,
|
| 34 |
_selected_residual_scale,
|
| 35 |
_summarize_rows,
|
| 36 |
+
_task_limited_exclude_types,
|
| 37 |
_task_limited_challenger_mask,
|
| 38 |
)
|
| 39 |
|
|
|
|
| 677 |
assert mask.tolist() == [[False, True, False]]
|
| 678 |
|
| 679 |
|
| 680 |
+
def test_residual_candidate_type_normalizer_accepts_shorthand() -> None:
|
| 681 |
+
assert _normalize_residual_candidate_type_name("near_miss") == "residual_near_miss"
|
| 682 |
+
assert _normalize_residual_candidate_type_name("policy") == "policy_residual"
|
| 683 |
+
assert (
|
| 684 |
+
_normalize_residual_candidate_type_name("retrieval_residual_residual_no_op")
|
| 685 |
+
== "residual_no_op"
|
| 686 |
+
)
|
| 687 |
+
assert (
|
| 688 |
+
_normalize_residual_candidate_type_name("near_miss+no_op")
|
| 689 |
+
== "residual_near_miss+residual_no_op"
|
| 690 |
+
)
|
| 691 |
+
|
| 692 |
+
|
| 693 |
def test_task_limited_challenger_mask_respects_task_gate() -> None:
|
| 694 |
import torch
|
| 695 |
|
|
|
|
| 734 |
assert unrestricted.tolist() == [[False, True, True, False]]
|
| 735 |
|
| 736 |
|
| 737 |
+
def test_task_limited_challenger_mask_can_limit_individual_types() -> None:
|
| 738 |
+
import torch
|
| 739 |
+
|
| 740 |
+
case = SimpleNamespace(
|
| 741 |
+
candidate_types=[
|
| 742 |
+
"policy_residual",
|
| 743 |
+
"residual_near_miss",
|
| 744 |
+
"residual_wrong_gripper",
|
| 745 |
+
"residual_near_miss+residual_wrong_gripper",
|
| 746 |
+
]
|
| 747 |
+
)
|
| 748 |
+
|
| 749 |
+
pick_mask = _task_limited_challenger_mask(
|
| 750 |
+
[case],
|
| 751 |
+
task_id="PickCube-v1",
|
| 752 |
+
torch=torch,
|
| 753 |
+
device="cpu",
|
| 754 |
+
include_types=("near_miss", "wrong_gripper"),
|
| 755 |
+
include_tasks=(),
|
| 756 |
+
include_type_tasks={"wrong_gripper": ("PickCube-v1", "PullCube-v1")},
|
| 757 |
+
)
|
| 758 |
+
lift_mask = _task_limited_challenger_mask(
|
| 759 |
+
[case],
|
| 760 |
+
task_id="LiftPegUpright-v1",
|
| 761 |
+
torch=torch,
|
| 762 |
+
device="cpu",
|
| 763 |
+
include_types=("near_miss", "wrong_gripper"),
|
| 764 |
+
include_tasks=(),
|
| 765 |
+
include_type_tasks={"wrong_gripper": ("PickCube-v1", "PullCube-v1")},
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
assert pick_mask is not None
|
| 769 |
+
assert lift_mask is not None
|
| 770 |
+
assert pick_mask.tolist() == [[False, True, True, False]]
|
| 771 |
+
assert lift_mask.tolist() == [[False, True, False, False]]
|
| 772 |
+
|
| 773 |
+
|
| 774 |
+
def test_task_limited_exclude_types_adds_task_specific_components() -> None:
|
| 775 |
+
base = ("residual_random_negative", "residual_wrong_direction")
|
| 776 |
+
mapping = {"residual_wrong_gripper": ("StackCube-v1",)}
|
| 777 |
+
|
| 778 |
+
stack_excludes = _task_limited_exclude_types(
|
| 779 |
+
base,
|
| 780 |
+
task_id="StackCube-v1",
|
| 781 |
+
exclude_type_tasks=mapping,
|
| 782 |
+
)
|
| 783 |
+
pick_excludes = _task_limited_exclude_types(
|
| 784 |
+
base,
|
| 785 |
+
task_id="PickCube-v1",
|
| 786 |
+
exclude_type_tasks=mapping,
|
| 787 |
+
)
|
| 788 |
+
|
| 789 |
+
assert stack_excludes == (
|
| 790 |
+
"residual_random_negative",
|
| 791 |
+
"residual_wrong_direction",
|
| 792 |
+
"residual_wrong_gripper",
|
| 793 |
+
)
|
| 794 |
+
assert pick_excludes == base
|
| 795 |
+
|
| 796 |
+
|
| 797 |
def test_expand_residual_lattice_mask_can_limit_challenger_scales() -> None:
|
| 798 |
import torch
|
| 799 |
|