Address possible memory leak during model sleep/unload#2030
Open
glaziermag wants to merge 1 commit intoEricLBuehler:masterfrom
Open
Address possible memory leak during model sleep/unload#2030glaziermag wants to merge 1 commit intoEricLBuehler:masterfrom
glaziermag wants to merge 1 commit intoEricLBuehler:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tentatively addressing issue #545.
It appears that the VRAM memory leak during
/v1/sleepand model unload operations might be related to asynchronous CUDA context bindings executing after the OS thread has shut down or detached from the device pool. By synchronizing theengine_handlerthread and explicitly pre-binding thecandle_corecontext to the local HTTP thread before the unmapped Rust pointers evaluate their destructors, the driver seems to successfully purge the PagedAttention memory pools back to OS limits.Still testing the broader implications of this driver context synchronization, so I'm open to feedback on whether this is the optimal approach for the architecture.
Diagnostic Traces (L4 Instance)
Before synchronization:
(Driver executes pointer drops synchronously but execution appears to drop unmapped, leaving memory allocated.)
After synchronization:
(Memory returns to the intrinsic context reservation block, clearing the dynamically loaded KV cache).