core: explicit CPU thread count and compute-device selection for embedders - #112
Open
erichchampion wants to merge 1 commit into
Open
core: explicit CPU thread count and compute-device selection for embedders#112erichchampion wants to merge 1 commit into
erichchampion wants to merge 1 commit into
Conversation
…dders An embedder today can only steer GGML through the GGML_BACKEND environment variable, and cannot pick a thread count at all. This adds src/backend-config.h: a set-once, unsynchronized configuration object -- ace_backend_configure(device, n_threads) plus single-field setters -- that backend init reads before its first model load. NULL/"" device means the old behaviour (GGML_BACKEND env var, then auto-best), so the CLIs are unchanged; a positive thread count caps GGML inference threads, <= 0 keeps the auto default. The device name is one ggml registers (CUDA0, Vulkan0, Metal, CPU); a request that matches nothing dies with the available names printed. Thread clamping: the override is clamped to the logical CPU count (with the Apple perflevel0 physical count preferred where available, since GEMM shares SIMD units across hyperthreads), and the MP3 export encoder honours the same cap through one shared clamp helper so the two workloads cannot diverge. test-backend-config.cpp covers config-readback, clamping, and end-to-end device selection against the real registry.
Contributor
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Last of four small embedder patches from Cadenza (independent of the other three).
What it does
An embedder today can only steer GGML through the
GGML_BACKENDenvironment variable, and cannot pick a thread count at all. Environment variables are the wrong interface for an app: a GUI cannot ask its user to export one before launch, and a mobile app has no shell at all.This adds
src/backend-config.h: a set-once, unsynchronized configuration object ---- that backend init reads before its first model load:
NULL/""device means exactly today's behaviour (GGML_BACKENDenv var, then auto-best), so the CLIs are unchanged.<= 0keeps the auto default.perflevel0.physicalcpuwhere available, since GEMM shares SIMD units across hyperthreads), and the MP3 export encoder honours the same cap through one shared clamp helper so the two workloads cannot diverge.Testing
tests/test-backend-config.cppcovers config read-back, clamping, and end-to-end device selection against the real registry (Metal on an Apple-silicon Mac, plus the CPU path). Built and run on macOS/arm64/Metal.