@@ -377,33 +377,38 @@ def pick_existant_file(ntoption,nonntoption):
377377lib_noavx2 = pick_existant_file ("koboldcpp_noavx2.dll" ,"koboldcpp_noavx2.so" )
378378lib_clblast = pick_existant_file ("koboldcpp_clblast.dll" ,"koboldcpp_clblast.so" )
379379lib_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" )
380381lib_cublas = pick_existant_file ("koboldcpp_cublas.dll" ,"koboldcpp_cublas.so" )
381382lib_hipblas = pick_existant_file ("koboldcpp_hipblas.dll" ,"koboldcpp_hipblas.so" )
382383lib_vulkan = pick_existant_file ("koboldcpp_vulkan.dll" ,"koboldcpp_vulkan.so" )
383384lib_vulkan_noavx2 = pick_existant_file ("koboldcpp_vulkan_noavx2.dll" ,"koboldcpp_vulkan_noavx2.so" )
384385libname = ""
385386lib_option_pairs = [
386387 (lib_default , "Use CPU" ),
387- (lib_clblast , "Use CLBlast" ),
388388 (lib_cublas , "Use CuBLAS" ),
389389 (lib_hipblas , "Use hipBLAS (ROCm)" ),
390390 (lib_vulkan , "Use Vulkan" ),
391+ (lib_clblast , "Use CLBlast" ),
391392 (lib_noavx2 , "Use CPU (Old CPU)" ),
392393 (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)" ),
394396 (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 )
396398runopts = [opt for lib , opt in lib_option_pairs if file_exists (lib )]
397399
398400def init_library ():
399401 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
401403
402404 libname = lib_default
403405
404406 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
407412 elif (args .usevulkan is not None ) and file_exists (lib_vulkan_noavx2 ):
408413 libname = lib_vulkan_noavx2
409414 elif (args .failsafe ) and file_exists (lib_failsafe ):
@@ -3425,7 +3430,7 @@ def setup_backend_tooltip(parent):
34253430 # backend count label with the tooltip function
34263431 nl = '\n '
34273432 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 )
34293434 num_backends_built .grid (row = 1 , column = 1 , padx = 205 , pady = 0 )
34303435 num_backends_built .configure (text_color = "#00ff00" )
34313436
@@ -3446,7 +3451,7 @@ def changed_gpulayers_estimate(*args):
34463451 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 ())]))
34473452 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 "" )
34483453 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)" )
34503455 layercounter_label .grid (row = 6 , column = 1 , padx = 75 , sticky = "W" )
34513456 quick_layercounter_label .grid (row = 6 , column = 1 , padx = 75 , sticky = "W" )
34523457 if sys .platform == "darwin" and gpulayers_var .get ()== "-1" :
@@ -3477,7 +3482,7 @@ def changed_gpu_choice_var(*args):
34773482 if v == "Use Vulkan" or v == "Use Vulkan (Old CPU)" :
34783483 quick_gpuname_label .configure (text = VKDevicesNames [s ])
34793484 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)" :
34813486 quick_gpuname_label .configure (text = CLDevicesNames [s ])
34823487 gpuname_label .configure (text = CLDevicesNames [s ])
34833488 else :
@@ -3534,12 +3539,12 @@ def changerunmode(a,b,c):
35343539 global runmode_untouched
35353540 runmode_untouched = False
35363541 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)" :
35383543 quick_gpuname_label .grid (row = 3 , column = 1 , padx = 75 , sticky = "W" )
35393544 gpuname_label .grid (row = 3 , column = 1 , padx = 75 , sticky = "W" )
35403545 gpu_selector_label .grid (row = 3 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
35413546 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)" :
35433548 gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
35443549 quick_gpu_selector_box .grid (row = 3 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
35453550 CUDA_gpu_selector_box .grid_remove ()
@@ -3583,7 +3588,7 @@ def changerunmode(a,b,c):
35833588 else :
35843589 quick_use_flashattn .grid (row = 22 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
35853590
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)" :
35873592 gpu_layers_label .grid (row = 6 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
35883593 gpu_layers_entry .grid (row = 6 , column = 1 , padx = 8 , pady = 1 , stick = "nw" )
35893594 quick_gpu_layers_label .grid (row = 6 , column = 0 , padx = 8 , pady = 1 , stick = "nw" )
@@ -3954,10 +3959,13 @@ def export_vars():
39543959 args .noavx2 = False
39553960 if gpu_choice_var .get ()!= "All" :
39563961 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)" :
39583963 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)" :
39603965 args .noavx2 = True
3966+ elif runopts_var .get () == "Use CLBlast (Older CPU)" :
3967+ args .noavx2 = True
3968+ args .failsafe = True
39613969 if runopts_var .get () == "Use CuBLAS" or runopts_var .get () == "Use hipBLAS (ROCm)" :
39623970 if gpu_choice_var .get ()== "All" :
39633971 args .usecublas = ["lowvram" ] if lowvram_var .get () == 1 else ["normal" ]
@@ -4926,6 +4934,9 @@ def main(launch_args,start_server=True):
49264934 if args .quantkv and args .quantkv > 0 and not args .flashattention :
49274935 exit_with_error (1 , "Error: Using --quantkv requires --flashattention" )
49284936
4937+ if args .failsafe : #failsafe implies noavx2
4938+ args .noavx2 = True
4939+
49294940 if not args .model_param :
49304941 args .model_param = args .model
49314942
@@ -5596,7 +5607,7 @@ def range_checker(arg: str):
55965607 compatgroup3 .add_argument ("--usemmap" , help = "If set, uses mmap to load model. This model will not be unloadable." , action = 'store_true' )
55975608 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' )
55985609 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' )
56005611 advparser .add_argument ("--debugmode" , help = "Shows additional debug info in the terminal." , nargs = '?' , const = 1 , type = int , default = 0 )
56015612 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 )
56025613 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