Handle unreliable Vulkan memory budgets#613
Open
surma wants to merge 1 commit into
Open
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.
Summary
Some Vulkan drivers do not expose
VK_EXT_memory_budget. In that case,node-llama-cppcan still return heap-size values viagetVramState(), but live allocation accounting is not useful:usedremains0andfree === totaleven after loading a GPU-offloaded model.QMD currently treats that state as reliable VRAM availability and derives embedding/rerank context parallelism from it. On PanVK/Mali-G610 this causes QMD to create too many embedding contexts, which reproduces as:
It can also crash the process when multiple embedding contexts evaluate concurrently.
This PR adds a conservative fallback for unreliable Vulkan memory-budget reporting:
used === 0,free === total, no unified budget)1for that caseembedBatch()sequentially with fresh contexts on that pathMotivation / repro notes
Observed on
aarch64-linuxwith Mali-G610/PanVK:getVramState()reports roughly the full device heap as free before and after model loadingVK_ERROR_OUT_OF_DEVICE_MEMORYSo the issue is not “no GPU”; it is unsafe concurrency/context reuse decisions caused by unreliable Vulkan memory accounting.
Tests
CI=true bun test test/llm.test.tsResult: passes.
I also attempted broader local validation, but there are unrelated local environment failures in this checkout:
bun run buildfails on current main with:full
CI=true bun testcould not complete locally because CLI tests needbetter-sqlite3native bindings, which were not built in this checkout on myaarch64-linuxmachine.