@@ -377,33 +377,38 @@ def pick_existant_file(ntoption,nonntoption):
377
377
lib_noavx2 = pick_existant_file ("koboldcpp_noavx2.dll" ,"koboldcpp_noavx2.so" )
378
378
lib_clblast = pick_existant_file ("koboldcpp_clblast.dll" ,"koboldcpp_clblast.so" )
379
379
lib_clblast_noavx2 = pick_existant_file ("koboldcpp_clblast_noavx2.dll" ,"koboldcpp_clblast_noavx2.so" )
380
+ lib_clblast_failsafe = pick_existant_file ("koboldcpp_clblast_failsafe.dll" ,"koboldcpp_clblast_failsafe.so" )
380
381
lib_cublas = pick_existant_file ("koboldcpp_cublas.dll" ,"koboldcpp_cublas.so" )
381
382
lib_hipblas = pick_existant_file ("koboldcpp_hipblas.dll" ,"koboldcpp_hipblas.so" )
382
383
lib_vulkan = pick_existant_file ("koboldcpp_vulkan.dll" ,"koboldcpp_vulkan.so" )
383
384
lib_vulkan_noavx2 = pick_existant_file ("koboldcpp_vulkan_noavx2.dll" ,"koboldcpp_vulkan_noavx2.so" )
384
385
libname = ""
385
386
lib_option_pairs = [
386
387
(lib_default , "Use CPU" ),
387
- (lib_clblast , "Use CLBlast" ),
388
388
(lib_cublas , "Use CuBLAS" ),
389
389
(lib_hipblas , "Use hipBLAS (ROCm)" ),
390
390
(lib_vulkan , "Use Vulkan" ),
391
+ (lib_clblast , "Use CLBlast" ),
391
392
(lib_noavx2 , "Use CPU (Old CPU)" ),
392
393
(lib_vulkan_noavx2 , "Use Vulkan (Old CPU)" ),
393
- (lib_clblast_noavx2 , "Use CLBlast (Older CPU)" ),
394
+ (lib_clblast_noavx2 , "Use CLBlast (Old CPU)" ),
395
+ (lib_clblast_failsafe , "Use CLBlast (Older CPU)" ),
394
396
(lib_failsafe , "Failsafe Mode (Older CPU)" )]
395
- default_option , clblast_option , cublas_option , hipblas_option , vulkan_option , noavx2_option , vulkan_noavx2_option , clblast_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 )
397
+ default_option , cublas_option , hipblas_option , vulkan_option , clblast_option , noavx2_option , vulkan_noavx2_option , clblast_noavx2_option , clblast_failsafe_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 )
396
398
runopts = [opt for lib , opt in lib_option_pairs if file_exists (lib )]
397
399
398
400
def init_library ():
399
401
global handle , args , libname
400
- global lib_default ,lib_failsafe ,lib_noavx2 ,lib_clblast ,lib_clblast_noavx2 ,lib_cublas ,lib_hipblas ,lib_vulkan ,lib_vulkan_noavx2
402
+ global lib_default ,lib_failsafe ,lib_noavx2 ,lib_clblast ,lib_clblast_noavx2 ,lib_clblast_failsafe , lib_cublas ,lib_hipblas ,lib_vulkan ,lib_vulkan_noavx2
401
403
402
404
libname = lib_default
403
405
404
406
if args .noavx2 :
405
- if args .useclblast and file_exists (lib_clblast_noavx2 ) and (os .name != 'nt' or file_exists ("clblast.dll" )):
406
- libname = lib_clblast_noavx2
407
+ if args .useclblast and (os .name != 'nt' or file_exists ("clblast.dll" )):
408
+ if (args .failsafe ) and file_exists (lib_clblast_failsafe ):
409
+ libname = lib_clblast_failsafe
410
+ elif file_exists (lib_clblast_noavx2 ):
411
+ libname = lib_clblast_noavx2
407
412
elif (args .usevulkan is not None ) and file_exists (lib_vulkan_noavx2 ):
408
413
libname = lib_vulkan_noavx2
409
414
elif (args .failsafe ) and file_exists (lib_failsafe ):
@@ -3425,7 +3430,7 @@ def setup_backend_tooltip(parent):
3425
3430
# backend count label with the tooltip function
3426
3431
nl = '\n '
3427
3432
tooltxt = "Number of backends you have built and available." + (f"\n \n Missing Backends: \n \n { nl .join (antirunopts )} " if len (runopts ) < 8 else "" )
3428
- num_backends_built = makelabel (parent , str (len (runopts )) + "/8 " , 5 , 2 ,tooltxt )
3433
+ num_backends_built = makelabel (parent , str (len (runopts )) + "/9 " , 5 , 2 ,tooltxt )
3429
3434
num_backends_built .grid (row = 1 , column = 1 , padx = 205 , pady = 0 )
3430
3435
num_backends_built .configure (text_color = "#00ff00" )
3431
3436
@@ -3446,7 +3451,7 @@ def changed_gpulayers_estimate(*args):
3446
3451
predicted_gpu_layers = autoset_gpu_layers (int (contextsize_text [context_var .get ()]),(sd_quant_var .get ()== 1 ),int (blasbatchsize_values [int (blas_size_var .get ())]))
3447
3452
max_gpu_layers = (f"/{ modelfile_extracted_meta [0 ][0 ]+ 3 } " if (modelfile_extracted_meta and modelfile_extracted_meta [0 ] and modelfile_extracted_meta [0 ][0 ]!= 0 ) else "" )
3448
3453
index = runopts_var .get ()
3449
- gpu_be = (index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" )
3454
+ gpu_be = (index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Old CPU)" or index == "Use CLBlast ( Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" )
3450
3455
layercounter_label .grid (row = 6 , column = 1 , padx = 75 , sticky = "W" )
3451
3456
quick_layercounter_label .grid (row = 6 , column = 1 , padx = 75 , sticky = "W" )
3452
3457
if sys .platform == "darwin" and gpulayers_var .get ()== "-1" :
@@ -3477,7 +3482,7 @@ def changed_gpu_choice_var(*args):
3477
3482
if v == "Use Vulkan" or v == "Use Vulkan (Old CPU)" :
3478
3483
quick_gpuname_label .configure (text = VKDevicesNames [s ])
3479
3484
gpuname_label .configure (text = VKDevicesNames [s ])
3480
- elif v == "Use CLBlast" or v == "Use CLBlast (Older CPU)" :
3485
+ elif v == "Use CLBlast" or v == "Use CLBlast (Old CPU)" or v == "Use CLBlast ( Older CPU)" :
3481
3486
quick_gpuname_label .configure (text = CLDevicesNames [s ])
3482
3487
gpuname_label .configure (text = CLDevicesNames [s ])
3483
3488
else :
@@ -3534,12 +3539,12 @@ def changerunmode(a,b,c):
3534
3539
global runmode_untouched
3535
3540
runmode_untouched = False
3536
3541
index = runopts_var .get ()
3537
- if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
3542
+ if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Old CPU)" or index == "Use CLBlast (Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
3538
3543
quick_gpuname_label .grid (row = 3 , column = 1 , padx = 75 , sticky = "W" )
3539
3544
gpuname_label .grid (row = 3 , column = 1 , padx = 75 , sticky = "W" )
3540
3545
gpu_selector_label .grid (row = 3 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
3541
3546
quick_gpu_selector_label .grid (row = 3 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
3542
- if index == "Use CLBlast" or index == "Use CLBlast (Older CPU)" :
3547
+ if index == "Use CLBlast" or index == "Use CLBlast (Old CPU)" or index == "Use CLBlast ( Older CPU)" :
3543
3548
gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
3544
3549
quick_gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
3545
3550
CUDA_gpu_selector_box .grid_remove ()
@@ -3583,7 +3588,7 @@ def changerunmode(a,b,c):
3583
3588
else :
3584
3589
quick_use_flashattn .grid (row = 22 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
3585
3590
3586
- if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
3591
+ if index == "Use Vulkan" or index == "Use Vulkan (Old CPU)" or index == "Use CLBlast" or index == "Use CLBlast (Old CPU)" or index == "Use CLBlast ( Older CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)" :
3587
3592
gpu_layers_label .grid (row = 6 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
3588
3593
gpu_layers_entry .grid (row = 6 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
3589
3594
quick_gpu_layers_label .grid (row = 6 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
@@ -3954,10 +3959,13 @@ def export_vars():
3954
3959
args .noavx2 = False
3955
3960
if gpu_choice_var .get ()!= "All" :
3956
3961
gpuchoiceidx = int (gpu_choice_var .get ())- 1
3957
- if runopts_var .get () == "Use CLBlast" or runopts_var .get () == "Use CLBlast (Older CPU)" :
3962
+ if runopts_var .get () == "Use CLBlast" or runopts_var .get () == "Use CLBlast (Old CPU)" or runopts_var . get () == "Use CLBlast ( Older CPU)" :
3958
3963
args .useclblast = [[0 ,0 ], [1 ,0 ], [0 ,1 ], [1 ,1 ]][gpuchoiceidx ]
3959
- if runopts_var .get () == "Use CLBlast (Older CPU)" :
3964
+ if runopts_var .get () == "Use CLBlast (Old CPU)" :
3960
3965
args .noavx2 = True
3966
+ elif runopts_var .get () == "Use CLBlast (Older CPU)" :
3967
+ args .noavx2 = True
3968
+ args .failsafe = True
3961
3969
if runopts_var .get () == "Use CuBLAS" or runopts_var .get () == "Use hipBLAS (ROCm)" :
3962
3970
if gpu_choice_var .get ()== "All" :
3963
3971
args .usecublas = ["lowvram" ] if lowvram_var .get () == 1 else ["normal" ]
@@ -4926,6 +4934,9 @@ def main(launch_args,start_server=True):
4926
4934
if args .quantkv and args .quantkv > 0 and not args .flashattention :
4927
4935
exit_with_error (1 , "Error: Using --quantkv requires --flashattention" )
4928
4936
4937
+ if args .failsafe : #failsafe implies noavx2
4938
+ args .noavx2 = True
4939
+
4929
4940
if not args .model_param :
4930
4941
args .model_param = args .model
4931
4942
@@ -5596,7 +5607,7 @@ def range_checker(arg: str):
5596
5607
compatgroup3 .add_argument ("--usemmap" , help = "If set, uses mmap to load model. This model will not be unloadable." , action = 'store_true' )
5597
5608
advparser .add_argument ("--usemlock" , help = "Enables mlock, preventing the RAM used to load the model from being paged out. Not usually recommended." , action = 'store_true' )
5598
5609
advparser .add_argument ("--noavx2" , help = "Do not use AVX2 instructions, a slower compatibility mode for older devices." , action = 'store_true' )
5599
- advparser .add_argument ("--failsafe" , help = "Use failsafe mode, extremely slow CPU only compatibility mode that should work on all devices." , action = 'store_true' )
5610
+ advparser .add_argument ("--failsafe" , help = "Use failsafe mode, extremely slow CPU only compatibility mode that should work on all devices. Can be combined with useclblast if your device supports OpenCL. " , action = 'store_true' )
5600
5611
advparser .add_argument ("--debugmode" , help = "Shows additional debug info in the terminal." , nargs = '?' , const = 1 , type = int , default = 0 )
5601
5612
advparser .add_argument ("--onready" , help = "An optional shell command to execute after the model has been loaded." , metavar = ('[shell command]' ), type = str , default = "" ,nargs = 1 )
5602
5613
advparser .add_argument ("--benchmark" , help = "Do not start server, instead run benchmarks. If filename is provided, appends results to provided file." , metavar = ('[filename]' ), nargs = '?' , const = "stdout" , type = str , default = None )
0 commit comments