Files
llmgw/internal/control/catalog/pickle_test.go
T
Ilker ManapandClaude Opus 5.5 258591b3f2
CI / test (push) Failing after 8m0s
What an engine downloads by a Hugging Face id is asked about too
From review. An adapter given by its id is downloaded by vLLM itself, and
a TensorRT-LLM model by its id by TensorRT-LLM, past the node's check and
not held to safetensors: a model with either is refused when it is added,
unless it says allow_pickle, with how to mirror its safetensors instead.
vLLM's own model by id stays allowed: the agent gives it --load-format
safetensors. A test holds every preset to its own pickle check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 11:06:11 +01:00

76 lines
2.9 KiB
Go

package catalog
import (
"strings"
"testing"
)
func TestAModelInAPickleFormatIsRefusedUnlessItSaysSo(t *testing.T) {
m := Model{Name: "triposr", Source: "hf:stabilityai/TripoSR/model.ckpt",
Adapters: []Adapter{{Name: "a", Source: "http://m/a/adapter_model.bin"}}}
err := m.CheckPickle()
if err == nil || !strings.Contains(err.Error(), "model.ckpt") || !strings.Contains(err.Error(), "allow_pickle") {
t.Fatalf("not refused, or not said why: %v", err)
}
if got := m.PickleSources(); len(got) != 2 {
t.Errorf("pickle sources %v, want the model's and the adapter's", got)
}
// A source that was there before is not asked about again: changing
// the scaling of a model that runs does not need allow_pickle.
if err := m.CheckPickle(m.PickleSources()...); err != nil {
t.Errorf("sources already there were refused: %v", err)
}
m.AllowPickle = true
if err := m.CheckPickle(); err != nil {
t.Errorf("allow_pickle was not honoured: %v", err)
}
if err := (Model{Name: "q", Source: "http://m/q/v/q-Q4_K_M.gguf"}).CheckPickle(); err != nil {
t.Errorf("a GGUF was refused: %v", err)
}
}
func TestTheTripoSRPresetSaysItsCheckpointIsAllowed(t *testing.T) {
p, ok := PresetNamed("triposr")
if !ok {
t.Fatal("no triposr preset")
}
if err := p.Model.CheckPickle(); err != nil {
t.Errorf("the preset llmgw ships is refused by its own check: %v", err)
}
}
func TestWhatAnEngineDownloadsByIDIsAskedAbout(t *testing.T) {
m := Model{Name: "m", Source: "http://mirror/m/v/", Profiles: []Profile{{Name: "gpu", Engine: "vllm"}},
Adapters: []Adapter{{Name: "a", Source: "someone/lora-x"}}}
if err := m.CheckPickle(); err == nil || !strings.Contains(err.Error(), "someone/lora-x") {
t.Errorf("an adapter by its id: %v", err)
}
m.Adapters = []Adapter{{Name: "a", Source: "http://mirror/a/v/adapter_model.safetensors"}}
if err := m.CheckPickle(); err != nil {
t.Errorf("a mirrored adapter: %v", err)
}
trt := Model{Name: "t", Source: "meta-llama/Llama-3.1-8B-Instruct", Profiles: []Profile{{Name: "gpu", Engine: "trtllm"}}}
if err := trt.CheckPickle(); err == nil {
t.Error("TensorRT-LLM downloading by id was not asked about")
}
vllm := Model{Name: "v", Source: "meta-llama/Llama-3.1-8B-Instruct", Profiles: []Profile{{Name: "gpu", Engine: "vllm"}}}
if err := vllm.CheckPickle(); err != nil {
t.Errorf("vLLM reads a model by id as safetensors only: %v", err)
}
for s, want := range map[string]bool{"Qwen/Qwen2.5-7B": true, "meta-llama/Llama-3.1-8B-Instruct": true,
"org/model.gguf": false, "o/r:Q4_K_M": false, "/models/x": false, "hf:o/r/f.gguf": false} {
if hubID(s) != want {
t.Errorf("hubID(%q) = %v", s, !want)
}
}
}
func TestEveryPresetPassesItsOwnPickleCheck(t *testing.T) {
// What llmgw ships must be addable: TripoSR was not, once.
for _, p := range Presets() {
if err := p.Model.CheckPickle(); err != nil {
t.Errorf("%s: %v", p.Model.Name, err)
}
}
}