fix: make parameter loading backend-aware - #1828
Merged
Merged
Conversation
happyyzy
marked this pull request as ready for review
July 29, 2026 03:22
Closed
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
Fix two backend correctness issues in model loading:
ModelManager, select a compatible buffer withsupports_op, and enable CPU fallback only for unsupported graph nodesThis follows llama.cpp's per-op buffer selection. It adds no model, tensor-name, or shape special cases and does not modify ggml.
Previously loader workers entered the same backend upload path concurrently, while Q4_0 token embeddings were placed in an OpenCL SoA buffer that rejects
GET_ROWS(Q4_0).Image evidence
Tested on Adreno 830 with OpenCL,
GGML_OPENCL_SOA_Q, Adreno kernels, Q4_0 DP4A GEMM, and direct VAE convolution. The image runs used ggml from llama.cpp commit7e1e28cae36d41fe7bbe9dae7c9625de6565c063.The unpatched default four-thread load aborts in
clCreateSubBuffer. The before images use-t 1only to isolate the independent incompatible-buffer error. Patched runs use the default four loader threads.Reproduction commands
Checks
git diff --check origin/master..HEAD cmake -S . -B build-pr -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DGGML_OPENCL=ON \ -DGGML_OPENCL_USE_ADRENO_KERNELS=ON \ -DGGML_OPENCL_EMBED_KERNELS=ON cmake --build build-pr --target sd-cli -jThe Android/OpenCL
sd-clibuild also passes against the repository's pinnedggml@eced84c8.Checklist