Skip to content

Fix: minor issue of tqdm lock leak during termination with TP - #88

Open
xinze-zheng wants to merge 2 commits into
FlashML-org:mainfrom
xinze-zheng:main
Open

Fix: minor issue of tqdm lock leak during termination with TP#88
xinze-zheng wants to merge 2 commits into
FlashML-org:mainfrom
xinze-zheng:main

Conversation

@xinze-zheng

Copy link
Copy Markdown

Use a process-local threading.RLock for scheduler-worker tqdm progress bars.

tqdm defaults to a multiprocessing lock, creating one POSIX semaphore per TP rank. FreeToken terminates workers before those locks are finalized, causing resource_tracker warnings. Only rank 0 renders progress, so cross-process locking is unnecessary. A thread lock provides the required in-process synchronization without allocating semaphores. thus removes the warning.
Example TP=4 warning:

/usr/lib/python3.10/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 4 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

Tested on Qwen2.5 and TinyLlama with TP=2 and 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant