lm-sys / lm-sys/FastChat

Why is controller's heart beat thread daemon set to False?

Open
#3,089 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.5k
Forks
4.8k
PR merge metrics
No merged PRs in 30d

Description

Setup:
OS: Ubuntu 22.04.3 LTS
Python: Python 3.10.12
FastChat version: 0.2.36

--
I am using FastChat to run local LLMs. I am trying to run the following command:

python -m fastchat.serve.controller

I get the following logs:

2024-02-25 22:08:38 | INFO | controller | args: Namespace(host='localhost', port=21001, dispatch_method='shortest_queue', ssl=False)
2024-02-25 22:08:38 | ERROR | stderr | INFO:     Started server process [15985]
2024-02-25 22:08:38 | ERROR | stderr | INFO:     Waiting for application startup.
2024-02-25 22:08:38 | ERROR | stderr | INFO:     Application startup complete.
2024-02-25 22:08:38 | ERROR | stderr | INFO:     Uvicorn running on http://localhost:21001 (Press CTRL+C to quit)

When I interrupt the process once, I get the following logs:

2024-02-25 22:09:55 | ERROR | stderr | INFO:     Shutting down
2024-02-25 22:09:55 | ERROR | stderr | INFO:     Waiting for application shutdown.
2024-02-25 22:09:55 | ERROR | stderr | INFO:     Application shutdown complete.
2024-02-25 22:09:55 | ERROR | stderr | INFO:     Finished server process [15985]

However, the process continues to run nonetheless. I believe that this is because the heart_beat_thread defined in controller.py continues to run as daemon is set to False.

self.heart_beat_thread = threading.Thread(
    target=heart_beat_controller, args=(self,)
)

Is this an intended behavior? If so, why? Is there a better way to terminate the controller thread?

For information, here are the logs that I get when I interrupt a second time:

2024-02-25 22:10:38 | ERROR | stderr | Exception ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
2024-02-25 22:10:38 | ERROR | stderr | Traceback (most recent call last):
2024-02-25 22:10:38 | ERROR | stderr |   File "/usr/lib/python3.10/threading.py", line 1567, in _shutdown
2024-02-25 22:10:38 | ERROR | stderr |     lock.acquire()
2024-02-25 22:10:38 | ERROR | stderr | KeyboardInterrupt:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with fastchat/serve/controller.py and the fastchat.serve.controller entry point, then inspect how heart_beat_thread is created and how shutdown is handled after Uvicorn exits. Reproduce the single-interrupt behavior on the stated setup and trace the remaining thread. Done means the controller terminates cleanly after interruption, or the intended daemon behavior is documented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.