The explorer listed every weight file with its own button. For a repository of alternatives that is right — q4_k_m or q8_0, you want one — and for a sharded model it is fifteen clicks to fetch one thing, with nothing stopping you from losing count and leaving a version with fourteen of its parts. Files are grouped into sets now. A run of "-00002-of-00004" is one row and one button; everything else stays its own row. Not "fetch all the weights", which would be wrong half the time: two safetensors files are halves of one thing and useless apart, two GGUF files are usually alternatives and fetching both spends gigabytes on a copy nobody asked for. The set is the unit that is whole. A repository can hold both the split and the joined copy of the same quantisation — the real Qwen coder repos do — so a shard set keeps the -of- notation in its name rather than collapsing onto the name of the whole file beside it. A set publishes no single checksum. Several files have several, and showing one of them invites comparing it against the wrong thing. The form posts every source in the set, and a failure part way says how many already started: a set that fails on its fourth shard has three arriving, and reading that as "nothing happened" sends somebody to fetch them all again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ed530133b6
commit
a588646b7c
5 files changed
+277
-31
No files matched your search
@@ -52,6 +52,7 @@ type fakeMirror struct {
|
||||
models []mirror.Status
|
||||
listErr error
|
||||
fetched mirror.FetchRequest
|
||||
all []mirror.FetchRequest
|
||||
fetchErr error
|
||||
removed [2]string
|
||||
removeErr error
|
||||
@@ -68,6 +69,7 @@ func (f *fakeMirror) List(context.Context) (mirror.ModelsResponse, error) {
|
||||
|
||||
func (f *fakeMirror) Fetch(_ context.Context, r mirror.FetchRequest) (mirror.FetchResponse, error) {
|
||||
f.fetched = r
|
||||
f.all = append(f.all, r)
|
||||
if f.fetchErr != nil {
|
||||
return mirror.FetchResponse{}, f.fetchErr
|
||||
}
|
||||
@@ -435,3 +437,96 @@ func TestWithNoRegistryThereIsNoSearchBox(t *testing.T) {
|
||||
t.Error("fetching by hand must still be there")
|
||||
}
|
||||
}
|
||||
|
||||
func shardedRepo() *fakeRegistry {
|
||||
return &fakeRegistry{repo: hf.Repo{
|
||||
ID: "Qwen/Qwen2.5-7B-Instruct", Revision: "abc123def456",
|
||||
Files: []hf.File{
|
||||
{Path: "model-00001-of-00004.safetensors", Bytes: 4_000_000_000},
|
||||
{Path: "model-00002-of-00004.safetensors", Bytes: 4_000_000_000},
|
||||
{Path: "model-00003-of-00004.safetensors", Bytes: 4_000_000_000},
|
||||
{Path: "model-00004-of-00004.safetensors", Bytes: 3_000_000_000},
|
||||
{Path: "README.md", Bytes: 900},
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
func TestAShardedModelIsOneRowAndOneButton(t *testing.T) {
|
||||
body := mirrorGet(t, mirrorPageWith(t, &fakeMirror{}, shardedRepo(), true),
|
||||
"/admin/mirror?repo=Qwen/Qwen2.5-7B-Instruct").Body.String()
|
||||
|
||||
// Fifteen shards is one decision, not fifteen. Four here, and one form.
|
||||
if n := strings.Count(body, `action="/admin/mirror/fetch"`); n != 2 {
|
||||
// One for the set, one for the manual form at the bottom.
|
||||
t.Errorf("expected the four shards as a single form, found %d forms", n)
|
||||
}
|
||||
if !strings.Contains(body, "4 shards, fetched together") {
|
||||
t.Errorf("the row should say it is a set; got %s", body)
|
||||
}
|
||||
// Summed, so the operator sees what the disk is in for.
|
||||
if !strings.Contains(body, "14.0 GiB") {
|
||||
t.Error("the set should total its shards")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFetchingASetStartsEveryShard(t *testing.T) {
|
||||
m := &fakeMirror{}
|
||||
form := url.Values{"csrf": {"tok"}, "model": {"qwen"}, "version": {"abc123de"}}
|
||||
for i, p := range []string{"model-00001-of-00004.safetensors", "model-00002-of-00004.safetensors"} {
|
||||
form.Add("source", "https://hf/resolve/abc123def456/"+p)
|
||||
form.Add("file", p)
|
||||
_ = i
|
||||
}
|
||||
body := mirrorPost(t, mirrorPageWith(t, m, shardedRepo(), true),
|
||||
"/admin/mirror/fetch", form).Body.String()
|
||||
|
||||
if len(m.all) != 2 {
|
||||
t.Fatalf("expected both shards to be started, got %d", len(m.all))
|
||||
}
|
||||
// Each shard keeps its own filename under one model and version, which is
|
||||
// what makes them one version on disk.
|
||||
if m.all[0].File == m.all[1].File {
|
||||
t.Errorf("the shards collided on %q", m.all[0].File)
|
||||
}
|
||||
if m.all[0].Model != "qwen" || m.all[1].Version != "abc123de" {
|
||||
t.Errorf("the set should share one model and version: %+v", m.all)
|
||||
}
|
||||
if !strings.Contains(body, "2 files") {
|
||||
t.Errorf("the message should say how many started; got %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestASetThatFailsPartWaySaysHowFarItGot(t *testing.T) {
|
||||
m := &fakeMirror{fetchErr: errors.New("the mirror is full")}
|
||||
form := url.Values{"csrf": {"tok"}, "model": {"qwen"}, "version": {"v"}}
|
||||
form.Add("source", "https://hf/a.safetensors")
|
||||
form.Add("file", "a.safetensors")
|
||||
|
||||
body := mirrorPost(t, mirrorPageWith(t, m, shardedRepo(), true),
|
||||
"/admin/mirror/fetch", form).Body.String()
|
||||
|
||||
// "0 of 1 started, then …" rather than a bare error: a set that fails on
|
||||
// its fourth shard has three arriving, and reading it as nothing started
|
||||
// would send somebody to fetch them all again.
|
||||
if !strings.Contains(body, "0 of 1 started") {
|
||||
t.Errorf("the message should say how far it got; got %s", body)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAlternativeQuantisationsStaySeparateRows(t *testing.T) {
|
||||
reg := &fakeRegistry{repo: hf.Repo{
|
||||
ID: "Qwen/X", Revision: "abc",
|
||||
Files: []hf.File{
|
||||
{Path: "m-q4_k_m.gguf", Bytes: 1},
|
||||
{Path: "m-q8_0.gguf", Bytes: 2},
|
||||
},
|
||||
}}
|
||||
body := mirrorGet(t, mirrorPageWith(t, &fakeMirror{}, reg, true),
|
||||
"/admin/mirror?repo=Qwen/X").Body.String()
|
||||
|
||||
// Two GGUFs are alternatives, not halves. Offering "fetch all" here would
|
||||
// spend gigabytes on a copy nobody asked for.
|
||||
if n := strings.Count(body, `action="/admin/mirror/fetch"`); n != 3 {
|
||||
t.Errorf("expected a form each plus the manual one, found %d", n)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user