diff --git a/scripts/distributed.py b/scripts/distributed.py index ec92e0c..e5f84a9 100644 --- a/scripts/distributed.py +++ b/scripts/distributed.py @@ -10,7 +10,7 @@ import re import signal import sys import time -from threading import Thread, current_thread +from threading import Thread from typing import List import gradio import urllib3 @@ -330,7 +330,8 @@ class Script(scripts.Script): payload_temp['seed'] += prior_images if payload_temp['subseed_strength'] == 0 else 0 logger.debug( f"'{job.worker.label}' job's given starting seed is " - f"{payload_temp['seed']} with {prior_images} coming before it") + f"{payload_temp['seed']} with {prior_images} coming before it" + ) if job.worker.loaded_model != name or job.worker.loaded_vae != vae: sync = True diff --git a/scripts/spartan/pmodels.py b/scripts/spartan/pmodels.py index 45c8c5b..e349dc8 100644 --- a/scripts/spartan/pmodels.py +++ b/scripts/spartan/pmodels.py @@ -42,4 +42,4 @@ class ConfigModel(BaseModel): job_timeout: Optional[int] = Field(default=3) enabled: Optional[bool] = Field(description="Whether the extension as a whole should be active or disabled", default=True) complement_production: Optional[bool] = Field(description="Whether to generate complementary images to prevent under-utilizing hardware", default=True) - step_reduction: Optional[bool] = Field(description="Whether to downscale requested steps in order to meet time constraints") + step_scaling: Optional[bool] = Field(description="Whether to downscale requested steps in order to meet time constraints", default=False) diff --git a/scripts/spartan/shared.py b/scripts/spartan/shared.py index 52512b7..5400464 100644 --- a/scripts/spartan/shared.py +++ b/scripts/spartan/shared.py @@ -61,7 +61,7 @@ logger.addHandler(gui_handler) # end logging warmup_samples = 2 # number of samples to do before recording a valid benchmark sample -samples = 4 # number of times to benchmark worker after warmup benchmarks are completed +samples = 3 # number of times to benchmark worker after warmup benchmarks are completed class BenchmarkPayload(BaseModel): diff --git a/scripts/spartan/ui.py b/scripts/spartan/ui.py index bbcdd74..d0f4d27 100644 --- a/scripts/spartan/ui.py +++ b/scripts/spartan/ui.py @@ -85,10 +85,8 @@ class UI: """updates the options visible on the settings tab""" self.world.thin_client_mode = thin_client_mode - logger.debug(f"thin client mode is now {thin_client_mode}") job_timeout = int(job_timeout) self.world.job_timeout = job_timeout - logger.debug(f"job timeout is now {job_timeout} seconds") self.world.complement_production = complement_production self.world.step_scaling = step_scaling self.world.save_config() @@ -216,7 +214,6 @@ class UI: interactive=True ) main_toggle.input(self.main_toggle_btn) - setattr(main_toggle, 'do_not_save_to_config', True) # ui_loadsave.py apply_field() components.append(main_toggle) with gradio.Tab('Status') as status_tab: @@ -355,13 +352,13 @@ class UI: with gradio.Tab('Settings'): thin_client_cbx = gradio.Checkbox( label='Thin-client mode', - info="Only generate images using remote workers. There will be no previews (yet) when enabled.", + info="Only generate images remotely (no image previews yet)", value=self.world.thin_client_mode ) job_timeout = gradio.Number( label='Job timeout', value=self.world.job_timeout, info="Seconds until a worker is considered too slow to be assigned an" - " equal share of the total request. Longer than 2 seconds is recommended." + " equal share of the total request. Longer than 2 seconds is recommended" ) complement_production = gradio.Checkbox( @@ -390,4 +387,7 @@ class UI: """ ) + # prevent wui from overriding any values + for component in components: + setattr(component, 'do_not_save_to_config', True) # ui_loadsave.py apply_field() return components diff --git a/scripts/spartan/world.py b/scripts/spartan/world.py index 5156cc6..1b2bfcb 100644 --- a/scripts/spartan/world.py +++ b/scripts/spartan/world.py @@ -353,7 +353,7 @@ class World: return lag - def update_jobs(self): + def make_jobs(self): """creates initial jobs (before optimization) """ # clear jobs if this is not the first time running @@ -367,6 +367,7 @@ class World: worker.benchmark() self.jobs.append(Job(worker=worker, batch_size=batch_size)) + logger.debug(f"added job for worker {worker.label}") def update(self, p): """preps world for another run""" @@ -378,7 +379,7 @@ class World: logger.debug("world was already initialized") self.p = p - self.update_jobs() + self.make_jobs() def get_workers(self): filtered: List[Worker] = [] @@ -525,7 +526,7 @@ class World: if num_images_compensate == 0 and self.step_scaling: seconds_per_sample = job.worker.eta(payload=payload, batch_size=1, samples=1) realtime_samples = slack_time // seconds_per_sample - logger.critical( + logger.debug( f"job for '{job.worker.label}' downscaled to {realtime_samples} samples to meet time constraints\n" f"{realtime_samples:.0f} samples = {slack_time:.2f}s slack รท {seconds_per_sample:.2f}s/sample\n" f" step reduction: {payload['steps']} -> {realtime_samples:.0f}" @@ -652,7 +653,7 @@ class World: self.job_timeout = config.job_timeout self.enabled = config.enabled self.complement_production = config.complement_production - self.step_scaling = config.step_reduction + self.step_scaling = config.step_scaling logger.debug("config loaded")