server: remove dhiltgen/* compat redirect table

The redirect table was a stopgap for arches that llama-server (after
the runner removal) couldn't load because the Ollama-format GGUFs in
library/* differed from upstream. Every entry has now been superseded
by an in-process translator in llama/compat/, so the redirects are
dead weight: pulling library/<arch> works directly through compat
without rerouting the user to a republished blob.

Drops:
  * `compatModelRedirects` table (10 entries)
  * `applyCompatRedirect` / `reverseCompatRedirect` helpers
  * The single `applyCompatRedirect` call in resolveName
  * The `reverseCompatRedirect` call in PsHandler (the display name
    is now just the model's actual ShortName)
This commit is contained in:
jmorganca 2026-04-19 16:36:51 -07:00
parent 034fee349c
commit 9945c5a932
2 changed files with 1 additions and 76 deletions

View file

@ -1,79 +1,10 @@
package server
import (
"log/slog"
"strings"
"github.com/ollama/ollama/internal/modelref"
"github.com/ollama/ollama/types/model"
)
// Temporary redirection logic to map incompatible library models to compatible versions.
//
// Architectures listed here are handled via republished blobs under the
// dhiltgen/ namespace. Once llama/compat/ grows a handler for an arch, its
// entry should be removed from this list — the compat layer translates the
// original library/ blob in memory so no republish is needed.
var compatModelRedirects = []struct{ from, to string }{
// library/gpt-oss — handled by llama/compat (text only).
// library/gemma3 — handled by llama/compat (text + vision).
// library/lfm2.5-thinking — handled by llama/compat (text only).
{"library/embeddinggemma", "dhiltgen/embeddinggemma"},
{"library/snowflake-arctic-embed2", "dhiltgen/snowflake-arctic-embed2"},
{"library/gemma3n", "dhiltgen/gemma3n"},
{"library/glm-4.7-flash", "dhiltgen/glm-4.7-flash"},
{"library/deepseek-ocr", "dhiltgen/deepseek-ocr"},
{"library/glm-ocr", "dhiltgen/glm-ocr"},
{"library/gemma4", "dhiltgen/gemma4"},
{"library/qwen2.5vl", "dhiltgen/qwen2.5vl"},
{"library/qwen3-vl", "dhiltgen/qwen3-vl"},
}
// applyCompatRedirect checks if a model name matches a compat redirect and
// returns the redirected name. Returns the original name if no redirect applies.
func applyCompatRedirect(n model.Name) (model.Name, bool) {
if strings.Contains(n.DisplayShortest(), "-cloud") {
return n, false
}
for _, r := range compatModelRedirects {
fromNS, fromModel, _ := strings.Cut(r.from, "/")
if fromNS == n.Namespace && fromModel == n.Model {
redirected := n
toNS, toRest, _ := strings.Cut(r.to, "/")
redirected.Namespace = toNS
// Support "namespace/model:tag" to override the tag
if toModel, toTag, hasTag := strings.Cut(toRest, ":"); hasTag {
redirected.Model = toModel
redirected.Tag = toTag
} else {
redirected.Model = toRest
}
slog.Debug("redirecting to compatible model", "from", n.DisplayShortest(), "to", redirected.DisplayShortest())
return redirected, true
}
}
return n, false
}
// reverseCompatRedirect maps a redirected name back to its original library name.
// Used by PsHandler so users see the name they requested, not the internal redirect target.
// TODO: consider removing this before merging — it papers over the fact that
// the scheduler stores the redirected name instead of the user-facing name.
func reverseCompatRedirect(n model.Name) model.Name {
for _, r := range compatModelRedirects {
toNS, toModel, _ := strings.Cut(r.to, "/")
if toNS == n.Namespace && toModel == n.Model {
fromNS, fromModel, _ := strings.Cut(r.from, "/")
reversed := n
reversed.Namespace = fromNS
reversed.Model = fromModel
return reversed
}
}
return n
}
type modelSource = modelref.ModelSource
const (

View file

@ -1073,9 +1073,6 @@ func getExistingName(n model.Name) (model.Name, error) {
}
}
// Redirect models that have been republished in a compatible format
n, _ = applyCompatRedirect(n)
return n, nil
}
@ -2080,10 +2077,7 @@ func (s *Server) PsHandler(c *gin.Context) {
for _, v := range s.sched.loaded {
m := v.model
// Show the user-facing name (pre-redirect) so ps output matches
// what the user originally requested.
// TODO: consider removing before merging — see reverseCompatRedirect comment
displayName := reverseCompatRedirect(model.ParseName(m.ShortName)).DisplayShortest()
displayName := model.ParseName(m.ShortName).DisplayShortest()
modelDetails := api.ModelDetails{
Format: m.Config.ModelFormat,
Family: m.Config.ModelFamily,