Skip to content

fix(gallery): write installed inference defaults under parameters so the loader reads them (#11230) - #11253

Open
Anai-Guo wants to merge 1 commit into
mudler:masterfrom
Anai-Guo:fix-gallery-inference-defaults-parameters-11230
Open

fix(gallery): write installed inference defaults under parameters so the loader reads them (#11230)#11253
Anai-Guo wants to merge 1 commit into
mudler:masterfrom
Anai-Guo:fix-gallery-inference-defaults-parameters-11230

Conversation

@Anai-Guo

Copy link
Copy Markdown
Contributor

What

Gallery installs write the model-family inference defaults (temperature, top_p, top_k, min_p, repeat_penalty, presence_penalty) into the persisted model YAML as top-level keys:

name: qwen3.5-122b-a10b
min_p: 0
presence_penalty: 1.5
temperature: 0.7
top_k: 20
top_p: 0.8
parameters:
  model: llama-cpp/models/Qwen3.5-122B-A10B-Q4_K_M-00001-of-00003.gguf

But config.ModelConfig embeds schema.PredictionOptions with yaml:"parameters" (core/config/model_config.go), so the loader only reads those fields from the parameters: submap. Every top-level key above is inert — the persisted defaults never take effect on reload.

Fixes #11230.

Change

In InstallModel, merge the applied inference defaults into the parameters: submap of the config map instead of the top level (creating the submap if absent, and preserving any value the config already sets there). The write side now targets the same key the loader reads.

Test

Adds a regression test (core/gallery/model_artifacts_inference_defaults_test.go) that installs a qwen3.5 model through the existing offline fakeArtifactMaterializer path and asserts the defaults:

  • round-trip through the typed config.ModelConfig loader (PresencePenalty == 1.5, RepeatPenalty == 1, MinP/Temperature non-nil), and
  • are serialized under parameters:, never at the top level.

Before the fix these fields land as top-level keys, so the typed reload sees the zero values and the test fails.

This branch is based on the fork's master; the diverged/behind count in the compare view is just the fork being behind upstream — the change set is the two files shown.

🤖 Generated with Claude Code

@localai-org-maint-bot localai-org-maint-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two blockers before this can merge:

  1. The new test does not compile against the current PR base. Running go test ./core/gallery -run TestGallery -count=1 fails with:
core/gallery/model_artifacts_inference_defaults_test.go:14:2: no required module provides package github.com/mudler/LocalAI/pkg/modelartifacts

pkg/modelartifacts, gallery.WithArtifactMaterializer, and the shared fakeArtifactMaterializer are not present on current master; they belong to the still-open #11162 work. Please rewrite this regression test against the gallery APIs available on master (the offline file-backed approach in #11232 is one example), or explicitly establish and document the dependency. The fix needs a test that compiles and exercises the current base.

  1. The PR body says the change was generated with Claude Code, but the commit contains only the human DCO trailer. Per this repository .agents/ai-coding-assistants.md, please amend the commit with an Assisted-by: Claude:<model-version> [Claude Code] trailer while retaining your own Signed-off-by:.

…the loader reads them back (mudler#11230)

ModelConfig embeds schema.PredictionOptions with `yaml:"parameters"`, so
the loader only reads temperature/top_p/top_k/min_p/repeat_penalty/
presence_penalty from the parameters: submap. The gallery installer wrote
those family defaults at the top level of the model YAML, where nothing
reads them back, leaving every persisted default inert on reload.

Merge them into the parameters: submap instead (preserving any values the
config already sets there), and add a regression test that installs a
qwen3.5 model and asserts the defaults round-trip through the typed
loader rather than landing as inert top-level keys. The test is fully
offline: the definition declares no files, so no download is attempted.

Assisted-by: Claude:claude-opus-4-8 [Claude Code]
Signed-off-by: Anai-Guo <antai12232931@outlook.com>
@Anai-Guo
Anai-Guo force-pushed the fix-gallery-inference-defaults-parameters-11230 branch from 5f39199 to b743f48 Compare July 31, 2026 16:17
@Anai-Guo

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review — both blockers addressed in b743f48.

1. Test no longer depends on unmerged #11162. Rewrote the regression test against the gallery APIs on master: it now builds a ModelConfig inline with no files:/artifacts and calls the plain 7-arg InstallModel, so it runs fully offline (no pkg/modelartifacts, no WithArtifactMaterializer, no fakeArtifactMaterializer). This mirrors the offline pattern already used in models_test.go. The qwen3.5-managed name still drives ApplyInferenceDefaults to fill the sampling params, and the test asserts they round-trip through the typed loader under parameters: rather than as inert top-level keys. Also added the missing trailing newline.

2. Attribution trailer added. Amended the commit to carry Assisted-by: Claude:claude-opus-4-8 [Claude Code] alongside the existing Signed-off-by:, per .agents/ai-coding-assistants.md.

go test ./core/gallery -run TestGallery should now compile and pass against the current base.

@localai-org-maint-bot localai-org-maint-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mudler This is good to merge now. The contributor removed the unmerged #11162 dependency, added the required AI-assistance trailer, and the revised offline regression test passes against current master (go test ./core/gallery -run TestGallery -count=1 -ginkgo.focus "persists inference defaults under parameters"). The broader gallery suite reached and passed this new spec; its only failures here were three unrelated existing network-backed specs receiving HTTP 403 responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gallery install writes sampling parameters where the config loader cannot read them

2 participants