ComfyUI Node

Model Randomizer

The Checkpoint Randomizer That Kills a Four-Node Muter Chain

By Mervent·Created 6 months ago·Updated 3 months ago· 0
Model Randomizer
    • MODEL
    • CLIP
    • VAE
    • MODEL_NAME
    • CFG
    seed0

    If you've ever built a "random checkpoint" workflow the old way, you know the drill: Load Checkpoint → rgthree's Context Big → Impact Pack's Fast Muter and Random Unmuter, arranged so exactly one muter flips off per run. It works. It also makes your graph look like a plumbing diagram for something that's really one question: which model this time? Model Randomizer collapses that whole chain into a single loader node, and it adds two things the muter dance never gave you - per-model CFG ranges and probability weights.

    The pitch is simple: you keep a list of checkpoints, each with its own CFG min/max, a weight for how likely it is to win, and an enable toggle. Every run, the node picks one, loads it, and hands you a CFG value rolled inside that model's range. Same pack as the WAN2.2 LoRA Randomizer, in case you spot the family resemblance.

    How it works

    The node is two halves. The frontend JS builds a widget row per entry - checkpoint dropdown, cfg_min, cfg_max, weight, enabled - plus Add / Remove and drag-reorder controls that live right on the node. The backend Python, on each execute, parses every ckpt_N widget, discards disabled entries and anything with weight <= 0, then runs a weighted random choice with random.choices. The CFG is a uniform roll inside the entry's range, rounded to one decimal.

    Three implementation details are worth knowing. First, it uses a local random.Random(seed), so it never touches ComfyUI's global RNG and never changes what your other nodes roll. Second, IS_CHANGED returns NaN, which forces a fresh execution every run - without that, ComfyUI's result cache would freeze your first pick forever. Third, there's a tiny instance-level cache: if the same checkpoint wins twice in a row, it skips the reload. Consecutive same-model runs are a real thing when one entry has weight 10 and the others have weight 1.

    Inputs and outputs

    The only fixed input is seed (default 0). Zero means a fresh random pick every run; any non-zero value makes the whole selection reproducible - as long as you don't add, remove, or reorder entries, since that shifts the RNG stream. Every other input is one per model entry:

    • ckpt - dropdown populated from your checkpoints folder
    • cfg_min / cfg_max - both default to 7.0, so a stock entry always rolls exactly 7
    • weight - relative probability; higher wins more often
    • enabled - toggle to park a model without deleting it

    Outputs are MODEL, CLIP, VAE (wire straight into your sampler / conditioning pipeline), plus two extras: MODEL_NAME, the winning checkpoint's filename - genuinely handy for a Save node or just seeing which one hit - and CFG, the float you feed into the KSampler's cfg slot.

    One honest warning: CFG 7 is an SD1.5/SDXL number. If your list is mostly guidance-distilled models - the bulk of what shipped in the last couple of years - those want CFG 1 to 3, and the node will cheerfully hand you 7 if that's what the range says. Set your ranges per model, not per habit.

    Installing it

    No dependencies to fight, which is rare and nice:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Mervent/comfyui-model-randomizer.git
    

    Then restart ComfyUI. Or use ComfyUI Manager - search for "Model Randomizer" or the pack name "comfyui-model-randomizer". There's no requirements.txt and no bundled model downloads: it only loads checkpoints you already have. The node shows up under loaders → Model Randomizer.

    Gotchas

    The main one to trip on: if every entry is disabled or has weight 0, it raises "No enabled models with weight > 0" and the error shows right on the node. Entries with cfg_min greater than cfg_max get silently swapped rather than erroring. And remember that stale checkpoint names are validated against your folder at execution - rename a file and the node will refuse to run until you re-pick it. None of these are hard to recover from; they're just the shape of a node that actually checks its inputs instead of silently passing through garbage.

    Categoryloaders

    Inputs (1)

    NameTypeDefaultDescription
    seedINT00–18446744073709550000Seed for reproducible selection. 0 = random every time.

    Outputs (5)

    NameTypeDescription
    MODELMODELThe diffusion model from the selected checkpoint.
    CLIPCLIPThe CLIP model from the selected checkpoint.
    VAEVAEThe VAE model from the selected checkpoint.
    MODEL_NAMESTRINGFilename of the selected checkpoint.
    CFGFLOATRandom CFG value within the selected model's range.