Nodes/Nukun_ComfyUI_Nodes/T5/Qwen Sculpt Equal-Length Prompt Balancer (Nukun)
ComfyUI Node

T5/Qwen Sculpt Equal-Length Prompt Balancer (Nukun)

Equal-length T5 balancing, plus optional embedding edits

By OnekoSL·Created 3 months ago·Updated 11 days ago· 1
T5/Qwen Sculpt Equal-Length Prompt Balancer (Nukun)
  • tokenizer
  • positive
  • negative
  • positive_raw_tokens
  • negative_raw_tokens
  • effective_target
  • positive_sculpted_tokens
  • negative_sculpted_tokens
  • report
target1024
positive
negative
positive_intensity0.35
positive_methodforward
positive_normalizationnone
negative_intensity0.00
negative_methodforward
negative_normalizationmean
top_k64

The experimental sibling of T5 Equal-Length Prompt Balancer (Nukun). It does the same equal-length encoding for T5/Qwen prompts, then optionally edits the token embeddings before scheduled encoding - "sculpting" them toward sharper adherence, in the same spirit as the SDXL Vector Sculptor family but for the T5/Qwen stream. It's the node to reach for when balancing alone isn't enough and you want to push prompt fidelity further.

Read the label before you commit: it's experimental, and the defaults are deliberately mild - positive_intensity 0.35 with none normalization on the positive side, and normalization-only (negative_intensity 0) on the negative. That asymmetry is a design choice: the negative gets length-equalized but its embeddings are left mostly alone, because sculpting the negative is where people usually overstep. The README's advice is to compare against the plain balancer before increasing intensity, and that's the correct workflow.

How it works

Same inputs as the plain balancer (tokenizer, target, positive, negative) plus the sculpt controls: positive_intensity, positive_method, positive_normalization, negative_intensity, negative_method, negative_normalization, and top_k (default 64, the nearest-vector search breadth).

The machinery is the interesting part. It skips special, padded, and Qwen3-VL chat-template tokens, shares repeated token IDs across positive and negative (each unique token searched once, not per occurrence), and runs the top_k nearest-vector search in bounded chunks rather than cloning the complete embedding table into VRAM. If the accelerator OOMs, only temporary cache data is cleared and it transparently retries the search on CPU. The report output states the search device, fallback state, chunk size, query batches, and unique-token count - unusually transparent for a node this fiddly.

Outputs add positive_sculpted_tokens and negative_sculpted_tokens counts on top of the balancer's usual outputs (positive, negative, both raw token counts, effective_target, report).

Installing it

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/OnekoSL/Nukun_ComfyUI_Nodes.git

Restart, or use Manager (search "Nukun"). Self-contained - the chunked search and CPU fallback are implemented in the pack.

Common issues

This is the node in the pack most likely to look like it did nothing or too much, because embedding edits are invisible in the text and only show up in the image. If output looks unchanged, raise positive_intensity; if it looks worse, lower it or check the report for a CPU fallback - a search device of cpu doesn't mean it failed, but it does mean slower, and on a big prompt it's worth knowing why. The negative side defaults to normalization-only on purpose; if you set negative_intensity high and get degraded images, that's the classic over-sculpted negative. And keep the low-memory note from the balancer in mind: target = 0 avoids artificial padding when VRAM is tight, which matters even more here because sculpting runs over token counts.

CategoryNukun/Conditioning

Inputs (11)

NameTypeDefaultDescription
tokenizerCLIPThe loaded T5/Qwen tokenizer to use.
targetINT10240–4096Minimum shared token length for positive and negative prompts.
positiveSTRING
negativeSTRING
positive_intensityFLOAT0.350–5
positive_methodCOMBOforward4 options: forward, backward, maximum_absolute, add_minimum_absolute
positive_normalizationCOMBOnone3 options: none, mean, mean * attention
negative_intensityFLOAT0.000–5
negative_methodCOMBOforward4 options: forward, backward, maximum_absolute, add_minimum_absolute
negative_normalizationCOMBOmean3 options: none, mean, mean * attention
top_kINT641–512Number of nearest token vectors used for sculpting.

Outputs (8)

NameTypeDescription
positiveCONDITIONING
negativeCONDITIONING
positive_raw_tokensINT
negative_raw_tokensINT
effective_targetINT
positive_sculpted_tokensINT
negative_sculpted_tokensINT
reportSTRING