Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

ml/backend/ggml: create a new file descriptor for tensor (#10133)

Daniel Hipke0f3f9e353df9
diff --git a/ml/backend/ggml/ggml.go b/ml/backend/ggml/ggml.go
index a106fed5f..7e81e9950 100644
--- a/ml/backend/ggml/ggml.go
+++ b/ml/backend/ggml/ggml.go
@@ -319,7 +319,14 @@ func New(ctx context.Context, r *os.File, params ml.BackendParams) (ml.Backend,
tts[i] = tt
}
- sr := io.NewSectionReader(r, int64(meta.Tensors().Offset+t.Offset), int64(t.Size()))
+ // Create a new FD for each goroutine so that each FD is read sequentially, rather than
+ // seeking around within an FD shared between all goroutines.
+ file, err := os.Open(r.Name())
+ if err != nil {
+ return err
+ }
+ defer file.Close()
+ sr := io.NewSectionReader(file, int64(meta.Tensors().Offset+t.Offset), int64(t.Size()))
bts := make([]byte, 128*format.KibiByte)
var s uint64