Skip to content

Commit 852ca78

Browse files
committed
cherrypicked the Hipblas fixed from PR #571
1 parent 77463e0 commit 852ca78

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

koboldcpp.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def bring_terminal_to_foreground():
408408
currentusergenkey = "" #store a special key so polled streaming works even in multiuser
409409
args = None #global args
410410
gui_layers_untouched = True
411+
runmode_untouched = True
411412
preloaded_story = None
412413
sslvalid = False
413414

@@ -1288,12 +1289,13 @@ def auto_gpu_heuristics():
12881289
MaxMemory[0] = max(int(FetchedCUdeviceMem[idx])*1024*1024,MaxMemory[0])
12891290

12901291
#autopick cublas if suitable, requires at least 3.5GB VRAM to auto pick
1291-
global exitcounter
1292-
if exitcounter < 100 and MaxMemory[0]>3500000000 and CUDevicesNames[0]!="" and ("Use CuBLAS" in runopts or "Use hipBLAS (ROCM)" in runopts) and runopts_var.get()=="Use OpenBLAS":
1292+
global exitcounter, runmode_untouched
1293+
#we do not want to autoselect hip/cublas if the user has already changed their desired backend!
1294+
if exitcounter < 100 and MaxMemory[0]>3500000000 and (("Use CuBLAS" in runopts and CUDevicesNames[0]!="") or "Use hipBLAS (ROCm)" in runopts) and (any(CUDevicesNames) or any(CLDevicesNames)) and runmode_untouched:
12931295
if "Use CuBLAS" in runopts:
12941296
runopts_var.set("Use CuBLAS")
1295-
elif "Use hipBLAS (ROCM)" in runopts:
1296-
runopts_var.set("Use hipBLAS (ROCM)")
1297+
elif "Use hipBLAS (ROCm)" in runopts:
1298+
runopts_var.set("Use hipBLAS (ROCm)")
12971299

12981300
changed_gpu_choice_var()
12991301
return
@@ -1394,6 +1396,8 @@ def changed_gpu_choice_var(*args):
13941396
gpulayers_var.trace("w", changed_gpulayers)
13951397

13961398
def changerunmode(a,b,c):
1399+
global runmode_untouched
1400+
runmode_untouched = False
13971401
index = runopts_var.get()
13981402
if index == "Use CLBlast" or index == "CLBlast NoAVX2 (Old CPU)" or index == "Use CuBLAS" or index == "Use hipBLAS (ROCm)":
13991403
quick_gpuname_label.grid(row=3, column=1, padx=75, sticky="W")
@@ -1525,6 +1529,8 @@ def changerunmode(a,b,c):
15251529

15261530
runopts_var.trace('w', changerunmode)
15271531
changerunmode(1,1,1)
1532+
global runmode_untouched
1533+
runmode_untouched = True
15281534

15291535
# Tokens Tab
15301536
tokens_tab = tabcontent["Tokens"]
@@ -1704,7 +1710,7 @@ def import_vars(dict):
17041710
if cublas_option:
17051711
runopts_var.set(cublas_option)
17061712
elif hipblas_option:
1707-
runopts_var.set(cublas_option)
1713+
runopts_var.set(hipblas_option)
17081714
lowvram_var.set(1 if "lowvram" in dict["usecublas"] else 0)
17091715
mmq_var.set(1 if "mmq" in dict["usecublas"] else 0)
17101716
gpu_choice_var.set("All")

0 commit comments

Comments
 (0)