fix(quantization): pin the producing backend on imported quantized models (#11875) - #11879
Open
Anai-Guo wants to merge 1 commit into
Open
fix(quantization): pin the producing backend on imported quantized models (#11875)#11879Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
…dels (mudler#11875) ImportModel hands the copied GGUF to importers.ImportLocalPath, which detects the file format and defaults every GGUF to `backend: llama-cpp`. For a model this service just produced with a backend stock llama.cpp cannot read, the generated config names an engine that cannot load the file, and the import silently registers an unloadable model. Correcting `backend:` by hand makes the same file work. The job record already carries the backend that served StartQuantization, so carry it into the config instead of keeping the detected default. The gallery publishes a quantizer as a release channel of the engine that runs its output ("llama-cpp-quantization" is llama.cpp's quantizer, whose GGUF is served by "llama-cpp"), so the channel suffix is stripped to get the serving backend. A backend that both quantizes and serves ("rocmfp4") carries no suffix and passes through unchanged, as do pinned hardware variants ("rocm-rocmfp4"), which are valid values for a config's backend field. An empty job backend leaves the detected default in place. Also replace the importer's generic "Fine-tuned model (GGUF)" description for this path: the model was quantized, not fine-tuned, and the job knows the type. Signed-off-by: Tai An <antai12232931@outlook.com>
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.
Fixes #11875.
Problem
QuantizationService.ImportModelcopies the finished GGUF into the models directory and then callsimporters.ImportLocalPathto generate the config. That importer detects the file format and hardcodes the backend for any GGUF:ImportModelthen only overridescfg.Name, so the job's own backend is discarded. For a model this service just quantized with a backend whose weight types stock llama.cpp does not know (the reporter hit this withrocmfp4, ROCmFP4 types from #11636), the generated YAML names an engine that cannot load the file. The import reports success and registers a model that fails at load; correctingbackend:by hand makes the same file work immediately.The one path that produces a model and the one path that registers it disagree about how to run it.
Fix
The job record already carries the backend that served
StartQuantization(schema.QuantizationJob.Backend), so carry it into the config instead of keeping the detected default.Copying
job.Backendverbatim would be wrong for the common case, because the gallery publishes a quantizer as a release channel of the engine that serves its output —llama-cpp-quantizationis llama.cpp's quantizer, and the GGUF it writes is served byllama-cpp. That convention is already stated incore/config/backend_capabilities.go:So the new helper strips that suffix (after
config.NormalizeBackendName, which foldsllama.cpp→llama-cpp):job.Backendbackend:llama-cpp-quantizationllama-cpprocmfp4rocmfp4rocm-rocmfp4-quantizationrocm-rocmfp4backend:valuellama.cpp-quantizationllama-cpp""Both cases the reporter actually hit come out right.
I deliberately kept this inside
core/services/quantization.stripBackendVariantincore/configdoes the same job and also strips hardware prefixes, but it is unexported; if you would rather export it and call it here (which would additionally reducerocm-rocmfp4torocmfp4), say so and I will switch — I did not want to widen a package's API unasked.Also addresses the secondary point in the issue: the description said
Fine-tuned model (GGUF)for a model that was quantized, not fine-tuned. This path now writesQuantized model (<type>, GGUF), guarded so an empty type leaves the importer's text alone. The generic importer is untouched.Verification
Added five specs to
core/services/quantization/service_test.go(existing ginkgo white-box suite) covering exactly the table above.The mapping was also run standalone against the real logic:
gofmt -lis clean on both changed files. I do not have a ROCm host, so the end-to-end quantize→import round trip onrocmfp4is not something I could re-run; the failing artifact and the hand-corrected YAML in the issue are the ground truth I worked from.🤖 Generated with Claude Code