vclmax2 commited on
Commit
cbf1986
·
verified ·
1 Parent(s): af46555

Use pre-baked 10Eros checkpoints + split text_proj/audio_vae + CLASSIC cache

Browse files
Files changed (1) hide show
  1. app.py +135 -98
app.py CHANGED
@@ -422,34 +422,34 @@ def _install_kv_wrapper(comfy_root: pathlib.Path) -> None:
422
 
423
  DOWNLOADS = [
424
  {
425
- "repo": "TenStrip/LTX2.3-10Eros",
426
- "file": "10Eros_v1-fp8mixed_learned.safetensors",
427
- "dest": MODELS / "checkpoints" / "10Eros_v1-fp8mixed_learned.safetensors",
428
- "label": "main checkpoint",
429
  },
430
  {
431
- "repo": "Comfy-Org/ltx-2",
432
- "file": "split_files/text_encoders/gemma_3_12B_it_fp8_scaled.safetensors",
433
- "dest": MODELS / "text_encoders" / "gemma_3_12B_it_fp8_scaled.safetensors",
434
- "label": "text encoder",
435
  },
436
  {
437
- "repo": "TenStrip/LTX2.3_Distilled_Lora_1.1_Experiments",
438
- "file": "ltx-2.3-22b-distilled-lora-1.1_fro90_ceil72_condsafe.safetensors",
439
- "dest": MODELS / "loras" / "ltx23" / "ltx-2.3-22b-distilled-lora-1.1_fro90_ceil72_condsafe.safetensors",
440
- "label": "distilled lora",
441
  },
442
  {
443
- "repo": "VasiliyWeb/OmniNFT_ComfyUI",
444
- "file": "OmniNFT_converted_lora.safetensors",
445
- "dest": MODELS / "loras" / "ltx23" / "OmniNFT_converted_lora.safetensors",
446
- "label": "omninft (converted) lora",
447
  },
448
  {
449
- "repo": "Kijai/LTX2.3_comfy",
450
- "file": "loras/LTX-2.3-OmniNFT-RL-Lora_bf16.safetensors",
451
- "dest": MODELS / "loras" / "ltx23" / "LTX-2.3-OmniNFT-RL-Lora_bf16.safetensors",
452
- "label": "omninft RL bf16 lora",
453
  },
454
  {
455
  "repo": "Lightricks/LTX-2.3",
@@ -458,90 +458,50 @@ DOWNLOADS = [
458
  "label": "spatial upscaler",
459
  },
460
  {
461
- "repo": "maximsobolev275/LTX-SulphurExperimental-LoRA-Optimized",
462
- "file": "LTX_SulphurEXP_LoRA_fro99-avgrank105.safetensors",
463
- "dest": MODELS / "loras" / "ltx23" / "LTX_SulphurEXP_LoRA_fro99-avgrank105.safetensors",
464
- "label": "sulphur experimental lora",
465
- },
466
- {
467
- "repo": "SulphurAI/Sulphur-2-base",
468
- "file": "experimental/sulphur_experimental_lora_v1.safetensors",
469
- "dest": MODELS / "loras" / "ltx23" / "sulphur_experimental_lora_v1.safetensors",
470
- "label": "sulphur experimental v1 lora (kiwv official)",
471
- },
472
- {
473
- "repo": "signsur4739379373/archive",
474
- "file": "2497207_LTX2.3_reasoning_I2V_V3.safetensors",
475
- "dest": MODELS / "loras" / "ltx23" / "2497207_LTX2.3_reasoning_I2V_V3.safetensors",
476
- "label": "vbvr lora",
477
  },
478
- {
479
- "repo": "signsur4739379373/archive",
480
- "file": "1811313_dreamlay_ltx_V2.safetensors",
481
- "dest": MODELS / "loras" / "ltx23" / "1811313_dreamlay_ltx_V2.safetensors",
482
- "label": "dreamly lora",
 
 
483
  },
484
- {
485
  "repo": "signsur4739379373/archive",
486
  "file": "2509189_Synth_01_rank32.safetensors",
487
  "dest": MODELS / "loras" / "ltx23" / "2509189_Synth_01_rank32.safetensors",
488
- "label": "synth lora",
489
  },
490
- {
491
  "repo": "signsur4739379373/archive",
492
  "file": "2598050_plora_sulfer_v1.2-step00008500.safetensors",
493
  "dest": MODELS / "loras" / "ltx23" / "2598050_plora_sulfer_v1.2-step00008500.safetensors",
494
- "label": "plora",
495
  },
496
- {
497
  "repo": "signsur4739379373/archive",
498
  "file": "2344781_Sulphur_LTX 2.3_better_motion.safetensors",
499
  "dest": MODELS / "loras" / "ltx23" / "2344781_Sulphur_LTX 2.3_better_motion.safetensors",
500
- "label": "better motion lora (mistic)",
501
  },
502
- {
503
  "repo": "signsur4739379373/archive",
504
  "file": "2592090_LTX2.3_Physics_V2_000002000.safetensors",
505
  "dest": MODELS / "loras" / "ltx23" / "2592090_LTX2.3_Physics_V2_000002000.safetensors",
506
- "label": "physics v2 lora (mistic)",
507
  },
508
- {
509
  "repo": "signsur4739379373/archive",
510
  "file": "2508281_LTX-2.3_Cinematic hardcut.safetensors",
511
  "dest": MODELS / "loras" / "ltx23" / "2508281_LTX-2.3_Cinematic hardcut.safetensors",
512
- "label": "cinematic hardcut lora",
513
- },
514
- {
515
- "repo": "joyfox/LTX-2.3-Transition-LORA",
516
- "file": "ltx2.3-transition.safetensors",
517
- "dest": MODELS / "loras" / "ltx23" / "ltx2.3-transition.safetensors",
518
- "label": "transition lora",
519
- },
520
- {
521
- "repo": "Muapi/mature-anime-screencap-style-ltx-2.3-edition",
522
- "file": "mature-anime-screencap-style-ltx-2.3-edition.safetensors",
523
- "dest": MODELS / "loras" / "ltx23" / "mature-anime-screencap-style-ltx-2.3-edition.safetensors",
524
- "label": "anime screencap lora",
525
  },
526
- {
527
  "repo": "LiconStudio/LTX-2.3-Multiple-Subject-Reference",
528
  "file": "LTX2.3-Licon-MSR-test_version.safetensors",
529
  "dest": MODELS / "loras" / "ltx23" / "LTX2.3-Licon-MSR-test_version.safetensors",
530
- "label": "MSR ic-lora",
531
- },
532
- {
533
- "repo": "WarmBloodAban/Singularity-LTX-2.3_OmniCine_V1",
534
- "file": "Singularity-LTX-2.3_OmniCine_V1nsf.safetensors",
535
- "dest": MODELS / "loras" / "ltx23" / "Singularity-LTX-2.3_OmniCine_V1nsf.safetensors",
536
- "label": "singularity lora",
537
- },
538
- {
539
- "repo": "Kijai/MelBandRoFormer_comfy",
540
- "file": "MelBandRoformer_fp16.safetensors",
541
- "dest": MODELS / "diffusion_models" / "MelBandRoformer_fp16.safetensors",
542
- "label": "mel band roformer (stem separation)",
543
  },
544
- ]
545
 
546
  SULPHUR_LORA_FILENAME = "ltx23/LTX_SulphurEXP_LoRA_fro99-avgrank105.safetensors"
547
  SULPHUR_V1_LORA_FILENAME = "ltx23/sulphur_experimental_lora_v1.safetensors"
@@ -1267,6 +1227,7 @@ def _download_to_dest(repo: str, file_path: str, dest: pathlib.Path, token: str
1267
 
1268
 
1269
  def _ensure_models(progress: gr.Progress | None = None) -> None:
 
1270
  token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
1271
  for index, item in enumerate(DOWNLOADS):
1272
  dest = pathlib.Path(item["dest"])
@@ -1278,6 +1239,17 @@ def _ensure_models(progress: gr.Progress | None = None) -> None:
1278
  _download_to_dest(item["repo"], item["file"], dest, token)
1279
 
1280
 
 
 
 
 
 
 
 
 
 
 
 
1281
  def _init_comfy_nodes() -> None:
1282
  global _nodes_ready
1283
  if _nodes_ready:
@@ -1382,9 +1354,13 @@ def _convert_workflow(visual_path: str) -> dict[str, Any]:
1382
  link_map[link_id] = replacement
1383
  changed = True
1384
 
 
 
 
1385
  skip_ids = {
1386
  617, 535, 548, 556, 591, 596, 550, 593, 274, 789, 780,
1387
  551, 598, 549, 552, 755, 769,
 
1388
  }
1389
  rewires = {
1390
  "510": {"latent_image": ["772", 0]},
@@ -1392,6 +1368,8 @@ def _convert_workflow(visual_path: str) -> dict[str, Any]:
1392
  "802": {"latent_image": ["770", 0]},
1393
  "740": {"samples": ["802", 1]},
1394
  "597": {"images": ["740", 0]},
 
 
1395
  }
1396
 
1397
  # Native AV: keep the concat/separate/decoder chain so 597.audio resolves
@@ -1473,6 +1451,15 @@ def _convert_workflow(visual_path: str) -> dict[str, Any]:
1473
 
1474
  api[node_key] = {"class_type": class_type, "inputs": inputs}
1475
 
 
 
 
 
 
 
 
 
 
1476
  return api
1477
 
1478
 
@@ -1514,17 +1501,17 @@ def _convert_runexx_workflow(visual_path: str) -> dict[str, Any]:
1514
  nid = int(node["id"])
1515
  if nid == RUNEXX_NODE_UNET_LOADER:
1516
  node["type"] = "CheckpointLoaderSimple"
1517
- node["widgets_values"] = ["10Eros_v1-fp8mixed_learned.safetensors"]
1518
  elif nid == RUNEXX_NODE_CLIP_LOADER:
1519
  node["type"] = "LTXAVTextEncoderLoader"
1520
  node["widgets_values"] = [
1521
  "gemma_3_12B_it_fp8_scaled.safetensors",
1522
- "10Eros_v1-fp8mixed_learned.safetensors",
1523
  "default",
1524
  ]
1525
  elif nid == RUNEXX_NODE_VAE_AUDIO:
1526
  node["type"] = "LTXVAudioVAELoader"
1527
- node["widgets_values"] = ["10Eros_v1-fp8mixed_learned.safetensors"]
1528
 
1529
  # Skip the dead loader/preview/parallel nodes AND the UUID stand-ins which
1530
  # we replace via the link rewire pass below.
@@ -1916,6 +1903,12 @@ def _inject_params(
1916
  else:
1917
  resolved_cache_step = int(cache_at_step)
1918
  workflow[NODE_LOAD_IMAGE]["inputs"]["image"] = image_name
 
 
 
 
 
 
1919
  _inject_optional_loras(
1920
  workflow,
1921
  video_strengths={
@@ -2119,6 +2112,18 @@ OPTIONAL_LORAS = {
2119
  }
2120
 
2121
 
 
 
 
 
 
 
 
 
 
 
 
 
2122
  def _inject_optional_loras(
2123
  workflow: dict[str, Any],
2124
  video_strengths: dict[str, float],
@@ -2126,13 +2131,12 @@ def _inject_optional_loras(
2126
  ) -> None:
2127
  """Populate the MultiLoRALoader's lora_data JSON string.
2128
 
2129
- LTX-mode entry format (per phazei's dispatch): per-key alpha is multiplied
2130
- by the modality factor matching the tensor name pattern, then the global
2131
- `str` applies on top. vid covers main video attn/ff.net tensors, aud covers
2132
- audio_attn / audio_ff.net, v2a / a2v cover cross-modal attn. Setting aud
2133
- independent of vid lets a non-audio-trained lora influence video without
2134
- distorting the audio stream. Disabled (skipped) when video_strength <= 0
2135
- and audio_strength <= 0. Idempotent.
2136
  """
2137
  node = workflow.get(NODE_POWER_LORA)
2138
  if node is None:
@@ -2140,10 +2144,13 @@ def _inject_optional_loras(
2140
  audio_strengths = audio_strengths or {}
2141
  entries: list[dict[str, Any]] = []
2142
  for key, filename in OPTIONAL_LORAS.items():
 
 
2143
  vid = float(video_strengths.get(key, 0.0) or 0.0)
2144
  aud = float(audio_strengths.get(key, vid) or 0.0)
2145
  if vid <= 0 and aud <= 0:
2146
  continue
 
2147
  entries.append({
2148
  "lora": filename,
2149
  "on": True,
@@ -2731,6 +2738,7 @@ def _inject_msr(
2731
  # loader by stealing rgthree's `model` upstream connection.
2732
  power_loader = workflow.get(NODE_POWER_LORA)
2733
  if msr_lora_strength > 0 and power_loader is not None:
 
2734
  # Clear any stale lora_msr entry from prior versions.
2735
  power_loader["inputs"].pop("lora_msr", None)
2736
  upstream_model = power_loader["inputs"].get("model")
@@ -3367,21 +3375,50 @@ def upscale_to_ts(clip_urls: str, output_keys: str, width: int, height: int) ->
3367
  return json.dumps({"status": "completed", "urls": out_urls})
3368
 
3369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3370
  def _execute_workflow(workflow: dict[str, Any]) -> str:
3371
- _prune_and_reset_comfy_memory()
3372
  import execution
3373
  import server
3374
 
3375
- loop = asyncio.new_event_loop()
3376
- asyncio.set_event_loop(loop)
3377
- server_instance = server.PromptServer(loop)
3378
- executor = execution.PromptExecutor(
3379
- server_instance,
3380
- cache_type=execution.CacheType.RAM_PRESSURE,
3381
- cache_args={"lru": 0, "ram": 2.0, "ram_inactive": 8.0},
3382
- )
 
 
3383
  prompt_id = str(uuid.uuid4())
3384
- executor.execute(workflow, prompt_id, extra_data={}, execute_outputs=[NODE_OUTPUT])
 
 
 
3385
  if not executor.success:
3386
  raise RuntimeError(str(executor.status_messages[-1] if executor.status_messages else "comfy execution failed"))
3387
 
 
422
 
423
  DOWNLOADS = [
424
  {
425
+ "repo": "vclmax/LTX2.3-10Eros-Baked",
426
+ "file": "baked_eros_v1.safetensors",
427
+ "dest": MODELS / "checkpoints" / "baked_eros_v1.safetensors",
428
+ "label": "baked 10Eros realistic checkpoint",
429
  },
430
  {
431
+ "repo": "vclmax/LTX2.3-10Eros-Baked",
432
+ "file": "baked_eros-anime_v1.safetensors",
433
+ "dest": MODELS / "checkpoints" / "baked_eros-anime_v1.safetensors",
434
+ "label": "baked 10Eros anime checkpoint",
435
  },
436
  {
437
+ "repo": "vclmax/LTX2.3-10Eros-Baked",
438
+ "file": "text_proj_eros_v1.safetensors",
439
+ "dest": MODELS / "checkpoints" / "text_proj_eros_v1.safetensors",
440
+ "label": "10Eros text embedding projection",
441
  },
442
  {
443
+ "repo": "vclmax/LTX2.3-10Eros-Baked",
444
+ "file": "audio_vae_eros_v1.safetensors",
445
+ "dest": MODELS / "checkpoints" / "audio_vae_eros_v1.safetensors",
446
+ "label": "10Eros audio VAE + vocoder",
447
  },
448
  {
449
+ "repo": "Comfy-Org/ltx-2",
450
+ "file": "split_files/text_encoders/gemma_3_12B_it_fp8_scaled.safetensors",
451
+ "dest": MODELS / "text_encoders" / "gemma_3_12B_it_fp8_scaled.safetensors",
452
+ "label": "text encoder",
453
  },
454
  {
455
  "repo": "Lightricks/LTX-2.3",
 
458
  "label": "spatial upscaler",
459
  },
460
  {
461
+ "repo": "Kijai/MelBandRoFormer_comfy",
462
+ "file": "MelBandRoformer_fp16.safetensors",
463
+ "dest": MODELS / "diffusion_models" / "MelBandRoformer_fp16.safetensors",
464
+ "label": "mel band roformer (stem separation)",
 
 
 
 
 
 
 
 
 
 
 
 
465
  },
466
+ ]
467
+
468
+ LAZY_LORA_DOWNLOADS = {
469
+ "ltx23/LTX-2.3-OmniNFT-RL-Lora_bf16.safetensors": {
470
+ "repo": "Kijai/LTX2.3_comfy",
471
+ "file": "loras/LTX-2.3-OmniNFT-RL-Lora_bf16.safetensors",
472
+ "dest": MODELS / "loras" / "ltx23" / "LTX-2.3-OmniNFT-RL-Lora_bf16.safetensors",
473
  },
474
+ "ltx23/2509189_Synth_01_rank32.safetensors": {
475
  "repo": "signsur4739379373/archive",
476
  "file": "2509189_Synth_01_rank32.safetensors",
477
  "dest": MODELS / "loras" / "ltx23" / "2509189_Synth_01_rank32.safetensors",
 
478
  },
479
+ "ltx23/2598050_plora_sulfer_v1.2-step00008500.safetensors": {
480
  "repo": "signsur4739379373/archive",
481
  "file": "2598050_plora_sulfer_v1.2-step00008500.safetensors",
482
  "dest": MODELS / "loras" / "ltx23" / "2598050_plora_sulfer_v1.2-step00008500.safetensors",
 
483
  },
484
+ "ltx23/2344781_Sulphur_LTX 2.3_better_motion.safetensors": {
485
  "repo": "signsur4739379373/archive",
486
  "file": "2344781_Sulphur_LTX 2.3_better_motion.safetensors",
487
  "dest": MODELS / "loras" / "ltx23" / "2344781_Sulphur_LTX 2.3_better_motion.safetensors",
 
488
  },
489
+ "ltx23/2592090_LTX2.3_Physics_V2_000002000.safetensors": {
490
  "repo": "signsur4739379373/archive",
491
  "file": "2592090_LTX2.3_Physics_V2_000002000.safetensors",
492
  "dest": MODELS / "loras" / "ltx23" / "2592090_LTX2.3_Physics_V2_000002000.safetensors",
 
493
  },
494
+ "ltx23/2508281_LTX-2.3_Cinematic hardcut.safetensors": {
495
  "repo": "signsur4739379373/archive",
496
  "file": "2508281_LTX-2.3_Cinematic hardcut.safetensors",
497
  "dest": MODELS / "loras" / "ltx23" / "2508281_LTX-2.3_Cinematic hardcut.safetensors",
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  },
499
+ "ltx23/LTX2.3-Licon-MSR-test_version.safetensors": {
500
  "repo": "LiconStudio/LTX-2.3-Multiple-Subject-Reference",
501
  "file": "LTX2.3-Licon-MSR-test_version.safetensors",
502
  "dest": MODELS / "loras" / "ltx23" / "LTX2.3-Licon-MSR-test_version.safetensors",
 
 
 
 
 
 
 
 
 
 
 
 
 
503
  },
504
+ }
505
 
506
  SULPHUR_LORA_FILENAME = "ltx23/LTX_SulphurEXP_LoRA_fro99-avgrank105.safetensors"
507
  SULPHUR_V1_LORA_FILENAME = "ltx23/sulphur_experimental_lora_v1.safetensors"
 
1227
 
1228
 
1229
  def _ensure_models(progress: gr.Progress | None = None) -> None:
1230
+ (MODELS / "loras" / "ltx23").mkdir(parents=True, exist_ok=True)
1231
  token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
1232
  for index, item in enumerate(DOWNLOADS):
1233
  dest = pathlib.Path(item["dest"])
 
1239
  _download_to_dest(item["repo"], item["file"], dest, token)
1240
 
1241
 
1242
+ def _ensure_lazy_lora(rel_filename: str) -> None:
1243
+ spec = LAZY_LORA_DOWNLOADS.get(rel_filename)
1244
+ if not spec:
1245
+ return
1246
+ dest = pathlib.Path(spec["dest"])
1247
+ if dest.exists():
1248
+ return
1249
+ token = os.environ.get("HF_TOKEN") or os.environ.get("HUGGINGFACE_HUB_TOKEN")
1250
+ _download_to_dest(spec["repo"], spec["file"], dest, token)
1251
+
1252
+
1253
  def _init_comfy_nodes() -> None:
1254
  global _nodes_ready
1255
  if _nodes_ready:
 
1354
  link_map[link_id] = replacement
1355
  changed = True
1356
 
1357
+ # Skip preview/unused nodes AND skip the 4 runtime distilled-LoRA loader nodes
1358
+ # (718, 719, 722, 723) since distilled-lora + _TUNED are pre-baked into
1359
+ # `baked_eros_v1.safetensors` and `baked_eros-anime_v1.safetensors`.
1360
  skip_ids = {
1361
  617, 535, 548, 556, 591, 596, 550, 593, 274, 789, 780,
1362
  551, 598, 549, 552, 755, 769,
1363
+ 718, 719, 722, 723, 779, 781, 782, 783,
1364
  }
1365
  rewires = {
1366
  "510": {"latent_image": ["772", 0]},
 
1368
  "802": {"latent_image": ["770", 0]},
1369
  "740": {"samples": ["802", 1]},
1370
  "597": {"images": ["740", 0]},
1371
+ "731": {"model": ["557", 0]},
1372
+ "583": {"model": ["557", 0]},
1373
  }
1374
 
1375
  # Native AV: keep the concat/separate/decoder chain so 597.audio resolves
 
1451
 
1452
  api[node_key] = {"class_type": class_type, "inputs": inputs}
1453
 
1454
+ if "646" in api:
1455
+ api["646"]["inputs"]["ckpt_name"] = "baked_eros_v1.safetensors"
1456
+ if NODE_TEXT_ENCODER in api:
1457
+ api[NODE_TEXT_ENCODER]["inputs"]["text_encoder"] = "gemma_3_12B_it_fp8_scaled.safetensors"
1458
+ api[NODE_TEXT_ENCODER]["inputs"]["ckpt_name"] = "text_proj_eros_v1.safetensors"
1459
+ api[NODE_TEXT_ENCODER]["inputs"]["device"] = "default"
1460
+ if NODE_AUDIO_VAE_LOADER in api:
1461
+ api[NODE_AUDIO_VAE_LOADER]["inputs"]["ckpt_name"] = "audio_vae_eros_v1.safetensors"
1462
+
1463
  return api
1464
 
1465
 
 
1501
  nid = int(node["id"])
1502
  if nid == RUNEXX_NODE_UNET_LOADER:
1503
  node["type"] = "CheckpointLoaderSimple"
1504
+ node["widgets_values"] = ["baked_eros_v1.safetensors"]
1505
  elif nid == RUNEXX_NODE_CLIP_LOADER:
1506
  node["type"] = "LTXAVTextEncoderLoader"
1507
  node["widgets_values"] = [
1508
  "gemma_3_12B_it_fp8_scaled.safetensors",
1509
+ "text_proj_eros_v1.safetensors",
1510
  "default",
1511
  ]
1512
  elif nid == RUNEXX_NODE_VAE_AUDIO:
1513
  node["type"] = "LTXVAudioVAELoader"
1514
+ node["widgets_values"] = ["audio_vae_eros_v1.safetensors"]
1515
 
1516
  # Skip the dead loader/preview/parallel nodes AND the UUID stand-ins which
1517
  # we replace via the link rewire pass below.
 
1903
  else:
1904
  resolved_cache_step = int(cache_at_step)
1905
  workflow[NODE_LOAD_IMAGE]["inputs"]["image"] = image_name
1906
+ if "646" in workflow:
1907
+ workflow["646"]["inputs"]["ckpt_name"] = (
1908
+ "baked_eros-anime_v1.safetensors"
1909
+ if float(anime_lora_strength or 0.0) > 0.0
1910
+ else "baked_eros_v1.safetensors"
1911
+ )
1912
  _inject_optional_loras(
1913
  workflow,
1914
  video_strengths={
 
2112
  }
2113
 
2114
 
2115
+ BAKED_LORA_KEYS = {
2116
+ "lora_sulphur",
2117
+ "lora_sulphur_v1",
2118
+ "lora_vbvr",
2119
+ "lora_dreamly",
2120
+ "lora_singularity",
2121
+ "lora_omninft",
2122
+ "lora_transition",
2123
+ "lora_anime",
2124
+ }
2125
+
2126
+
2127
  def _inject_optional_loras(
2128
  workflow: dict[str, Any],
2129
  video_strengths: dict[str, float],
 
2131
  ) -> None:
2132
  """Populate the MultiLoRALoader's lora_data JSON string.
2133
 
2134
+ The 8 `_TUNED` + `anime` + `distilled` LoRAs are already permanently baked
2135
+ into `baked_eros_v1.safetensors` and `baked_eros-anime_v1.safetensors`, so
2136
+ they are skipped here (`lora_data="[]"` for all standard realistic & anime
2137
+ runs, eliminating ~50 GB of CPU RAM and ~70s of runtime LoRA patching).
2138
+ Only extra non-baked LoRAs (synth, plora, omninft_bf16, better_motion,
2139
+ physics_v2, hardcut) are added when explicitly requested (`> 0`).
 
2140
  """
2141
  node = workflow.get(NODE_POWER_LORA)
2142
  if node is None:
 
2144
  audio_strengths = audio_strengths or {}
2145
  entries: list[dict[str, Any]] = []
2146
  for key, filename in OPTIONAL_LORAS.items():
2147
+ if key in BAKED_LORA_KEYS:
2148
+ continue
2149
  vid = float(video_strengths.get(key, 0.0) or 0.0)
2150
  aud = float(audio_strengths.get(key, vid) or 0.0)
2151
  if vid <= 0 and aud <= 0:
2152
  continue
2153
+ _ensure_lazy_lora(filename)
2154
  entries.append({
2155
  "lora": filename,
2156
  "on": True,
 
2738
  # loader by stealing rgthree's `model` upstream connection.
2739
  power_loader = workflow.get(NODE_POWER_LORA)
2740
  if msr_lora_strength > 0 and power_loader is not None:
2741
+ _ensure_lazy_lora(MSR_LORA_FILENAME)
2742
  # Clear any stale lora_msr entry from prior versions.
2743
  power_loader["inputs"].pop("lora_msr", None)
2744
  upstream_model = power_loader["inputs"].get("model")
 
3375
  return json.dumps({"status": "completed", "urls": out_urls})
3376
 
3377
 
3378
+ _global_executor = None
3379
+
3380
+
3381
+ def _cleanup_post_run() -> None:
3382
+ from comfy import model_management as mm
3383
+
3384
+ for lm in list(mm.current_loaded_models):
3385
+ mp = getattr(lm, "model", None)
3386
+ if mp is not None and hasattr(mp, "model") and hasattr(mp.model, "diffusion_model"):
3387
+ backbone = mp.model.diffusion_model
3388
+ for block in getattr(backbone, "transformer_blocks", []):
3389
+ attn1 = getattr(block, "attn1", None)
3390
+ if attn1 is not None:
3391
+ for attr in ("_10s_aware_anchor_hook", "_10s_likeness_anchor_hook"):
3392
+ h = getattr(attn1, attr, None)
3393
+ if h is not None:
3394
+ try:
3395
+ h.remove()
3396
+ except Exception:
3397
+ pass
3398
+ delattr(attn1, attr)
3399
+ mm.soft_empty_cache()
3400
+
3401
+
3402
  def _execute_workflow(workflow: dict[str, Any]) -> str:
3403
+ global _global_executor
3404
  import execution
3405
  import server
3406
 
3407
+ if _global_executor is None:
3408
+ loop = asyncio.new_event_loop()
3409
+ asyncio.set_event_loop(loop)
3410
+ server_instance = server.PromptServer(loop)
3411
+ _global_executor = execution.PromptExecutor(
3412
+ server_instance,
3413
+ cache_type=execution.CacheType.CLASSIC,
3414
+ cache_args={"lru": 16, "ram": 2.0, "ram_inactive": 8.0},
3415
+ )
3416
+ executor = _global_executor
3417
  prompt_id = str(uuid.uuid4())
3418
+ try:
3419
+ executor.execute(workflow, prompt_id, extra_data={}, execute_outputs=[NODE_OUTPUT])
3420
+ finally:
3421
+ _cleanup_post_run()
3422
  if not executor.success:
3423
  raise RuntimeError(str(executor.status_messages[-1] if executor.status_messages else "comfy execution failed"))
3424