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
2dc60d46
Commit
2dc60d46
authored
Feb 27, 2025
by
Michael Yang
Browse files
ml/backend/ggml: offload vision to cpu
temporary until tensor loading can accurately account for vision models
parent
b5312f30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
+6
-10
ml/backend/ggml/ggml.go
ml/backend/ggml/ggml.go
+6
-10
No files found.
ml/backend/ggml/ggml.go
View file @
2dc60d46
...
@@ -134,13 +134,7 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
...
@@ -134,13 +134,7 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
cpuDeviceBufferTypes
:=
deviceBufferType
{
C
.
ggml_backend_dev_by_type
(
C
.
GGML_BACKEND_DEVICE_TYPE_CPU
),
cpuBufferTypes
}
cpuDeviceBufferTypes
:=
deviceBufferType
{
C
.
ggml_backend_dev_by_type
(
C
.
GGML_BACKEND_DEVICE_TYPE_CPU
),
cpuBufferTypes
}
input
:=
cpuDeviceBufferTypes
input
:=
cpuDeviceBufferTypes
var
blocks
int
blocks
:=
int
(
meta
.
KV
()
.
BlockCount
())
for
key
,
value
:=
range
meta
.
KV
()
{
if
strings
.
HasSuffix
(
key
,
".block_count"
)
{
blocks
+=
int
(
value
.
(
uint32
))
}
}
assignLayer
:=
func
(
i
int
)
(
temp
deviceBufferType
)
{
assignLayer
:=
func
(
i
int
)
(
temp
deviceBufferType
)
{
if
i
>=
params
.
NumGPULayers
{
if
i
>=
params
.
NumGPULayers
{
return
cpuDeviceBufferTypes
return
cpuDeviceBufferTypes
...
@@ -206,7 +200,7 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
...
@@ -206,7 +200,7 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
return
nil
return
nil
}
}
hasPart
:=
func
(
s
string
,
parts
...
string
)
bool
{
contains
:=
func
(
s
string
,
parts
...
string
)
bool
{
split
:=
strings
.
Split
(
s
,
"."
)
split
:=
strings
.
Split
(
s
,
"."
)
for
_
,
part
:=
range
parts
{
for
_
,
part
:=
range
parts
{
if
slices
.
Contains
(
split
,
part
)
{
if
slices
.
Contains
(
split
,
part
)
{
...
@@ -219,10 +213,12 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
...
@@ -219,10 +213,12 @@ func New(r *os.File, params ml.BackendParams) (ml.Backend, error) {
for
_
,
t
:=
range
meta
.
Tensors
()
.
Items
()
{
for
_
,
t
:=
range
meta
.
Tensors
()
.
Items
()
{
switch
{
switch
{
case
hasPart
(
t
.
Name
,
"position_embd"
,
"token_embd"
,
"token_norm_embd"
,
"token_types"
)
:
case
contains
(
t
.
Name
,
"position_embd"
,
"token_embd"
,
"token_norm_embd"
,
"token_types"
)
:
createTensor
(
tensor
{
source
:
t
},
input
.
bts
)
createTensor
(
tensor
{
source
:
t
},
input
.
bts
)
case
hasPart
(
t
.
Name
,
"cls"
,
"output"
,
"output_norm"
)
:
case
contains
(
t
.
Name
,
"cls"
,
"output"
,
"output_norm"
)
:
createTensor
(
tensor
{
source
:
t
},
output
.
bts
)
createTensor
(
tensor
{
source
:
t
},
output
.
bts
)
case
strings
.
HasPrefix
(
t
.
Name
,
"v."
)
||
strings
.
HasPrefix
(
t
.
Name
,
"mm."
)
:
createTensor
(
tensor
{
source
:
t
},
input
.
bts
)
default
:
default
:
if
i
:=
func
()
int
{
if
i
:=
func
()
int
{
if
fields
:=
strings
.
FieldsFunc
(
t
.
Name
,
func
(
r
rune
)
bool
{
return
!
unicode
.
IsNumber
(
r
)
});
len
(
fields
)
>
0
{
if
fields
:=
strings
.
FieldsFunc
(
t
.
Name
,
func
(
r
rune
)
bool
{
return
!
unicode
.
IsNumber
(
r
)
});
len
(
fields
)
>
0
{
...
...
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