File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ def translate_tensor_name(t: str) -> str:
49
49
def write_file_header (fout : TextIO , params : Dict [str , Any ]) -> None :
50
50
fout .write (b"ggla" [::- 1 ]) # magic (ggml lora)
51
51
fout .write (struct .pack ("i" , 1 )) # file version
52
- fout .write (struct .pack ("ii" , params ["r" ], params ["lora_alpha" ]))
52
+ fout .write (struct .pack ("i" , params ["r" ]))
53
+ # https://opendelta.readthedocs.io/en/latest/modules/deltas.html says that `lora_alpha` is an int
54
+ # but some models ship a float value instead
55
+ # let's convert to int, but fail if lossless conversion is not possible
56
+ assert int (params ["lora_alpha" ]) == params ["lora_alpha" ], "cannot convert float to int losslessly"
57
+ fout .write (struct .pack ("i" , int (params ["lora_alpha" ])))
53
58
54
59
55
60
def write_tensor_header (
@@ -89,7 +94,7 @@ def write_tensor_header(
89
94
print (f"Error: unsupported adapter type { params ['peft_type' ]} , expected LORA" )
90
95
sys .exit (1 )
91
96
92
- if params ["fan_in_fan_out" ] == True :
97
+ if params ["fan_in_fan_out" ] is True :
93
98
print ("Error: param fan_in_fan_out is not supported" )
94
99
sys .exit (1 )
95
100
You can’t perform that action at this time.
0 commit comments