Repository navigation
Free llama.cpp models before the process exits - #422
Merged
Merged
Conversation
The parent measures a child's time until it sees the child end, and a busy CI runner delayed that by about seven seconds, so upper bounds failed although every child ended as expected. Exact exit statuses, the lower bounds, the parent's kill timer, and the lifecycle unit tests still catch a broken handler or watchdog.
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.
This PR works around a crash at exit in llama.cpp's Metal backend. A process that exits while a model has layers on the GPU aborts on
GGML_ASSERT([rsets->data count] == 0), and an exit in the middle of a generation crashes with or without the GPU.LlamaLanguageModelnow registers an exit handler when a load finishes. The handler stops new loads and generations, waits up to three seconds for running work to stop at its next token, and then frees every loaded model. It's best effort: if work is still running after three seconds, or the exit comes from inside a load or a generation, it frees nothing and the process can still abort. If freeing the models takes more than ten seconds, the handler aborts the process itself, so an exit can't hang. Requests that start after the handler runs throwGenerationError.assetsUnavailable. The README lists the cases the handler can't cover.