Skip to content

Commit 18b24ae

Browse files
committed
replace the notile option with a configurable threshold
This allows selecting a lower threshold value, reducing the peak memory usage. The legacy sdnotile parameter gets automatically converted to the new parameter, if it's the only one supplied.
1 parent 496e5f2 commit 18b24ae

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

koboldcpp.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ def sd_load_model(model_filename,vae_filename,lora_filename,t5xxl_filename,clipl
15491549
inputs.threads = thds
15501550
inputs.quant = quant
15511551
inputs.taesd = True if args.sdvaeauto else False
1552-
inputs.tiled_vae_threshold = -1 if args.sdnotile else 0
1552+
inputs.tiled_vae_threshold = args.sdtiledvae
15531553
inputs.vae_filename = vae_filename.encode("UTF-8")
15541554
inputs.lora_filename = lora_filename.encode("UTF-8")
15551555
inputs.lora_multiplier = args.sdloramult
@@ -4303,7 +4303,7 @@ def hide_tooltip(event):
43034303
sd_clipg_var = ctk.StringVar()
43044304
sd_photomaker_var = ctk.StringVar()
43054305
sd_vaeauto_var = ctk.IntVar(value=0)
4306-
sd_notile_var = ctk.IntVar(value=0)
4306+
sd_tiled_vae_var = ctk.StringVar(value="")
43074307
sd_clamped_var = ctk.StringVar(value="0")
43084308
sd_clamped_soft_var = ctk.StringVar(value="0")
43094309
sd_threads_var = ctk.StringVar(value=str(default_threads))
@@ -5033,7 +5033,7 @@ def toggletaesd(a,b,c):
50335033
sdvaeitem2.grid()
50345034
sdvaeitem3.grid()
50355035
makecheckbox(images_tab, "Use TAE SD (AutoFix Broken VAE)", sd_vaeauto_var, 42,command=toggletaesd,tooltiptxt="Replace VAE with TAESD. May fix bad VAE.")
5036-
makecheckbox(images_tab, "No VAE Tiling", sd_notile_var, 44,tooltiptxt="Disables VAE tiling, may not work for large images.")
5036+
makelabelentry(images_tab, "VAE Tiling Above:", sd_tiled_vae_var, 44, 50, padx=190,singleline=True,tooltip="Enable VAE Tiling for images above this size, to save memory.\n-1 disables tiling for all images. Leave at 0 for the default limit (768).")
50375037

50385038
# audio tab
50395039
audio_tab = tabcontent["Audio"]
@@ -5266,7 +5266,7 @@ def export_vars():
52665266
args.sdthreads = (0 if sd_threads_var.get()=="" else int(sd_threads_var.get()))
52675267
args.sdclamped = (0 if int(sd_clamped_var.get())<=0 else int(sd_clamped_var.get()))
52685268
args.sdclampedsoft = (0 if int(sd_clamped_soft_var.get())<=0 else int(sd_clamped_soft_var.get()))
5269-
args.sdnotile = (True if sd_notile_var.get()==1 else False)
5269+
args.sdtiledvae = (0 if sd_tiled_vae_var.get()=="" else int(sd_tiled_vae_var.get()))
52705270
if sd_vaeauto_var.get()==1:
52715271
args.sdvaeauto = True
52725272
args.sdvae = ""
@@ -5488,7 +5488,8 @@ def import_vars(dict):
54885488
sd_clipg_var.set(dict["sdclipg"] if ("sdclipg" in dict and dict["sdclipg"]) else "")
54895489
sd_photomaker_var.set(dict["sdphotomaker"] if ("sdphotomaker" in dict and dict["sdphotomaker"]) else "")
54905490
sd_vaeauto_var.set(1 if ("sdvaeauto" in dict and dict["sdvaeauto"]) else 0)
5491-
sd_notile_var.set(1 if ("sdnotile" in dict and dict["sdnotile"]) else 0)
5491+
sd_tiled_vae_var.set(int(dict["sdtiledvae"]) if ("sdtiledvae" in dict and dict["sdtiledvae"]) else 0)
5492+
54925493
sd_lora_var.set(dict["sdlora"] if ("sdlora" in dict and dict["sdlora"]) else "")
54935494
sd_loramult_var.set(str(dict["sdloramult"]) if ("sdloramult" in dict and dict["sdloramult"]) else "1.0")
54945495

@@ -5856,6 +5857,8 @@ def convert_invalid_args(args):
58565857
dict["model_param"] = model_value
58575858
elif isinstance(model_value, list) and model_value: # Non-empty list
58585859
dict["model_param"] = model_value[0] # Take the first file in the list
5860+
if "sdnotile" in dict and ("sdtiledvae" not in dict or dict["sdtiledvae"] == 0):
5861+
dict["sdtiledvae"] = (-1 if dict["sdnotile"] else 0) # convert legacy option
58595862
return args
58605863

58615864
def setuptunnel(global_memory, has_sd):
@@ -7269,8 +7272,8 @@ def range_checker(arg: str):
72697272
sdparsergrouplora.add_argument("--sdquant", help="If specified, loads the model quantized to save memory.", action='store_true')
72707273
sdparsergrouplora.add_argument("--sdlora", metavar=('[filename]'), help="Specify an image generation LORA safetensors model to be applied.", default="")
72717274
sdparsergroup.add_argument("--sdloramult", metavar=('[amount]'), help="Multiplier for the image LORA model to be applied.", type=float, default=1.0)
7272-
sdparsergroup.add_argument("--sdnotile", help="Disables VAE tiling, may not work for large images.", action='store_true')
7273-
7275+
sdparsergroup.add_argument("--sdtiledvae", metavar=('[maxres]'), help="Adjust the automatic VAE tiling trigger for images above this size. 1 will always use tiling, -1 disables it for all images; 0 or unspecified uses the default 768", type=int, default=0)
7276+
sdparsergroup.add_argument("--sdnotile", help=argparse.SUPPRESS, action='store_true') # legacy option, see sdtiledvae
72747277
whisperparsergroup = parser.add_argument_group('Whisper Transcription Commands')
72757278
whisperparsergroup.add_argument("--whispermodel", metavar=('[filename]'), help="Specify a Whisper .bin model to enable Speech-To-Text transcription.", default="")
72767279

0 commit comments

Comments
 (0)