Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
eeb69526
Commit
eeb69526
authored
May 07, 2024
by
Michael Yang
Browse files
skip if same quantization
parent
2a5302a1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
llm/ggml.go
llm/ggml.go
+3
-3
server/images.go
server/images.go
+27
-27
No files found.
llm/ggml.go
View file @
eeb69526
...
@@ -45,12 +45,12 @@ func (kv KV) ParameterCount() uint64 {
...
@@ -45,12 +45,12 @@ func (kv KV) ParameterCount() uint64 {
return
kv
.
u64
(
"general.parameter_count"
)
return
kv
.
u64
(
"general.parameter_count"
)
}
}
func
(
kv
KV
)
FileType
()
string
{
func
(
kv
KV
)
FileType
()
fileType
{
if
u64
:=
kv
.
u64
(
"general.file_type"
);
u64
>
0
{
if
u64
:=
kv
.
u64
(
"general.file_type"
);
u64
>
0
{
return
fileType
(
uint32
(
u64
))
.
String
()
return
fileType
(
uint32
(
u64
))
}
}
return
"u
nknown
"
return
fileTypeU
nknown
}
}
func
(
kv
KV
)
BlockCount
()
uint64
{
func
(
kv
KV
)
BlockCount
()
uint64
{
...
...
server/images.go
View file @
eeb69526
...
@@ -370,17 +370,16 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
...
@@ -370,17 +370,16 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
baseLayer
.
MediaType
==
"application/vnd.ollama.image.model"
&&
baseLayer
.
MediaType
==
"application/vnd.ollama.image.model"
&&
baseLayer
.
GGML
!=
nil
&&
baseLayer
.
GGML
!=
nil
&&
baseLayer
.
GGML
.
Name
()
==
"gguf"
{
baseLayer
.
GGML
.
Name
()
==
"gguf"
{
ftype
,
err
:=
llm
.
ParseFileType
(
quantization
)
want
,
err
:=
llm
.
ParseFileType
(
quantization
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
f
iletype
:=
baseLayer
.
GGML
.
KV
()
.
FileType
()
f
t
:=
baseLayer
.
GGML
.
KV
()
.
FileType
()
if
!
slices
.
Contains
([]
string
{
"F16"
,
"F32"
},
f
iletype
)
{
if
!
slices
.
Contains
([]
string
{
"F16"
,
"F32"
},
f
t
.
String
()
)
{
return
errors
.
New
(
"quantization is only supported for F16 and F32 models"
)
return
errors
.
New
(
"quantization is only supported for F16 and F32 models"
)
}
}
else
if
want
!=
ft
{
fn
(
api
.
ProgressResponse
{
Status
:
fmt
.
Sprintf
(
"quantizing %s model to %s"
,
ft
,
quantization
)})
fn
(
api
.
ProgressResponse
{
Status
:
fmt
.
Sprintf
(
"quantizing %s model to %s"
,
filetype
,
quantization
)})
blob
,
err
:=
GetBlobsPath
(
baseLayer
.
Digest
)
blob
,
err
:=
GetBlobsPath
(
baseLayer
.
Digest
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -394,7 +393,7 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
...
@@ -394,7 +393,7 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
defer
temp
.
Close
()
defer
temp
.
Close
()
defer
os
.
Remove
(
temp
.
Name
())
defer
os
.
Remove
(
temp
.
Name
())
if
err
:=
llm
.
Quantize
(
blob
,
temp
.
Name
(),
ftype
);
err
!=
nil
{
if
err
:=
llm
.
Quantize
(
blob
,
temp
.
Name
(),
want
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -403,12 +402,13 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
...
@@ -403,12 +402,13 @@ func CreateModel(ctx context.Context, name, modelFileDir, quantization string, m
return
err
return
err
}
}
}
}
}
if
baseLayer
.
GGML
!=
nil
{
if
baseLayer
.
GGML
!=
nil
{
config
.
ModelFormat
=
cmp
.
Or
(
config
.
ModelFormat
,
baseLayer
.
GGML
.
Name
())
config
.
ModelFormat
=
cmp
.
Or
(
config
.
ModelFormat
,
baseLayer
.
GGML
.
Name
())
config
.
ModelFamily
=
cmp
.
Or
(
config
.
ModelFamily
,
baseLayer
.
GGML
.
KV
()
.
Architecture
())
config
.
ModelFamily
=
cmp
.
Or
(
config
.
ModelFamily
,
baseLayer
.
GGML
.
KV
()
.
Architecture
())
config
.
ModelType
=
cmp
.
Or
(
config
.
ModelType
,
format
.
HumanNumber
(
baseLayer
.
GGML
.
KV
()
.
ParameterCount
()))
config
.
ModelType
=
cmp
.
Or
(
config
.
ModelType
,
format
.
HumanNumber
(
baseLayer
.
GGML
.
KV
()
.
ParameterCount
()))
config
.
FileType
=
cmp
.
Or
(
config
.
FileType
,
baseLayer
.
GGML
.
KV
()
.
FileType
())
config
.
FileType
=
cmp
.
Or
(
config
.
FileType
,
baseLayer
.
GGML
.
KV
()
.
FileType
()
.
String
()
)
config
.
ModelFamilies
=
append
(
config
.
ModelFamilies
,
baseLayer
.
GGML
.
KV
()
.
Architecture
())
config
.
ModelFamilies
=
append
(
config
.
ModelFamilies
,
baseLayer
.
GGML
.
KV
()
.
Architecture
())
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment