fix(sdk): reacquire HTP sessions on all devices, not just NPU - #1289
Merged
Conversation
Mengsheng Wu (mengshengwu)
requested review from
David Qian (Davidqian123),
Paul Zhu (vinovo) and
Perry Cheng (zhycheng614)
as code owners
August 5, 2026 06:01
Mengsheng Wu (mengshengwu)
requested review from
RemiliaForever (RemiliaForever),
AlexCHEN (alexchen4ai) and
Zack Li (zhiyuan8)
as code owners
August 5, 2026 06:01
Any llama.cpp load walks the ggml registry's device list, so a stale HTP session pointer left by the last SessionGuard destruction crashes the load even when the current target is cpu / gpu. Symmetrize the gate: reacquire whenever the HTP backend is registered, regardless of the current device. Signed-off-by: Mengsheng Wu <mengshengwu@outlook.com>
Mengsheng Wu (mengshengwu)
force-pushed
the
fix/llama-cpp-htp-reacquire
branch
from
August 5, 2026 15:15
b4ed620 to
60b5977
Compare
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
test-sdk-qdchas been failing on all three legs since v0.3.18-alpha.2 withWindows fatal exception: access violationingeniex_llm_create/geniex_vlm_create.SessionGuard::release_if_lastreleases the shared HTP sessions on the last llama.cpp destructor unconditionally, but the reacquire hook inLlamaLlm::create/LlamaVlm::createwas gated todevice == Device::NPU. Any load walks the ggml registry's device list, so the nextllama_model_load_from_file— even on cpu / gpu — dereferences the stale HTP session pointer at offset 0x18.htp::htp_backend_present()instead, matching howmark_htpdecides whether to participate in the shared refcount.Test plan
pytest tests/plugins/llama_cpp/test_llama_cpp_llm.py -k "generate_stream or quality_keywords or multi_turn_recalls or ngram_simple"on the same host — 15 / 16 pass (only the pre-existingParis-npuearly-stop assertion remains, unrelated to the HTP session dance).test-sdk-qdcon this PR — pending CI.