Add optional negative use for cfg-1 models

This commit is contained in:
GenorTG
2026-11-09 19:11:13 +01:00
parent a043f6e0db
commit 593433f675
4 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -99,7 +99,7 @@ KSampler, KSampler (Advanced) and custom sigmas in one node, built on `comfy.sam
- **Schedules**: `scheduler = auto` uses LTX Video's token-count dependent schedule (max_shift, base_shift, terminal exposed) for LTX models and `simple` otherwise. Sigmas can also come from a SIGMAS input or a typed list (`custom_sigmas`), and `denoise` works with all of them. The sigmas used are an output.
- **runs**: samples seed, seed+1 ... in one node and returns one batch.
- **Advanced**: `start_at_step`, `end_at_step`, `add_noise`.
- **Advanced**: `start_at_step`, `end_at_step`, `add_noise`, `use_negative`. Distilled models run at cfg 1, where the negative prompt is ignored; `use_negative` raises a cfg of 1 to 1.5 for the guider so the negative pass runs. Off by default, because it can soften or over-bake a turbo result; raise cfg for more effect.
- **Recommended settings**: press `Use recommended settings` with a Loader's PIPE connected to fill sampler, scheduler, steps and cfg (nothing changes when you only connect the pipe). They come from the model's sidecar (the most common sampler, scheduler, steps and cfg of the author's example images; prompts are never read), then name hints (turbo / distilled -> 8 steps, cfg 1), then family defaults from community documentation (Krea 2: res_multistep/simple; MiniMax H3: euler/simple; LTX: the LTXV schedule). These are starting points, not official values.
- **Step cache**: `step_cache` (off / auto / easycache / lazycache) wraps ComfyUI's own EasyCache and LazyCache, which skip model calls on steps where the output barely changes and work across architectures (including audio+video models). `auto` turns on easycache from 15 steps up; distilled 4-8 step runs should stay off. `cache_threshold` (higher = faster, softer), `cache_start` and `cache_end` set when it may skip. Measured on Anima, 30 steps, RTX 5080: easycache 0.1 skipped 15/30 steps (1.8x, similarity to uncached 0.991), 0.2 skipped 17 (2.05x, 0.978), 0.4 skipped 19 (2.4x, 0.971); lazycache 0.2 gave 2.05x at 0.988. Results vary by model.
- **Presets**: save, apply and delete named presets (steps, cfg, sampler, scheduler, denoise, runs, step cache). They are stored in ComfyUI's user folder under `promptforge/sampler_presets.json`. Connect the Loader's PIPE to the sampler and the preset list shows only presets for that model family and model, plus generic presets; `show all presets` reveals the rest. A saved preset records the connected family and model, so it keeps matching that model and does not clutter other models.
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "ComfyUI-PromptForge"
description = "ComfyUI prompt enhancement suite: model/config node with GPU-aware auto settings, prompt enhancer with a preset catalog, and a standalone config finder."
version = "1.28.12"
version = "1.28.13"
license = { file = "LICENSE" }
dependencies = [
"transformers",
+6 -2
View File
@@ -28,7 +28,7 @@ from . import families, sampler_defaults
AUTO = "auto"
LTXV = "ltxv"
PRESET_FIELDS = ("steps", "cfg", "sampler_name", "scheduler", "denoise", "runs", "step_cache", "cache_threshold")
PRESET_FIELDS = ("steps", "cfg", "sampler_name", "scheduler", "denoise", "runs", "step_cache", "cache_threshold", "use_negative")
# step caching skips whole model calls, which only pays off (and only stays clean) with enough steps
AUTO_CACHE_MIN_STEPS = 15
CACHES = {"easycache": nodes_easycache.EasyCacheNode, "lazycache": nodes_easycache.LazyCacheNode}
@@ -125,6 +125,7 @@ class PROMPTFORGE_Sampler:
"ltxv_base_shift": ("FLOAT", {"default": 0.95, "min": 0.0, "max": 100.0, "step": 0.01, "advanced": True}),
"ltxv_terminal": ("FLOAT", {"default": 0.1, "min": 0.0, "max": 0.99, "step": 0.01, "advanced": True}),
"preview": (["default", "taesd", "latent2rgb", "none"], {"default": "default", "tooltip": "Live preview while sampling. default follows ComfyUI's --preview-method; taesd uses the model's tiny decoder when it is in models/vae_approx (taeh3 for MiniMax H3) and latent2rgb otherwise."}),
"use_negative": ("BOOLEAN", {"default": False, "advanced": True, "tooltip": "Use the negative prompt on distilled models. A cfg of 1 or less is raised to 1.5 for the guider, so the negative pass runs; raise cfg further for a stronger effect. Off keeps the fast cfg-1 path."}),
},
}
@@ -156,8 +157,11 @@ class PROMPTFORGE_Sampler:
def sample(self, model, positive, negative, latent_image, seed, steps, cfg, sampler_name, scheduler, denoise, runs,
pipe=None, sigmas=None, custom_sigmas="", step_cache="off", cache_threshold=0.2, cache_start=0.15, cache_end=0.95,
start_at_step=0, end_at_step=10000, add_noise=True, ltxv_max_shift=2.05, ltxv_base_shift=0.95, ltxv_terminal=0.1, preview="default"):
start_at_step=0, end_at_step=10000, add_noise=True, ltxv_max_shift=2.05, ltxv_base_shift=0.95, ltxv_terminal=0.1, preview="default",
use_negative=False):
family = self._family(model, pipe)
if use_negative and cfg <= 1.0:
cfg = 1.5
if step_cache == "auto":
step_cache = "easycache" if steps >= AUTO_CACHE_MIN_STEPS else "off"
if step_cache != "off":
+1 -1
View File
@@ -2,7 +2,7 @@ import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
const NODE = "PROMPTFORGE_Sampler";
const PRESET_FIELDS = ["steps", "cfg", "sampler_name", "scheduler", "denoise", "runs", "step_cache", "cache_threshold"];
const PRESET_FIELDS = ["steps", "cfg", "sampler_name", "scheduler", "denoise", "runs", "step_cache", "cache_threshold", "use_negative"];
const NO_PRESET = "(no preset)";
app.registerExtension({