Nodes/ComfyUI-lhyNodes/CLIP Text Encode (Cached)
ComfyUI Node

CLIP Text Encode (Cached)

The text encoder that stops re-doing work it already did

By lihaoyun6·Created 11 months ago·Updated 11 days ago· 20
CLIP Text Encode (Cached)
    • positive
    • negative
    clip_name
    type
    positive_prompt
    negative_prompt
    disk_cachetrue
    device

    CLIP Text Encode (Cached) is the pack author's "small caching experiment" that turned into a genuinely useful node: a text encoder that remembers its last result. Every time ComfyUI queues a run, every text encoder in the graph re-tokenizes and re-runs its prompt through the CLIP model - even if the text hasn't changed since the last run. This node keeps the last (CLIP, text) pair it encoded and, if both are unchanged, hands back the cached conditioning and skips the whole encode.

    In a normal single-prompt workflow the saving is modest - one encode is a few hundred milliseconds. But the author's world is large, complex workflows with six to eight samplers, XY-plot sweeps, and repeated queues while you tweak a denoise slider. There, the same prompt gets encoded over and over, and the savings compound across every sampler in the graph. It's the single-text cousin of the pack's AK CLIP Encode Multiple, which does the same caching trick across a whole list of prompts at once.

    The inputs. Just two: clip and text. The catch to know before you wire it: text is marked forceInput, so unlike the stock CLIP Text Encode node it's an input port rather than a box you type straight into. In practice you feed it from a primitive or a string node - which is actually the pattern the author uses everywhere (his Project Settings panel hands prompts out as strings), and it's what makes the caching meaningful: the text arrives as a value, stays identical across queues, and the node can skip re-encoding it.

    The output. conditioning, exactly what a KSampler's positive or negative input expects. It's a drop-in replacement for the stock encoder in that sense - swap one for the other in a wiring and the graph keeps working, just faster on repeats.

    How to install. ComfyUI Manager (search "AK Pack") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/akawana/ComfyUI-Utils-extra
    

    Restart ComfyUI. No dependencies, no model downloads.

    Where people get burned. The cache is exactly one entry. If you flip between two prompts on consecutive queues, you'll re-encode every time - the cache only pays off when the text actually stays put, which is the normal case during parameter tuning. It's also a per-process cache, so it does nothing across ComfyUI restarts (though that's fine, since the graph re-executes anyway). And the forceInput thing really does catch people: if you drag this node in expecting a typeable textarea like stock CLIP Text Encode, you'll hunt for a field that isn't there. Wire the text in and it behaves.

    CategorylhyNodes/Conditioning

    Inputs (6)

    NameTypeDefaultDescription
    clip_nameCOMBO0 options:
    typeCOMBO24 options: stable_diffusion, stable_cascade, sd3, stable_audio, mochi, ltxv, +18
    positive_promptSTRING
    negative_promptSTRING
    disk_cacheBOOLEANtrueCache the text embeddings to disk for faster re-use.
    deviceoptCOMBO2 options: default, cpu

    Outputs (2)

    NameTypeDescription
    positiveCONDITIONING
    negativeCONDITIONING