MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / explorer_monkey_patch

Function explorer_monkey_patch

tests/manager/synchronizer_test.py:51–81  ·  view source on GitHub ↗
(explore_step_time_list: List[int])

Source from the content-addressed store, hash-verified

49
50
51def explorer_monkey_patch(explore_step_time_list: List[int]):
52 async def new_explore_step(self: Explorer):
53 if self.explore_step_num >= len(explore_step_time_list):
54 await self.finish_current_steps()
55 await self.save_checkpoint()
56 await self.synchronizer.set_explorer_status.remote(
57 RunningStatus.STOPPED,
58 old_status=RunningStatus.RUNNING,
59 )
60 await self.shutdown()
61 return False
62 self.explore_step_num += 1
63 return True
64
65 async def new_finish_explore_step(self: Explorer, step: int) -> None:
66 metric = {"rollout/model_version": self.model_version}
67 await asyncio.sleep(explore_step_time_list[step - 1])
68 dummy_exps = [
69 Experience(
70 tokens=torch.tensor([0, 1, 2]),
71 info={"model_version": self.model_version},
72 )
73 for _ in range(self.config.buffer.train_batch_size)
74 ]
75 await self.rollout_coordinator.process_experiences.remote(
76 [Experience.serialize_many(dummy_exps)]
77 )
78 self.monitor.log(metric, step=step)
79
80 Explorer.explore_step = new_explore_step
81 Explorer._finish_explore_step = new_finish_explore_step
82
83
84def run_trainer(config: Config, train_step_time_list: List[int]) -> None:

Callers 2

run_explorerFunction · 0.85
run_bothFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected