T5/Qwen Sculpt Equal-Length Prompt Balancer (Nukun)
Equal-length T5 balancing, plus optional embedding edits
- tokenizer
- positive
- negative
- positive_raw_tokens
- negative_raw_tokens
- effective_target
- positive_sculpted_tokens
- negative_sculpted_tokens
- report
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.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| tokenizer | CLIP | The loaded T5/Qwen tokenizer to use. | |
| target | INT | 10240–4096 | Minimum shared token length for positive and negative prompts. |
| positive | STRING | — | |
| negative | STRING | — | |
| positive_intensity | FLOAT | 0.350–5 | — |
| positive_method | COMBO | forward | 4 options: forward, backward, maximum_absolute, add_minimum_absolute |
| positive_normalization | COMBO | none | 3 options: none, mean, mean * attention |
| negative_intensity | FLOAT | 0.000–5 | — |
| negative_method | COMBO | forward | 4 options: forward, backward, maximum_absolute, add_minimum_absolute |
| negative_normalization | COMBO | mean | 3 options: none, mean, mean * attention |
| top_k | INT | 641–512 | Number of nearest token vectors used for sculpting. |
Outputs (8)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| positive_raw_tokens | INT | — |
| negative_raw_tokens | INT | — |
| effective_target | INT | — |
| positive_sculpted_tokens | INT | — |
| negative_sculpted_tokens | INT | — |
| report | STRING | — |