feat: ltx-aware sort order for cache locality
This commit is contained in:
@@ -231,6 +231,19 @@ def check_if_job_completed(existing_items, conf, seed, width, height, batch_idx,
|
||||
return -1
|
||||
|
||||
|
||||
def _ltx_sort_components(x):
|
||||
"""Return tuple of LTX-specific sort components (None for non-LTX entries)."""
|
||||
if x.get('model_type') != 'ltx_video':
|
||||
return (None, None, None, None)
|
||||
cm = x.get('clip_models') or []
|
||||
return (
|
||||
tuple(cm),
|
||||
x.get('vae_video', ''),
|
||||
x.get('vae_audio', ''),
|
||||
x.get('latent_upscaler', ''),
|
||||
)
|
||||
|
||||
|
||||
def get_model_cache_key(conf):
|
||||
"""Generate a cache key that uniquely identifies the model+clip combination."""
|
||||
model_type = conf.get("model_type", "checkpoint")
|
||||
@@ -736,7 +749,17 @@ def run_generation_loop(
|
||||
extra_seeds = [random.randint(0, 2**32 - 1) for _ in range(add_random_seeds_to_gens)]
|
||||
|
||||
expanded = expand_configs(raw_configs, pos_prompts, neg_prompts, denoise_values, seed, extra_seeds, ckpt_name)
|
||||
expanded.sort(key=lambda x: (x.get('model_type', 'checkpoint'), x['model'], tuple(x.get('text_encoders', [])), x.get('vae', 'Default'), x['lora'], x.get('attention_mode', 'default'), x['positive'], x['negative']))
|
||||
expanded.sort(key=lambda x: (
|
||||
x.get('model_type', 'checkpoint'),
|
||||
x['model'],
|
||||
*_ltx_sort_components(x),
|
||||
tuple(x.get('text_encoders', [])),
|
||||
x.get('vae', 'Default'),
|
||||
x['lora'],
|
||||
x.get('attention_mode', 'default'),
|
||||
x['positive'],
|
||||
x['negative'],
|
||||
))
|
||||
|
||||
# ==== EXPAND LORA WEIGHT ARRAYS (Cartesian product) ====
|
||||
# Format: "lora:[0.5, 0.8]:1.0" → expand into separate configs per strength combo
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from generation_orchestrator import get_model_cache_key
|
||||
from generation_orchestrator import get_model_cache_key, _ltx_sort_components
|
||||
|
||||
|
||||
def _ltx_conf():
|
||||
@@ -92,3 +92,15 @@ def test_diffusion_model_key_unchanged():
|
||||
assert "diffusion_model" in key
|
||||
assert "t5.safetensors" in key
|
||||
assert "clip_l.safetensors" in key
|
||||
|
||||
|
||||
def test_ltx_sort_components_imports():
|
||||
assert _ltx_sort_components({"model_type": "checkpoint"}) == (None, None, None, None)
|
||||
ltx = {
|
||||
"model_type": "ltx_video",
|
||||
"clip_models": ["c1", "c2"],
|
||||
"vae_video": "vv",
|
||||
"vae_audio": "va",
|
||||
"latent_upscaler": "lup",
|
||||
}
|
||||
assert _ltx_sort_components(ltx) == (("c1", "c2"), "vv", "va", "lup")
|
||||
|
||||
Reference in New Issue
Block a user