Nodes/ArtyClaw Comfy Nodes/RNG LoRA Weight Injector
ComfyUI Node

RNG LoRA Weight Injector

Roll a Random LoRA Weight Into Every Generation

By artyclaw·Created 5 months ago·Updated 5 months ago· 0
RNG LoRA Weight Injector
    • prompt
    prompt<lora:MyLora:--->
    wildcard---
    start0.60
    end1.20
    same_for_alltrue
    decimals2
    seed0
    triangular_biasfalse

    This is the "roll the dice on LoRA strength" node. You hand it a prompt like <lora:MyLora:--->, tell it what to replace (---), and it swaps in a random float between start and end every run. No sum-balancing, no scaling - it's the sibling of the pack's LoRA Weight Balancer, but where that node balances a whole stack toward a target total, this one just injects random per-tag weights and moves on.

    It's from artyclaw/artyclaw-comfy, the author's personal pack of prompt-logic utilities. The default prompt is literally <lora:MyLora:--->, which tells you exactly how the author uses it: keep the tag, randomize the strength, see what sticks.

    How it works

    The mechanism is deliberately small. It counts how many times wildcard appears in your prompt, then:

    • If same_for_all is on, it draws one value and replaces every occurrence with it - useful when you want a whole stack to move together.
    • If off, each occurrence gets its own independent draw.
    • Values come from random.uniform(start, end), unless triangular_bias is on, which uses random.triangular to favor values near the midpoint. That's the "safer random" setting: you still get variety, but extremes become rare instead of equally likely.
    • decimals controls how many digits after the point (0–6, default 2), so you get 0.85 rather than 0.8539472 - and short, clean weights read better in a saved workflow.

    The one detail worth noticing: seed = 0 means "random seed." Every other node in this pack uses 0 as a fixed seed; here 0 explicitly produces non-deterministic randomness, and any non-zero seed makes the run reproducible. That's an intentional design fork, so don't expect 0 to reproduce anything.

    Inputs and outputs

    The inputs that matter for a first run:

    • prompt - the full prompt with your placeholder.
    • wildcard - the substring to replace (--- by default).
    • start / end - the low and high bounds of the random weight (defaults 0.6–1.2).
    • same_for_all - one shared value, or fresh per tag.
    • seed - 0 for random, anything else for deterministic.

    One output, prompt, which goes straight into a CLIP text encode. If the wildcard doesn't appear in the prompt, the text passes through untouched - silently.

    Install

    ComfyUI Manager → search ArtyClaw Comfy Nodes, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/artyclaw/artyclaw-comfy
    

    Restart. Pure Python, no dependencies, no downloads.

    Where people get burned

    The same_for_all trap is the common one: if you want independent weights per LoRA and leave it at the default (on), every tag gets the same value and your "randomness" is one knob. Flip it off. Second, negative bounds are allowed (start/end go down to -10), which is a real feature for negative-strength experiments, but it also means a mistyped range silently produces negative weights. Third, remember seed 0 isn't deterministic here - if your batches aren't reproducing, that's why. It's a tiny node, and the biggest risk is expecting more from it than it is: it randomizes weights, it doesn't curate them.

    CategoryPrompting/Utilities

    Inputs (8)

    NameTypeDefaultDescription
    promptSTRING<lora:MyLora:--->
    wildcardSTRING---Substring to replace with random float values.
    startFLOAT0.60-10–10Minimum random value.
    endFLOAT1.20-10–10Maximum random value.
    same_for_allBOOLEANtrueUse one RNG value for all wildcards, or a new one for each.
    decimalsINT20–6Digits after decimal point.
    seedINT00–2147483647Seed for deterministic randomness. 0 = random seed.
    triangular_biasBOOLEANfalseIf enabled, bias RNG values toward midpoint.

    Outputs (1)

    NameTypeDescription
    promptSTRING