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
ox696c
ktransformers
Commits
56382aa8
Unverified
Commit
56382aa8
authored
Feb 15, 2025
by
Azure
Committed by
GitHub
Feb 15, 2025
Browse files
Merge pull request #290 from ZhangShuaiyi/dev/check_gguf_path
ensure that gguf_path argument is a directory.
parents
c8bf2501
22280bf1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
0 deletions
+6
-0
ktransformers/util/custom_gguf.py
ktransformers/util/custom_gguf.py
+6
-0
No files found.
ktransformers/util/custom_gguf.py
View file @
56382aa8
...
...
@@ -166,6 +166,8 @@ class GGUFLoader:
# Check dir exist
if
not
os
.
path
.
exists
(
gguf_path
):
raise
FileNotFoundError
(
f
"GGUF dir not found:
{
gguf_path
}
"
)
if
os
.
path
.
isfile
(
gguf_path
):
gguf_path
=
os
.
path
.
dirname
(
gguf_path
)
self
.
tensor_info
=
{}
self
.
gguf_path
=
gguf_path
...
...
@@ -175,14 +177,18 @@ class GGUFLoader:
self
.
tensor_device_map
=
{}
# Walk through all the .gguf files in the directory
found_gguf
=
False
for
root
,
dirs
,
files
in
os
.
walk
(
gguf_path
):
for
file
in
files
:
if
file
.
endswith
(
".gguf"
):
found_gguf
=
True
file_name
=
os
.
path
.
join
(
root
,
file
)
with
open
(
file_name
,
"rb"
)
as
f
:
self
.
load_gguf
(
f
)
if
file_name
not
in
self
.
file_data_map
:
self
.
file_data_map
[
file_name
]
=
np
.
memmap
(
file_name
,
mode
=
'r'
)
if
not
found_gguf
:
raise
FileNotFoundError
(
f
"Cannot find any .gguf files in:
{
gguf_path
}
"
)
def
load_gguf
(
self
,
f
):
f
.
seek
(
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