Skip to content

Commit

Permalink
feat: reduce batching on flux
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Sep 11, 2024
1 parent ea24368 commit dca63e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions horde/classes/stable/waiting_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
KNOWN_LCM_LORA_VERSIONS,
KNOWN_POST_PROCESSORS,
SECOND_ORDER_SAMPLERS,
BASELINE_BATCHING_MULTIPLIERS,
)
from horde.flask import db
from horde.image import convert_pil_to_b64
Expand Down Expand Up @@ -511,5 +512,12 @@ def has_heavy_operations(self):
return True
return False

def get_highest_model_batching_multiplier(self):
highest_multiplier = 1
for mn in self.get_model_names():
if BASELINE_BATCHING_MULTIPLIERS.get(mn, 1) > highest_multiplier:
highest_multiplier = BASELINE_BATCHING_MULTIPLIERS.get(mn, 1)
return highest_multiplier

def count_pp(self):
return len(self.params.get("post_processing", []))
1 change: 1 addition & 0 deletions horde/classes/stable/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def get_safe_amount(self, amount, wp):
if wp.has_heavy_operations():
pp_multiplier *= 1.8
mps *= pp_multiplier
mps *= wp.get_highest_model_batching_multiplier()
safe_amount = round(safe_generations / mps)
if safe_amount > amount:
safe_amount = amount
Expand Down
7 changes: 7 additions & 0 deletions horde/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
"4x_AnimeSharp" "CodeFormers",
}

# These models are very large in VRAM, so we increase the calculated MPS
# used to figure out batches by a set multiplier to reduce how many images are batched
# at a time when these models are used.
BASELINE_BATCHING_MULTIPLIERS = {
"flux.1": 2,
}


KNOWN_SAMPLERS = {
"k_lms",
Expand Down

0 comments on commit dca63e0

Please sign in to comment.