Skip to content

common : only load backends when required - #22290

Merged
angt merged 3 commits into
ggml-org:masterfrom
angt:common-only-load-backends-when-required
May 5, 2026
Merged

angt merged 3 commits into
ggml-org:masterfrom
angt:common-only-load-backends-when-required

Conversation

@angt

@angt angt commented Apr 23, 2026

Copy link
Copy Markdown
Member

Overview

Only load backends when required.

Additional information

This fixe the following issues: #20186, #21708 and maybe others.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES (kimi): I've asked the list of functions to modify for a minimal patch

@angt
angt requested a review from a team as a code owner April 23, 2026 13:10
Comment thread ggml/src/ggml-backend-reg.cpp Resolved
Comment thread common/arg.cpp Resolved
@github-actions github-actions Bot added the ggml changes relating to the ggml tensor library for machine learning label Apr 23, 2026
@angt
angt force-pushed the common-only-load-backends-when-required branch from 1952e4b to f2d4b06 Compare April 28, 2026 14:08
@ggerganov

Copy link
Copy Markdown
Member

The test-thread-safety is failing

@angt
angt requested a review from ggerganov as a code owner April 28, 2026 15:09
@ggerganov

Copy link
Copy Markdown
Member

Hm, I don't see where we would call ggml_backend_load_all() for llama-cli, llama-server, etc. Building with -DGGML_BACKEND_DL=ON makes these binaries not load any backends.

@angt

angt commented Apr 28, 2026 •

Copy link
Copy Markdown
Member Author

Hm, I don't see where we would call ggml_backend_load_all() for llama-cli, llama-server, etc. Building with -DGGML_BACKEND_DL=ON makes these binaries not load any backends.

Damn, checking. I don’t use AI often (for llama.cpp!). Kimi is this bad ? 🤣

@github-actions github-actions Bot added the testing Everything test related label Apr 28, 2026
@angt
angt force-pushed the common-only-load-backends-when-required branch from 9027fd9 to 37ac5d5 Compare April 28, 2026 16:26
@angt

angt commented Apr 28, 2026 •

Copy link
Copy Markdown
Member Author

The last call was missing...
Edit: So Kimi is fine, it was my fault 🙄

@angt

angt commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

@ggerganov maybe I can take this PR as an opportunity to remove ggml_backend_load_all from common_params_parser_init and call it explicitly where it’s needed, instead of hiding it there?

@ggerganov

Copy link
Copy Markdown
Member

@ggerganov maybe I can take this PR as an opportunity to remove ggml_backend_load_all from common_params_parser_init and call it explicitly where it’s needed, instead of hiding it there?

Yes, let's do that.

@angt
angt force-pushed the common-only-load-backends-when-required branch from 37ac5d5 to b967482 Compare April 30, 2026 12:25
@angt
angt requested a review from a team as a code owner April 30, 2026 12:25
@angt

angt commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

I finally have updated llama_backend_init() to call ggml_backend_load_all(). The name was a perfect fit, so I decided to try this, but I’m not yet 100% convinced too, and maybe we should just call ggml_backend_load_all() everywhere...

@ggerganov ggerganov added the merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. label May 4, 2026
@angt
angt merged commit bf76ac7 into ggml-org:master May 5, 2026
44 of 46 checks passed
@rgerganov

rgerganov commented May 6, 2026 •

Copy link
Copy Markdown
Member

This patch broke RPC (issue #22721) and introduced obscure regressions (issue #22748). Having multiple calls to ggml_backend_load_all() is not how loading dynamic backends is supposed to work and breaks many implicit assumptions.

I suggest to revert this patch.

@angt

angt commented May 6, 2026

Copy link
Copy Markdown
Member Author

I think it’s just because of some missing calls it’s hard to track all of them

@angt

angt commented May 6, 2026

Copy link
Copy Markdown
Member Author

#22752 should fix both issues (and others)

cetarthoriphros pushed a commit to cetarthoriphros/llama.cpp that referenced this pull request May 9, 2026
* common : only load backends when required

Signed-off-by: Adrien Gallouët <[email protected]>

* llama : call ggml_backend_load_all() directly from llama_backend_init()

Signed-off-by: Adrien Gallouët <[email protected]>

* Add ggml_backend_load_all() where llama_backend_init() is not used

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
baramofme pushed a commit to baramofme/llama-cpp-turboquant that referenced this pull request May 23, 2026
* common : only load backends when required

Signed-off-by: Adrien Gallouët <[email protected]>

* llama : call ggml_backend_load_all() directly from llama_backend_init()

Signed-off-by: Adrien Gallouët <[email protected]>

* Add ggml_backend_load_all() where llama_backend_init() is not used

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
carlosfundora pushed a commit to carlosfundora/llama.cpp-1-bit-turbo that referenced this pull request May 24, 2026
* common : only load backends when required

Signed-off-by: Adrien Gallouët <[email protected]>

* llama : call ggml_backend_load_all() directly from llama_backend_init()

Signed-off-by: Adrien Gallouët <[email protected]>

* Add ggml_backend_load_all() where llama_backend_init() is not used

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
(cherry picked from commit bf76ac7)
zommiommy pushed a commit to zommiommy/llama.cpp that referenced this pull request Aug 18, 2026
* common : only load backends when required

Signed-off-by: Adrien Gallouët <[email protected]>

* llama : call ggml_backend_load_all() directly from llama_backend_init()

Signed-off-by: Adrien Gallouët <[email protected]>

* Add ggml_backend_load_all() where llama_backend_init() is not used

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
* common : only load backends when required

Signed-off-by: Adrien Gallouët <[email protected]>

* llama : call ggml_backend_load_all() directly from llama_backend_init()

Signed-off-by: Adrien Gallouët <[email protected]>

* Add ggml_backend_load_all() where llama_backend_init() is not used

Signed-off-by: Adrien Gallouët <[email protected]>

---------

Signed-off-by: Adrien Gallouët <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples ggml changes relating to the ggml tensor library for machine learning merge ready A maintainer can use this label to indicate that they consider the changes final and ready to merge. testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants