@@ -103,6 +103,7 @@ def pick_existant_file(ntoption,nonntoption):
103
103
lib_noavx2 = pick_existant_file ("koboldcpp_noavx2.dll" ,"koboldcpp_noavx2.so" )
104
104
lib_clblast = pick_existant_file ("koboldcpp_clblast.dll" ,"koboldcpp_clblast.so" )
105
105
lib_cublas = pick_existant_file ("koboldcpp_cublas.dll" ,"koboldcpp_cublas.so" )
106
+ lib_hipblas = pick_existant_file ("koboldcpp_hipblas.dll" ,"koboldcpp_hipblas.so" )
106
107
107
108
108
109
def init_library ():
@@ -113,6 +114,7 @@ def init_library():
113
114
use_openblas = False # if true, uses OpenBLAS for acceleration. libopenblas.dll must exist in the same dir.
114
115
use_clblast = False #uses CLBlast instead
115
116
use_cublas = False #uses cublas instead
117
+ use_hipblas = False #uses hipblas instead
116
118
use_noavx2 = False #uses no avx2 instructions
117
119
use_failsafe = False #uses no intrinsics, failsafe mode
118
120
if args .noavx2 :
@@ -131,11 +133,16 @@ def init_library():
131
133
print ("Attempting to use CLBlast library for faster prompt ingestion. A compatible clblast will be required." )
132
134
use_clblast = True
133
135
elif (args .usecublas is not None ):
134
- if not file_exists (lib_cublas ):
136
+ if not file_exists (lib_cublas ) and not file_exists ( lib_hipblas ) :
135
137
print ("Warning: CuBLAS library file not found. Non-BLAS library will be used." )
136
138
else :
137
- print ("Attempting to use CuBLAS library for faster prompt ingestion. A compatible CuBLAS will be required." )
138
- use_cublas = True
139
+ if file_exists (lib_cublas ):
140
+ print ("Attempting to use CuBLAS library for faster prompt ingestion. A compatible CuBLAS will be required." )
141
+ use_cublas = True
142
+ elif file_exists (lib_hipblas ):
143
+ print ("Attempting to use hipBLAS library for faster prompt ingestion. A compatible AMD GPU will be required." )
144
+ use_hipblas = True
145
+
139
146
else :
140
147
if not file_exists (lib_openblas ) or (os .name == 'nt' and not file_exists ("libopenblas.dll" )):
141
148
print ("Warning: OpenBLAS library file not found. Non-BLAS library will be used." )
@@ -157,6 +164,8 @@ def init_library():
157
164
libname = lib_clblast
158
165
elif use_cublas :
159
166
libname = lib_cublas
167
+ elif use_hipblas :
168
+ libname = lib_hipblas
160
169
elif use_openblas :
161
170
libname = lib_openblas
162
171
else :
@@ -766,10 +775,11 @@ def show_new_gui():
766
775
(lib_openblas , "Use OpenBLAS" ),
767
776
(lib_clblast , "Use CLBlast" ),
768
777
(lib_cublas , "Use CuBLAS" ),
778
+ (lib_hipblas , "Use hipBLAS (ROCm)" ),
769
779
(lib_default , "Use No BLAS" ),
770
780
(lib_noavx2 , "NoAVX2 Mode (Old CPU)" ),
771
781
(lib_failsafe , "Failsafe Mode (Old CPU)" )]
772
- openblas_option , clblast_option , cublas_option , default_option , noavx2_option , failsafe_option = (opt if file_exists (lib ) or (os .name == 'nt' and file_exists (opt + ".dll" )) else None for lib , opt in lib_option_pairs )
782
+ openblas_option , clblast_option , cublas_option , hipblas_option , default_option , noavx2_option , failsafe_option = (opt if file_exists (lib ) or (os .name == 'nt' and file_exists (opt + ".dll" )) else None for lib , opt in lib_option_pairs )
773
783
# slider data
774
784
blasbatchsize_values = ["-1" , "32" , "64" , "128" , "256" , "512" , "1024" , "2048" ]
775
785
blasbatchsize_text = ["Don't Batch BLAS" ,"32" ,"64" ,"128" ,"256" ,"512" ,"1024" ,"2048" ]
@@ -922,15 +932,15 @@ def setup_backend_tooltip(parent):
922
932
923
933
def changerunmode (a ,b ,c ):
924
934
index = runopts_var .get ()
925
- if index == "Use CLBlast" or index == "Use CuBLAS" :
935
+ if index == "Use CLBlast" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
926
936
gpu_selector_label .grid (row = 3 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
927
937
quick_gpu_selector_label .grid (row = 3 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
928
938
if index == "Use CLBlast" :
929
939
gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
930
940
quick_gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
931
941
if gpu_choice_var .get ()== "All" :
932
942
gpu_choice_var .set ("1" )
933
- elif index == "Use CuBLAS" :
943
+ elif index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
934
944
CUDA_gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
935
945
CUDA_quick_gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
936
946
else :
@@ -941,7 +951,7 @@ def changerunmode(a,b,c):
941
951
quick_gpu_selector_box .grid_forget ()
942
952
CUDA_quick_gpu_selector_box .grid_forget ()
943
953
944
- if index == "Use CuBLAS" :
954
+ if index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
945
955
lowvram_box .grid (row = 4 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
946
956
quick_lowvram_box .grid (row = 4 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
947
957
mmq_box .grid (row = 4 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
@@ -952,7 +962,7 @@ def changerunmode(a,b,c):
952
962
mmq_box .grid_forget ()
953
963
quick_mmq_box .grid_forget ()
954
964
955
- if index == "Use CLBlast" or index == "Use CuBLAS" :
965
+ if index == "Use CLBlast" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
956
966
gpu_layers_label .grid (row = 5 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
957
967
gpu_layers_entry .grid (row = 5 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
958
968
quick_gpu_layers_label .grid (row = 5 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
@@ -1147,7 +1157,7 @@ def export_vars():
1147
1157
gpuchoiceidx = int (gpu_choice_var .get ())- 1
1148
1158
if runopts_var .get () == "Use CLBlast" :
1149
1159
args .useclblast = [[0 ,0 ], [1 ,0 ], [0 ,1 ], [1 ,1 ]][gpuchoiceidx ]
1150
- if runopts_var .get () == "Use CuBLAS" :
1160
+ if runopts_var .get () == "Use CuBLAS" or runopts_var . get () == "Use hipBLAS (ROCm)" :
1151
1161
if gpu_choice_var .get ()== "All" :
1152
1162
args .usecublas = ["lowvram" ] if lowvram_var .get () == 1 else ["normal" ]
1153
1163
else :
@@ -1204,8 +1214,11 @@ def import_vars(dict):
1204
1214
runopts_var .set (clblast_option )
1205
1215
gpu_choice_var .set (str (["0 0" , "1 0" , "0 1" , "1 1" ].index (str (dict ["useclblast" ][0 ]) + " " + str (dict ["useclblast" ][1 ])) + 1 ))
1206
1216
elif "usecublas" in dict and dict ["usecublas" ]:
1207
- if cublas_option is not None :
1208
- runopts_var .set (cublas_option )
1217
+ if cublas_option is not None or hipblas_option is not None :
1218
+ if cublas_option :
1219
+ runopts_var .set (cublas_option )
1220
+ elif hipblas_option :
1221
+ runopts_var .set (cublas_option )
1209
1222
lowvram_var .set (1 if "lowvram" in dict ["usecublas" ] else 0 )
1210
1223
mmq_var .set (1 if "mmq" in dict ["usecublas" ] else 0 )
1211
1224
gpu_choice_var .set ("All" )
0 commit comments