-
Notifications
You must be signed in to change notification settings - Fork 147
Weaken num_new_engines into has_new_engines #938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rollout_ft/20
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,7 +33,8 @@ class ServerGroup: | |||||||||||||||||||||||||||
| pg: Any # (placement_group, reordered_bundle_indices, reordered_gpu_ids) | ||||||||||||||||||||||||||||
| all_engines: list | ||||||||||||||||||||||||||||
| num_gpus_per_engine: int | ||||||||||||||||||||||||||||
| num_new_engines: int | ||||||||||||||||||||||||||||
| # NOTE: this may have risk when recovering engines parallelly; may use source of truth (all_engines) later | ||||||||||||||||||||||||||||
| has_new_engines: bool | ||||||||||||||||||||||||||||
| worker_type: str = "regular" # "regular", "prefill", or "decode" | ||||||||||||||||||||||||||||
| rank_offset: int = 0 | ||||||||||||||||||||||||||||
| gpu_offset: int = 0 | ||||||||||||||||||||||||||||
|
|
@@ -53,15 +54,15 @@ def engines(self): | |||||||||||||||||||||||||||
| """Node-0 engines only (for multi-node serving).""" | ||||||||||||||||||||||||||||
| return self.all_engines[:: self.nodes_per_engine] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| def start_engines(self, port_cursors: PortCursors) -> list: | ||||||||||||||||||||||||||||
| def start_engines(self, port_cursors: PortCursors) -> tuple[list, int]: | ||||||||||||||||||||||||||||
| """Create Ray actors, allocate ports, and fire ``engine.init()`` without waiting. | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Returns ``(init_handles, port_cursors)`` where *init_handles* is a list | ||||||||||||||||||||||||||||
| Returns ``(init_handles, curr_num_new_engines)`` where *init_handles* is a list | ||||||||||||||||||||||||||||
| of Ray ObjectRefs and *port_cursors* maps node index -> next free port. | ||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||
|
Comment on lines
+57
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstring for
Suggested change
|
||||||||||||||||||||||||||||
| if self.args.debug_train_only or self.worker_type == "placeholder": | ||||||||||||||||||||||||||||
| self.num_new_engines = 0 | ||||||||||||||||||||||||||||
| return [] | ||||||||||||||||||||||||||||
| self.has_new_engines = False | ||||||||||||||||||||||||||||
| return [], 0 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| num_gpu_per_engine = min(self.num_gpus_per_engine, self.args.num_gpus_per_node) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -120,10 +121,11 @@ def start_engines(self, port_cursors: PortCursors) -> list: | |||||||||||||||||||||||||||
| new_engines.append((global_rank, rollout_engine)) | ||||||||||||||||||||||||||||
| self.all_engines[i] = rollout_engine | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| self.num_new_engines = len(new_engines) | ||||||||||||||||||||||||||||
| curr_num_new_engines = len(new_engines) | ||||||||||||||||||||||||||||
| self.has_new_engines |= curr_num_new_engines > 0 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if self.num_new_engines == 0: | ||||||||||||||||||||||||||||
| return [] | ||||||||||||||||||||||||||||
| if curr_num_new_engines == 0: | ||||||||||||||||||||||||||||
| return [], 0 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if self.args.rollout_external: | ||||||||||||||||||||||||||||
| addr_and_ports = allocate_rollout_engine_addr_and_ports_external( | ||||||||||||||||||||||||||||
|
|
@@ -149,7 +151,7 @@ def start_engines(self, port_cursors: PortCursors) -> list: | |||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| for index, engine in new_engines | ||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||
| return init_handles | ||||||||||||||||||||||||||||
| return init_handles, curr_num_new_engines | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| def stop_engines(self, rollout_engine_id: int): | ||||||||||||||||||||||||||||
| logger.info(f"Killing server group {rollout_engine_id}...") | ||||||||||||||||||||||||||||
|
|
@@ -173,12 +175,13 @@ def stop_engines(self, rollout_engine_id: int): | |||||||||||||||||||||||||||
| async def recover(self, port_cursors: PortCursors): | ||||||||||||||||||||||||||||
| dead_indices = [i for i, engine in enumerate(self.all_engines) if engine is None] | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await asyncio.gather(*self.start_engines(port_cursors)) | ||||||||||||||||||||||||||||
| handles, curr_num_new_engines = self.start_engines(port_cursors) | ||||||||||||||||||||||||||||
| await asyncio.gather(*handles) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| release_handles = [] | ||||||||||||||||||||||||||||
| all_resume_engines = [] | ||||||||||||||||||||||||||||
| logger.info(f"Recovered {self.num_new_engines} dead rollout engines (worker_type={self.worker_type})") | ||||||||||||||||||||||||||||
| assert self.num_new_engines == len(dead_indices), "num_new_engines does not match dead_indices length" | ||||||||||||||||||||||||||||
| logger.info(f"Recovered {curr_num_new_engines} dead rollout engines (worker_type={self.worker_type})") | ||||||||||||||||||||||||||||
| assert curr_num_new_engines == len(dead_indices), "curr_num_new_engines does not match dead_indices length" | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assertion message still refers to
Suggested change
|
||||||||||||||||||||||||||||
| if self.needs_offload and dead_indices: | ||||||||||||||||||||||||||||
| new_engines = [self.all_engines[i] for i in dead_indices] | ||||||||||||||||||||||||||||
| release_handles.extend(engine.release_memory_occupation.remote() for engine in new_engines) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 199 still refers to
num_new_engines. It should be updated tohas_new_enginesto reflect the recent changes.