Skip to content

Return the startup error when Hexagon session rollback fails - #265

Merged
leehack merged 3 commits into
mainfrom
lane-hexagon-startup-rollback
Dec 2, 2026
Merged

leehack merged 3 commits into
mainfrom
lane-hexagon-startup-rollback

Conversation

@leehack

@leehack leehack commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #264. When pinned llama.cpp's Hexagon backend fails during session setup and FastRPC cleanup also fails, GGML_ABORT in ggml_hexagon_session::release() killed the process before llama_dart_ggml_backend_dev_init could report the startup error.

  • Carries patch 0010-hexagon-startup-rollback.patch (~16 lines, one file): a session sets startup_complete only after its constructor succeeds. Before that, a failed dspqueue_close / htp_iface_stop is logged (startup rollback: ... failed) and rollback continues. A failed group rollback demotes already-started siblings the same way. Fully constructed sessions keep the upstream abort on the destructor path.
  • Adds llamadart_hexagon_startup_test: the pinned Hexagon host source (patched copy) built against stubbed FastRPC headers/calls on Linux and macOS hosts, run through llama_dart_ggml_backend_dev_init. Scenarios: cleanup-ok, cleanup-fail (failed dspqueue_close after failed dspqueue_export), group-rollback (3-session group, failed export on the third, failed close/stop on a started sibling) must each return no backend, the original dspqueue export failed error and a close of every queue and handle. constructed-abort constructs a session, fails dspqueue_close on teardown in a child process and requires the upstream GGML_ABORT.
  • docs/android_hexagon.md documents the patch, its removal condition and the device-qualification note.
  • patches/llama.cpp/README.md records the "Exception for native Hexagon session startup can abort during queue rollback #264" for 0010 only.
  • CMakeLists.txt / cmake/llama_cpp_patches.cmake: expose the patched-source list so the test compiles the patched copy; the test is skipped when cross-compiling or off Linux/macOS.
  • Workflow edits: validate_wrapper.yml builds the new target (the existing ctest step runs it); android_hexagon_candidate.yml also triggers on patch, CMake and submodule-pin paths. The candidate's validate_android_artifacts.py step fails when libggml-hexagon.so lacks the series marker startup rollback: dspqueue_close failed.

Eligibility: the Hexagon candidate is not yet a released artifact, so patches/llama.cpp/README.md's "released artifact crashes" condition is met only by #264's P1 triage. The maintainer approved this exception for 0010 only on 2026-12-01; the README now records it.

Validation

Check Result
ctest -R hexagon_startup (Debug, macOS arm64, patched) 4/4 pass
Mutation: patch removed cleanup-fail, group-rollback abort; cleanup-ok passes
Mutation: siblings not demoted group-rollback aborts; others pass
Mutation: never abort, even for constructed sessions constructed-abort fails; others pass
python3 -m unittest discover -s tests -p 'test_*.py' 530 pass, 1 skipped
Linux host build, Android candidate marker CI

Build-identity patch digest changes with this patch. No ABI or export change.

Deferred gates

  • Candidate device qualification (SM8650 v75, SM8750 v79): after a failed htp_iface_stop during startup rollback, teardown now unmaps and frees the session buffers and closes the handle instead of aborting. The host test cannot verify the DSP side; confirm no stuck DSP state or leaked mapping and that the next session start succeeds (docs/android_hexagon.md).

High-risk classification

High-risk: native FFI/runtime patch to a backend teardown path and a CI/build change (classify_high_risk_changes.dart: high-risk, surface regressionPolicy). Independent auditor-deep audit of the exact head required before ready. Head ac0e1e85 audited clean (no blocking code findings); a delta audit of the follow-up head is pending. This PR is a draft.

Changelog

N/A: unreleased opt-in Hexagon candidate. Build identity (patch digest) changes on every platform and the next release manifest lists 0010, but there is no runtime behavior change in default artifacts.

Carry llama.cpp patch 0010: a session that has not finished construction
logs a failed dspqueue_close or htp_iface_stop and keeps rolling back
instead of aborting, so llama_dart_ggml_backend_dev_init reports the
original startup error. Sessions that finished construction keep the
upstream abort. A host test with stubbed FastRPC calls covers a clean
cleanup, a failed queue close and a grouped-session rollback.

Fixes #264
@leehack
leehack marked this pull request as ready for review December 2, 2026 01:01
@leehack
leehack merged commit 2ab80a8 into main Dec 2, 2026
34 of 35 checks passed
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.

Hexagon session startup can abort during queue rollback

1 participant