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
fengzch-das
nunchaku
Commits
fb140c81
Unverified
Commit
fb140c81
authored
Sep 11, 2025
by
senlyu163
Committed by
GitHub
Sep 10, 2025
Browse files
feat: add rank calculation for transformer block state dict in merge_safetensors (#663)
parent
066dd05f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
nunchaku/merge_safetensors.py
nunchaku/merge_safetensors.py
+3
-0
No files found.
nunchaku/merge_safetensors.py
View file @
fb140c81
...
...
@@ -107,6 +107,8 @@ def merge_safetensors(
state_dict
=
unquantized_part_sd
state_dict
.
update
(
transformer_block_sd
)
rank
=
next
((
v
.
shape
[
1
]
for
k
,
v
in
transformer_block_sd
.
items
()
if
".lora_down"
in
k
),
32
)
precision
=
"int4"
for
v
in
state_dict
.
values
():
assert
isinstance
(
v
,
torch
.
Tensor
)
...
...
@@ -130,6 +132,7 @@ def merge_safetensors(
"scale_dtype"
:
"fp8_e4m3_nan"
if
precision
==
"fp4"
else
None
,
"group_size"
:
16
if
precision
==
"fp4"
else
64
,
},
"rank"
:
rank
,
}
return
state_dict
,
{
"config"
:
Path
(
config_path
).
read_text
(),
...
...
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