tests : load backends before init when built with GGML_BACKEND_DL - #4031
tests : load backends before init when built with GGML_BACKEND_DL#4031apollo-2006 wants to merge 1 commit into
Conversation
With GGML_BACKEND_DL=ON no backend is registered until something calls ggml_backend_load_all(). Every example does; the tests never did, so whisper_init_* and parakeet_init_* ran with devices = 0 and aborted on GGML_ASSERT(device) in ggml_backend_dev_backend_reg. Three tests aborted on such a build - test-whisper-zero-samples, test-vad and test-parakeet - taking ctest -L gh to 2 of 4. test-vad-full has the same fault and reaches it only once a real base.en model is present. No workflow caught this because none pairs the two: build-clang, build-gcc and build-sanitize run ctest -L gh but never set GGML_BACKEND_DL, while release.yml sets it and runs no tests. ggml_backend_load_all() is already reachable through whisper.h and parakeet.h via ggml-cpu.h, so no new include is needed.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are minimal and directly address the documented GGML_BACKEND_DL test abort by ensuring backends are registered before context initialization.
Pull request overview
Ensures tests that initialize a whisper_context / whisper_vad_context / parakeet_context explicitly load GGML backends first, matching the behavior of existing examples and preventing devices = 0 aborts when built with GGML_BACKEND_DL=ON.
Changes:
- Add
ggml_backend_load_all()at the start ofmain()in four affected test binaries. - Align test startup behavior with example binaries that already perform backend loading.
- Fixes aborts caused by no backends/devices being registered under dynamic-backend loading builds.
File summaries
| File | Description |
|---|---|
| tests/test-whisper-zero-samples.cpp | Load GGML backends before initializing a Whisper context. |
| tests/test-vad.cpp | Load GGML backends before initializing VAD context/model usage. |
| tests/test-vad-full.cpp | Load GGML backends before Whisper/VAD initialization path. |
| tests/test-parakeet.cpp | Load GGML backends before initializing Parakeet contexts. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@danbev one thing I could not settle from the source. Is that split deliberate, keeping anything that needs a model out of the gh job, or should |
There is a separate workflow, build-vad.yml which runs test-vad so it does not require the |
Fixes #4030.
ggml_backend_load_all()at the top ofmain()in the four tests thatinitialise a context. Every example already does this:
examples/cli/cli.cpp,bench,quantize,lsp,vad-speech-segments. The tests were the only callers that did not.With
GGML_BACKEND_DL=ONno backend is registered until something calls it,so
whisper_init_*andparakeet_init_*ran withdevices = 0and abortedon
GGML_ASSERT(device)inggml_backend_dev_backend_reg.No new include:
ggml_backend_load_all()is already reachable throughwhisper.handparakeet.h, both of which pull inggml-cpu.h, whichincludes
ggml-backend.h.Before / after
Full suite on a
-DGGML_BACKEND_DL=ON -DGGML_CPU_ALL_VARIANTS=ONbuild,macOS 26.6.2 / arm64, Apple clang 21.0.0:
test-whisper-zero-samplestest-vadtest-parakeettest-vad-fullctest -L ghgoes from 2 of 4 to 4 of 4. The full suite goes from threeaborts to none.
test-vad-fullis labelledbase;enrather thanghbecause it needs a realmodels/ggml-base.en.bin, which I do not have locally. It had the same faultand the fix is verified the same way: before, it printed
devices = 0and hitGGML_ASSERT(device); after, it printsdevices = 3and gets throughinitialisation. Substituting the stub model it then fails its own
assert(n_segments == 1), identically on aGGML_BACKEND_DLand a normalbuild, which is the stub having no segments rather than anything to do with
this change.
Regression check
The same suite on a build without
GGML_BACKEND_DLis unchanged; 14 of 15before and after, the one failure being
test-vad-fullfor the missing modeldescribed above. Both configurations now produce identical results.
Why CI did not catch it
None of the workflows pairs the two.
build-clang.yml,build-gcc.ymlandbuild-sanitize.ymlrunctest -L ghbut never setGGML_BACKEND_DL;release.ymlsets it but runs no tests. Adding acteststep to aGGML_BACKEND_DLjob would cover the combination, but that felt like aseparate change from fixing the tests, so I have left it out here.