Skip to content

Commit df69607

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 6570136 commit df69607

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
@@ -1540,7 +1540,7 @@ def sd_load_model(model_filename,vae_filename,lora_filename,t5xxl_filename,clipl
15401540
inputs.threads = thds
15411541
inputs.quant = quant
15421542
inputs.taesd = True if args.sdvaeauto else False
1543-
inputs.tiled_vae_threshold = -1 if args.sdnotile else 0
1543+
inputs.tiled_vae_threshold = args.sdtiledvae
15441544
inputs.vae_filename = vae_filename.encode("UTF-8")
15451545
inputs.lora_filename = lora_filename.encode("UTF-8")
15461546
inputs.lora_multiplier = args.sdloramult
@@ -4289,7 +4289,7 @@ def hide_tooltip(event):
42894289
sd_clipl_var = ctk.StringVar()
42904290
sd_clipg_var = ctk.StringVar()
42914291
sd_vaeauto_var = ctk.IntVar(value=0)
4292-
sd_notile_var = ctk.IntVar(value=0)
4292+
sd_tiled_vae_var = ctk.StringVar(value="")
42934293
sd_clamped_var = ctk.StringVar(value="0")
42944294
sd_clamped_soft_var = ctk.StringVar(value="0")
42954295
sd_threads_var = ctk.StringVar(value=str(default_threads))
@@ -5020,7 +5020,7 @@ def toggletaesd(a,b,c):
50205020
sdvaeitem2.grid()
50215021
sdvaeitem3.grid()
50225022
makecheckbox(images_tab, "Use TAE SD (AutoFix Broken VAE)", sd_vaeauto_var, 32,command=toggletaesd,tooltiptxt="Replace VAE with TAESD. May fix bad VAE.")
5023-
makecheckbox(images_tab, "No VAE Tiling", sd_notile_var, 34,tooltiptxt="Disables VAE tiling, may not work for large images.")
5023+
makelabelentry(images_tab, "VAE Tiling Above:", sd_tiled_vae_var, 34, 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).")
50245024

50255025
# audio tab
50265026
audio_tab = tabcontent["Audio"]
@@ -5253,7 +5253,7 @@ def export_vars():
52535253
args.sdthreads = (0 if sd_threads_var.get()=="" else int(sd_threads_var.get()))
52545254
args.sdclamped = (0 if int(sd_clamped_var.get())<=0 else int(sd_clamped_var.get()))
52555255
args.sdclampedsoft = (0 if int(sd_clamped_soft_var.get())<=0 else int(sd_clamped_soft_var.get()))
5256-
args.sdnotile = (True if sd_notile_var.get()==1 else False)
5256+
args.sdtiledvae = (0 if sd_tiled_vae_var.get()=="" else int(sd_tiled_vae_var.get()))
52575257
if sd_vaeauto_var.get()==1:
52585258
args.sdvaeauto = True
52595259
args.sdvae = ""
@@ -5472,7 +5472,8 @@ def import_vars(dict):
54725472
sd_clipl_var.set(dict["sdclipl"] if ("sdclipl" in dict and dict["sdclipl"]) else "")
54735473
sd_clipg_var.set(dict["sdclipg"] if ("sdclipg" in dict and dict["sdclipg"]) else "")
54745474
sd_vaeauto_var.set(1 if ("sdvaeauto" in dict and dict["sdvaeauto"]) else 0)
5475-
sd_notile_var.set(1 if ("sdnotile" in dict and dict["sdnotile"]) else 0)
5475+
sd_tiled_vae_var.set(int(dict["sdtiledvae"]) if ("sdtiledvae" in dict and dict["sdtiledvae"]) else 0)
5476+
54765477
sd_lora_var.set(dict["sdlora"] if ("sdlora" in dict and dict["sdlora"]) else "")
54775478
sd_loramult_var.set(str(dict["sdloramult"]) if ("sdloramult" in dict and dict["sdloramult"]) else "1.0")
54785479

@@ -5840,6 +5841,8 @@ def convert_invalid_args(args):
58405841
dict["model_param"] = model_value
58415842
elif isinstance(model_value, list) and model_value: # Non-empty list
58425843
dict["model_param"] = model_value[0] # Take the first file in the list
5844+
if "sdnotile" in dict and ("sdtiledvae" not in dict or dict["sdtiledvae"] == 0):
5845+
dict["sdtiledvae"] = (-1 if dict["sdnotile"] else 0) # convert legacy option
58435846
return args
58445847

58455848
def setuptunnel(global_memory, has_sd):
@@ -7242,8 +7245,8 @@ def range_checker(arg: str):
72427245
sdparsergrouplora.add_argument("--sdquant", help="If specified, loads the model quantized to save memory.", action='store_true')
72437246
sdparsergrouplora.add_argument("--sdlora", metavar=('[filename]'), help="Specify an image generation LORA safetensors model to be applied.", default="")
72447247
sdparsergroup.add_argument("--sdloramult", metavar=('[amount]'), help="Multiplier for the image LORA model to be applied.", type=float, default=1.0)
7245-
sdparsergroup.add_argument("--sdnotile", help="Disables VAE tiling, may not work for large images.", action='store_true')
7246-
7248+
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)
7249+
sdparsergroup.add_argument("--sdnotile", help=argparse.SUPPRESS, action='store_true') # legacy option, see sdtiledvae
72477250
whisperparsergroup = parser.add_argument_group('Whisper Transcription Commands')
72487251
whisperparsergroup.add_argument("--whispermodel", metavar=('[filename]'), help="Specify a Whisper .bin model to enable Speech-To-Text transcription.", default="")
72497252

0 commit comments

Comments
 (0)