From 8eca587825dfe50ff1ddde4dba2cb3b76cb93db5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 19 Mar 2023 10:28:24 -0500 Subject: [PATCH] set flag so that MPE is actually utilized --- README.md | 1 + preload.py | 6 ++++++ scripts/spartan/World.py | 37 ++++++++++++++++++++++++++----------- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f8ec931..e076748 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,4 @@ On each slave instance: **--distributed-remotes** Enter n pairs of sockets corresponding to remote workers in the form `name:address:port`\ **--distributed-skip-verify-remotes** Disable verification of remote worker TLS certificates (useful for if you are using self-signed certs like with auto tls-https)\ **--distributed-remotes-autosave** Enable auto-saving of remote worker generations +**--distributed-debug** Enable debug information diff --git a/preload.py b/preload.py index d00cd1d..a8c4977 100644 --- a/preload.py +++ b/preload.py @@ -17,4 +17,10 @@ def preload(parser): help="Enable auto-saving of remote worker generations", action="store_true" ) + + parser.add_argument( + "--distributed-debug", + help="Enable debug information", + action="store_true" + ) # args = parser.parse_args() diff --git a/scripts/spartan/World.py b/scripts/spartan/World.py index d6d3985..440dafa 100644 --- a/scripts/spartan/World.py +++ b/scripts/spartan/World.py @@ -17,6 +17,8 @@ from inspect import getsourcefile from os.path import abspath from pathlib import Path from modules.processing import process_images +from webui import server_name +from modules.shared import cmd_opts # from modules.processing import StableDiffusionProcessing, StableDiffusionProcessingTxt2Img @@ -114,9 +116,15 @@ class Worker: if master is True: self.master = master self.uuid = 'master' - # TODO get real ipm of main instance # set to a sentinel value to avoid issues with speed comparisons self.avg_ipm = 0 + + # right now this is really only for clarity while debugging: + self.address = server_name + if cmd_opts.port is None: + self.port = 7860 + else: + self.port = cmd_opts.port return self.address = address @@ -236,9 +244,9 @@ class Worker: try: percent_difference = self.other_to_euler_a[payload['sampler_name']] if percent_difference > 0: - eta = eta - (eta * abs((percent_difference / 100))) + eta -= (eta * abs((percent_difference / 100))) else: - eta = eta + (eta * abs((percent_difference / 100))) + eta += (eta * abs((percent_difference / 100))) except KeyError: print(f"Sampler '{payload['sampler_name']}' efficiency is not recorded.\n") print(f"Sampler efficiency will be treated as equivalent to Euler A.") @@ -247,13 +255,15 @@ class Worker: # That way initial estimations are more accurate from the second sdwui session onward # adjust for a known inaccuracy in our estimation of this worker using average percent error if len(self.eta_percent_error) > 0: - # eta = eta / (1 - self.eta_mpe() / 100) correction = eta * (self.eta_mpe() / 100) - print(f"worker '{self.uuid}' with correction +{eta + correction} - {eta - correction}") + + if cmd_opts.distributed_debug: + print(f"worker '{self.uuid}'s ETA was off by {correction}%") + if correction > 0: - eta = eta + correction + eta += correction else: - eta = eta - correction + eta -= correction return eta except Exception as e: @@ -314,8 +324,10 @@ class Worker: if self.benchmarked: self.response_time = time.time() - start variance = ((eta - self.response_time) / self.response_time) * 100 - print(f"\nWorker '{self.uuid}' was off by {variance:.2f}%.\n") - print(f"Predicted {eta:.2f}s. Actual: {self.response_time:.2f}s\n") + + if cmd_opts.distributed_debug: + print(f"\nWorker '{self.uuid}'s ETA was off by {variance:.2f}%.\n") + print(f"Predicted {eta:.2f}s. Actual: {self.response_time:.2f}s\n") if self.eta_percent_error == 0: self.eta_percent_error[0] = variance @@ -551,9 +563,12 @@ class World: if not benchmark_payload_loaded: benchmark_payload = workers_info[worker.uuid]['benchmark_payload'] benchmark_payload_loaded = True - print("loaded saved worker configuration:") - print(workers_info) + + if cmd_opts.distributed_debug: + print("loaded saved worker configuration:") + print(workers_info) worker.avg_ipm = workers_info[worker.uuid]['avg_ipm'] + worker.benchmarked = True workers_info.update(worker.info(benchmark_payload=benchmark_payload))