Skip to content
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

Better tp exit log. #2677

Merged
merged 2 commits into from
Nov 4, 2024
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
15 changes: 11 additions & 4 deletions lmdeploy/pytorch/engine/model_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,22 @@ def _start_tp_process(proc_id: int,
def _check_context_alive(mp_context: mp.ProcessContext):
"""check context alive."""
procs: List[mp.Process] = mp_context.processes
failed_ranks = list(idx for idx, p in enumerate(procs) if not p.is_alive())
if len(failed_ranks) == 0:
failed_procs = list(idx for idx, p in enumerate(procs) if not p.is_alive())
if len(failed_procs) == 0:
return
for p in procs:

log_procs = []
for idx, p in enumerate(procs):
if p.is_alive():
p.terminate()
else:
exitcode = p.exitcode
if exitcode > 0:
# terminated exitcode < 0
log_procs.append((idx, exitcode))
p.close()
logger.error(f'TP process {failed_ranks} failed.')
for idx, exitcode in log_procs:
logger.error(f'TP process {idx} failed with exitcode {exitcode}.')
# TODO: not safe exit.
os._exit(1)

Expand Down
Loading