fix(model-artifacts): gate inferred artifact materialization by backend#10910
Merged
Conversation
The managed-artifact materializer stages a HuggingFace snapshot into a directory (.artifacts/huggingface/<key>/snapshot/). That is the right load target for directory-consuming backends (transformers, vLLM, diffusers, ...), but PrimaryArtifactSpec inferred a managed artifact from ANY HuggingFace-shaped model reference regardless of backend. A single-file backend such as llama.cpp or whisper was therefore handed the snapshot directory instead of the weight file and failed to load it. The /import-model importer already guards this with a backend allow-list (managedArtifactBackends), but the loader-side inference did not. Move the allow-list into core/config as IsManagedArtifactBackend and apply it in PrimaryArtifactSpec: only directory-consuming backends may have an artifact inferred from a bare reference; every other backend stays on the legacy download-to-file path. An explicit artifacts: block still bypasses the gate, where single-file snapshot resolution handles the load path. The importer now shares the same predicate, so both paths agree on which backends auto-materialize. Assisted-by: Claude:opus-4.8 [Claude Code] Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
mudler
approved these changes
Jul 17, 2026
mudler
enabled auto-merge (squash)
July 17, 2026 23:04
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.
Problem
Follow-up to #10909 (single-file snapshot resolution). That PR fixed the case where an explicitly-resolved single-file snapshot was handed to a backend as a directory. This PR closes the remaining gap: the loader still infers a managed artifact from any HuggingFace-shaped
parameters.modelregardless of backend.PrimaryArtifactSpecmaterializes a bare HF reference (huggingface://owner/repo/model.gguf,hf://…, or a bareowner/repo) into a snapshot directory.artifacts/huggingface/<key>/snapshot/. That directory is the correct load target for directory-consuming backends (transformers, vLLM, diffusers, …), but a single-file backend such as llama.cpp or whisper is then handed the directory instead of the weight file:The
/import-modelimporter already guards this with a backend allow-list (managedArtifactBackends), but the loader-side inference incore/confignever applied the same gate. So a hand-written YAML orlocal-ai run huggingface://…/x.ggufwith a single-file backend and nofiles:would break — the exact class of failure that motivated #10909, just via the inference path rather than an explicitartifacts:block.Fix
core/gallery/importers/helpers.gointocore/configas an exported predicateIsManagedArtifactBackend(backend).PrimaryArtifactSpecnow gates the inferred cases: only directory-consuming backends may have an artifact inferred from a bare reference. Every other backend stays on the legacy download-to-file path, so the backend receives the weight file itself.artifacts:block still bypasses the gate — single-file snapshot resolution (fix(model-artifacts): load single-file HF snapshots from the file, not the directory #10909) handles the load path there.config.IsManagedArtifactBackend, so both paths agree on which backends auto-materialize (no duplicate list).Tests
core/config/model_artifact_inference_test.go(Ginkgo): a bare HF file/repo reference onllama-cppstays legacy (managed=false); a reference ontransformersstill infers a managed artifact; an explicitartifacts:block onllama-cppstays managed.Verified locally:
go test ./core/config/ ./core/gallery/importers/ ./core/services/galleryop/ ./core/application/pass;make lint(new-from-merge-base) reports 0 issues.Assisted-by: Claude:opus-4.8 [Claude Code]
🤖 Generated with Claude Code