anhtld commited on
Commit
3bcf6fb
·
verified ·
1 Parent(s): 48fd163

Auto-sync: 2026-06-30 09:56:41 (part 3)

Browse files
tests/test_maniskill_policy_rollout.py CHANGED
@@ -226,10 +226,14 @@ class _StubModel:
226
  distance = ((action - target) ** 2).reshape(action.shape[0], -1).sum(dim=1)
227
  return {"potential": -distance}
228
 
229
- def forward_proposals(self, observation, instruction):
230
  del observation, instruction
231
  if self._proposals is None:
232
  raise AssertionError("stub proposals were not configured")
 
 
 
 
233
  return self._proposals
234
 
235
 
@@ -318,6 +322,30 @@ def test_proposal_lattice_mode_scores_model_generated_proposals() -> None:
318
  assert index.tolist() == [1]
319
 
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  def test_retrieval_residual_margin_can_abstain_to_policy() -> None:
322
  import torch
323
 
 
226
  distance = ((action - target) ** 2).reshape(action.shape[0], -1).sum(dim=1)
227
  return {"potential": -distance}
228
 
229
+ def forward_proposals(self, observation, instruction, proposal_types=None):
230
  del observation, instruction
231
  if self._proposals is None:
232
  raise AssertionError("stub proposals were not configured")
233
+ if proposal_types:
234
+ # Test stubs use proposal type names p0/p1/... to request a subset.
235
+ indices = [int(str(proposal_type)[1:]) for proposal_type in proposal_types]
236
+ return self._proposals[:, indices]
237
  return self._proposals
238
 
239
 
 
322
  assert index.tolist() == [1]
323
 
324
 
325
+ def test_proposal_lattice_mode_can_request_type_subset() -> None:
326
+ import torch
327
+
328
+ mean = torch.zeros(1, 1, 2)
329
+ proposals = torch.tensor([[[[0.1, 0.0]], [[0.4, 0.4]], [[0.0, 0.1]]]], dtype=torch.float32)
330
+ offset = torch.tensor([[[0.4, 0.4]]], dtype=torch.float32)
331
+ model = _StubModel(torch, mean, best_offset=offset, proposals=proposals)
332
+
333
+ actions, index = _select_action_chunk(
334
+ model,
335
+ observations=torch.zeros(1, 3),
336
+ instructions=["a"],
337
+ torch=torch,
338
+ selection_mode="proposal_lattice",
339
+ num_candidates=1,
340
+ candidate_sigma=0.0,
341
+ selection_seed=0,
342
+ proposal_lattice_types=("p0", "p2"),
343
+ )
344
+
345
+ assert torch.allclose(actions, proposals[:, 0])
346
+ assert index.tolist() == [0]
347
+
348
+
349
  def test_retrieval_residual_margin_can_abstain_to_policy() -> None:
350
  import torch
351