Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions open_instruct/vllm_utils3.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,30 @@ def __init__(
self.eval_results_queue = eval_results_queue
self.actor_manager = actor_manager

# For caching should_stop status.
self._last_should_stop_update = float("-inf")
self._should_stop_value = False
self._should_stop_timeout_s = 5

def _should_stop(self) -> bool:
if (time.perf_counter() - self._last_should_stop_update) > self._should_stop_timeout_s:
should_stop_ref = self.actor_manager.should_stop.remote()
ready_refs, _ = ray.wait([should_stop_ref], timeout=0.1)
if ready_refs:
self._should_stop_value = ray.get(ready_refs[0])
self._last_should_stop_update = time.perf_counter()
else:
ray.cancel(should_stop_ref)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think its worth adding some logging here? It seems like if the actor manager doesn't return at all / times out for this call its a sign something is a bit off.

return self._should_stop_value

def process_from_queue(self, timeout: float = 60.0):
"""Run generation loop using LLMEngine directly, with optional tool support.

Returns:
int: Number of requests processed (0 or 1)
"""
while True:
# Non-blocking check for should_stop using ray.wait
should_stop_ref = self.actor_manager.should_stop.remote()
ready_refs, _ = ray.wait([should_stop_ref], timeout=0.1)
if ready_refs and ray.get(ready_refs[0]):
if self._should_stop():
return 0

try:
Expand Down