Enhanced KSampler (TJ)
A KSampler that can make your prompt actually stick — per architecture
- model
- positive
- negative
- latent_image
- latent
- enhance_info
Enhanced KSampler (TJ) is a standard KSampler with a built-in prompt-adherence enhancer for three modern architectures - Krea2, Klein, and Z-Image. The pitch is simple: these models' text encoders don't always do what you asked, and this node tweaks how the prompt conditioning is fed in to make the model listen harder. Flip the master switch off and it's a completely ordinary KSampler; flip it on, pick the architecture you're running, and it applies architecture-specific conditioning surgery before sampling.
How it works
The enhancement differs per architecture, which is the whole point of the enhance_arch dropdown:
- Krea2 - patches the model's text-fusion adapter directly, re-weighting specific text chunks. There's also
adv_text_scale, which scales the whole text-MLP output independently (it works even at enhance strength 0 - Krea2's text scale is decoupled from strength). - Klein - operates on the positive conditioning. Klein stacks three Qwen3 layer slices along the embedding dimension (early/mid/late), and the node scales them separately via
adv_early_layer_scale,adv_mid_layer_scale,adv_late_layer_scale. Raising the late layer is usually what strengthens adherence. - Z-Image - also conditioning-side, using neutral-conditioning operations:
adv_active_scale(multiply every active-token embedding),adv_per_token_whiten(widen or compress each token's deviation from the sequence mean), andadv_norm_equalize(flatten magnitude variance toward the mean norm).
enhance_strength (0–2) drives a per-architecture default profile; the advanced knobs override that profile when you touch them. The tooltips are refreshingly honest about the risks - e.g. "the model was trained on the text encoder's natural distribution, so values far from 1.0 push it off-distribution." This is a reweighting, not a free lunch.
Two safety behaviors are worth knowing. First, the node detects the loaded model's architecture at runtime, and if enhance_arch doesn't match (say you picked klein but loaded Krea2), it prints a warning and falls back to a plain sample rather than silently doing the wrong thing. Second, enhance_debug prints the detection result, applied architecture, and tensor deltas to the console when you're tuning and want to see what actually happened.
Outputs: latent (the sampled result) and enhance_info (a STRING summarizing what was detected, selected, and applied - handy for logging which run used which enhancement).
Inputs and outputs that matter
All the standard KSampler inputs (model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise), then: enhance_enabled (master), enhance_arch, enhance_strength, enhance_debug, and the advanced knobs. Set the first three and you're 90% of the way there.
Install
ComfyUI Manager → Install Custom Nodes → search TJ_NODE, or:
cd ComfyUI/custom_nodes
git clone https://github.com/designloves2/ComfyUI-TJ_NODE
Restart ComfyUI. No extra dependencies. Category: ✨ TJ_Node/Sampling.
The honest take
The enhancement logic is ported from capitan01R's MIT project (credited in the pack's THIRD_PARTY_LICENSES.md), and it's the kind of thing that ranges from "subtle nudge" to "meaningful." For Krea2 and Klein specifically, where prompt adherence complaints are common, it's worth a try before you reach for CFG gymnastics - and the mismatch detection means a wrong dropdown costs you a warning, not a corrupted run. Where people get burned: cranking the advanced knobs far from 1.0 without reading the tooltips, then blaming the node when the model goes off-distribution. Start with enhance_strength around 1.0, check enhance_info, and only then touch the layer knobs.
Inputs (21)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| seed | INT | 00–18446744073709550000 | — |
| steps | INT | 201–10000 | — |
| cfg | FLOAT | 8.00–100 | — |
| sampler_name | COMBO | 44 options: euler, euler_cfg_pp, euler_ancestral, euler_ancestral_cfg_pp, heun, heunpp2, +38 | |
| scheduler | COMBO | 9 options: simple, sgm_uniform, karras, exponential, ddim_uniform, beta, +3 | |
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| latent_image | LATENT | — | |
| denoise | FLOAT | 1.000–1 | — |
| enhance_enabled | BOOLEAN | true | Master switch. When off, every enhance option below is hidden and this behaves exactly like a standard KSampler. |
| enhance_arch | COMBO | krea2 | Which architecture's enhancer to use. Must match the loaded model — Krea2 patches the model's text-fusion adapter, while Klein and Z-Image operate on the positive conditioning. A mismatch is detected and skipped. |
| enhance_strength | FLOAT | 1.000–2 | Overall enhancement amount. 0 = no effect, 1.0 = default, 2.0 = maximum. Drives the built-in per-architecture profile; any Advanced knob you change below overrides that profile for this run. |
| enhance_debug | BOOLEAN | false | Print detection, applied architecture and tensor deltas to the console. |
| adv_text_scaleopt | FLOAT | 1.000.25–4 | [Krea2 only] Scale the whole text-MLP output, independently of Enhance strength (which only re-weights specific text chunks). 1.0 = unchanged. Raise it to push overall text influence up, lower it to let the base model speak more. Works even at strength 0. |
| adv_active_scaleopt | FLOAT | 1.000–10 | [Klein / Z-Image] Multiplier on every active-token embedding. 1.0 = unchanged. The model was trained on the text encoder's natural distribution, so values far from 1.0 push it off-distribution. |
| adv_per_token_whitenopt | FLOAT | 0.00-1–5 | [Klein / Z-Image] Amplify each token's deviation from the sequence mean: (x - mean) * (1 + w) + mean. Above 0 widens the spread (more contrast between tokens), below 0 compresses it. 0 = off. |
| adv_norm_equalizeopt | FLOAT | 0.000–1 | [Klein / Z-Image] Blend each token toward the sequence's mean L2 norm. Flattens magnitude variance, countering the text encoder's natural emphasis. 0 = off, 1.0 = fully equalized. |
| adv_early_layer_scaleopt | FLOAT | 1.000–5 | [Klein only] Scale the first Qwen3 layer slice (low-level / structural features). Klein conditioning stacks 3 layers along the embed dim. |
| adv_mid_layer_scaleopt | FLOAT | 1.000–5 | [Klein only] Scale the middle Qwen3 layer slice (intermediate semantic features). |
| adv_late_layer_scaleopt | FLOAT | 1.000–5 | [Klein only] Scale the last Qwen3 layer slice (high-level semantics). Raising this is usually what strengthens prompt adherence. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |
| enhance_info | STRING | — |