Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
mlx: partial cleanup of imagegen layout (#15435)
Daniel Hiltgen2d84ec939cf6
diff --git a/server/images.go b/server/images.goindex 35094fa55..0458c24ae 100644--- a/server/images.go+++ b/server/images.go@@ -31,7 +31,7 @@ import ("github.com/ollama/ollama/thinking""github.com/ollama/ollama/types/model""github.com/ollama/ollama/version"- "github.com/ollama/ollama/x/imagegen/transfer"+ "github.com/ollama/ollama/x/transfer")// Blobs newer than this may belong to another process that has not written itsdiff --git a/x/imagegen/transfer/download.go b/x/transfer/download.gosimilarity index 100%rename from x/imagegen/transfer/download.gorename to x/transfer/download.godiff --git a/x/imagegen/transfer/sparse_other.go b/x/transfer/sparse_other.gosimilarity index 100%rename from x/imagegen/transfer/sparse_other.gorename to x/transfer/sparse_other.godiff --git a/x/imagegen/transfer/sparse_windows.go b/x/transfer/sparse_windows.gosimilarity index 100%rename from x/imagegen/transfer/sparse_windows.gorename to x/transfer/sparse_windows.godiff --git a/x/imagegen/transfer/transfer.go b/x/transfer/transfer.gosimilarity index 100%rename from x/imagegen/transfer/transfer.gorename to x/transfer/transfer.godiff --git a/x/imagegen/transfer/transfer_test.go b/x/transfer/transfer_test.gosimilarity index 93%rename from x/imagegen/transfer/transfer_test.gorename to x/transfer/transfer_test.goindex d85f513a9..f28ecd155 100644--- a/x/imagegen/transfer/transfer_test.go+++ b/x/transfer/transfer_test.go@@ -1543,117 +1543,6 @@ func BenchmarkUploadThroughput(b *testing.B) {}}-// TestThroughput is a quick throughput test that reports MB/s-func TestThroughput(t *testing.T) {- if testing.Short() {- t.Skip("Skipping throughput test in short mode")- }-- // Test parameters - 5MB total across 5 blobs- const blobSize = 1024 * 1024 // 1MB per blob- const numBlobs = 5- const concurrency = 5-- // Create test blobs- serverDir := t.TempDir()- blobs := make([]Blob, numBlobs)- for i := range numBlobs {- data := make([]byte, blobSize)- // Different seed per blob for unique digests- for j := range data {- data[j] = byte((i*256 + j) % 256)- }- h := sha256.Sum256(data)- digest := fmt.Sprintf("sha256:%x", h)- blobs[i] = Blob{Digest: digest, Size: int64(len(data))}-- path := filepath.Join(serverDir, digestToPath(digest))- os.MkdirAll(filepath.Dir(path), 0o755)- os.WriteFile(path, data, 0o644)- }-- totalBytes := int64(blobSize * numBlobs)-- // Download server- dlServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- digest := filepath.Base(r.URL.Path)- path := filepath.Join(serverDir, digestToPath(digest))- data, err := os.ReadFile(path)- if err != nil {- http.NotFound(w, r)- return- }- w.Header().Set("Content-Length", fmt.Sprintf("%d", len(data)))- w.WriteHeader(http.StatusOK)- w.Write(data)- }))- defer dlServer.Close()-- // Measure download throughput- clientDir := t.TempDir()- start := time.Now()- err := Download(context.Background(), DownloadOptions{- Blobs: blobs,- BaseURL: dlServer.URL,- DestDir: clientDir,- Concurrency: concurrency,- })- dlElapsed := time.Since(start)- if err != nil {- t.Fatalf("Download failed: %v", err)- }-- dlThroughput := float64(totalBytes) / dlElapsed.Seconds() / (1024 * 1024)- t.Logf("Download: %.2f MB/s (%d bytes in %v)", dlThroughput, totalBytes, dlElapsed)-- // Upload server- var ulServerURL string- ulServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {- switch r.Method {- case http.MethodHead:- http.NotFound(w, r)- case http.MethodPost:- w.Header().Set("Location", fmt.Sprintf("%s/v2/library/_/blobs/uploads/1", ulServerURL))- w.WriteHeader(http.StatusAccepted)- case http.MethodPut:- io.Copy(io.Discard, r.Body)- w.WriteHeader(http.StatusCreated)- }- }))- defer ulServer.Close()- ulServerURL = ulServer.URL-- // Measure upload throughput- start = time.Now()- err = Upload(context.Background(), UploadOptions{- Blobs: blobs,- BaseURL: ulServer.URL,- SrcDir: serverDir,- Concurrency: concurrency,- })- ulElapsed := time.Since(start)- if err != nil {- t.Fatalf("Upload failed: %v", err)- }-- ulThroughput := float64(totalBytes) / ulElapsed.Seconds() / (1024 * 1024)- t.Logf("Upload: %.2f MB/s (%d bytes in %v)", ulThroughput, totalBytes, ulElapsed)-- // Sanity check - local transfers should be fast (>50 MB/s is reasonable for local)- // This ensures the implementation isn't artificially throttled- if dlThroughput < 10 {- t.Errorf("Download throughput unexpectedly low: %.2f MB/s", dlThroughput)- }- if ulThroughput < 10 {- t.Errorf("Upload throughput unexpectedly low: %.2f MB/s", ulThroughput)- }-- // Overall time check - should complete in <500ms for local transfers- if dlElapsed+ulElapsed > 500*time.Millisecond {- t.Logf("Warning: total time %v exceeds 500ms target", dlElapsed+ulElapsed)- }-}-// ==================== Resume Tests ====================func TestResumeFromPartialFile(t *testing.T) {diff --git a/x/imagegen/transfer/upload.go b/x/transfer/upload.gosimilarity index 100%rename from x/imagegen/transfer/upload.gorename to x/transfer/upload.go