ComfyUI Node

LockSeed

One random seed you can freeze — the boring node that tames randomness

By Inzaniak·Created 3 years ago·Updated 3 months ago· 26
LockSeed
    • INT
    use_lastfalse

    LockSeed is a three-line node with a surprisingly useful job: it hands you a fresh random integer every run, and remembers the last one. Flip its single input and it hands you the same integer again. That's it. There are flashier ways to solve this problem - one-shot random seed nodes with ten inputs - but for what it does, this one is hard to argue with.

    Why does this matter? Every other random node in this pack (Ranbooru, RandomPicturePath, PromptMix) is deliberately non-deterministic: they report themselves as always-dirty so ComfyUI re-runs them on every queue. That's what you want for roulette workflows. But sometimes you want the opposite - you want one roll to propagate everywhere. That's the "lock" part.

    How it works

    On each execution it generates random.randint(0, 1000000000) and stores it internally. If use_last is on and a previous value exists, it returns that instead. Simple, stateless across runs, no persistence beyond the current ComfyUI session.

    The classic pairing is feeding it into Ranbooru's seed input. Drop both nodes in, and on one run you get a tag set; with LockSeed set to use_last, the next run keeps the same tags so you can tweak sampler settings and actually compare apples to apples. Without a locked seed, every queue run re-rolls and your A/B test is testing noise, not your settings. Same trick works anywhere you want a stable-but-random value across multiple random nodes in a graph.

    Inputs and outputs

    • use_last - BOOLEAN, default off. On = reuse the previous seed.

    Output is a single INT. Wire it into anything that takes a seed: samplers, other Ranbooru nodes, whatever.

    Installing it

    It ships with the Ranbooru pack, so install is the whole pack: ComfyUI Manager, search "Ranbooru", or

    cd ComfyUI/custom_nodes
    git clone https://github.com/Inzaniak/comfyui-ranbooru
    

    then restart. No requirements.txt, no model downloads - this node imports nothing but random.

    Common issues

    Honestly, there aren't many ways to break this one. The one thing to keep in mind: the remembered seed lives in the node instance, so it doesn't survive a ComfyUI restart. If you restart mid-experiment, use_last has nothing to return and it rolls a new seed. If you need a seed that survives restarts, you're better off with a fixed seed constant or a workflow-saved value - LockSeed is for within a session.

    CategoryRanbooru Nodes

    Inputs (1)

    NameTypeDefaultDescription
    use_lastBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    INTINT