throw an error when encountering unsupport tensor sizes (#6538)

This commit is contained in:
Patrick Devine
2024-08-27 17:54:04 -07:00
committed by GitHub
parent 93ea9240ae
commit 6c1c1ad6a9
2 changed files with 106 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"io"
"io/fs"
@@ -50,6 +51,10 @@ func parseSafetensors(fsys fs.FS, replacer *strings.Replacer, ps ...string) ([]T
for _, key := range keys {
if value := headers[key]; value.Type != "" {
// bitsandbytes quantized models are unsupported
if len(value.Shape) == 0 {
return nil, errors.New("unsupported safetensors model")
}
ts = append(ts, safetensor{
fs: fsys,
path: p,