Mustache Variable Sampler
The engine that turns candidate pools into real prompts
- variable_defs
- variable_sets
This is the brain of the pack's mustache pipeline. Upstream, Mustache Variables (or Mustache Variable) defines pools - haircolor: [brown, blonde], leglength: [short, long, weird]. Downstream, Mustache Template wants concrete assignments. This node is the bridge: it expands the pools into a MUSTACHE_VARIABLE_LIST, where every entry is one fully-resolved setting like {"haircolor": "brown", "leglength": "short"}. Multiply it out - 2 × 3 = 6 settings - and Mustache Template renders one prompt per setting.
Three controls decide which expansions you get:
sampling_mode-sequential(default) walks the Cartesian product in stable, predictable order: all leg lengths for brown, then all for blonde.randomrandomizes key order, value order, and the emitted permutation order, so you get a seeded random subset of the space instead of a shuffled-in-place version of the product. Same seed → same order, always.seed- the 64-bit seed forrandommode. The entire sampling is deterministic off this; change it and you get a different but reproducible draw.limit- max settings to emit.-1(default) means no limit. This is your explosion control. If your pools multiply to 1,000 combinations and you only want 25, setlimit: 25and stop paying for the rest.
What it resolves that other nodes don't
Two things happen here that the definition nodes can't do. First, lazy placeholder settings like {{color:randomize}} inside YAML values get resolved here, using this node's seeded RNG - so your repeated runs with the same seed stay deterministic. Second, weighted values work through this node: if Mustache Variables tagged a value with a :probability suffix (e.g. black:0.4), random sampling respects those weights instead of drawing uniformly.
The guard rail worth memorizing: with limit = -1, the node is asked to materialize the entire output list, and if the total exceeds 100,000 settings it raises an error on purpose. That's not a bug - it's the pack refusing to look hung while it builds a quarter-million prompts. Use a finite limit for big spaces.
Installing and using it
Part of Skoogeer-Noise. ComfyUI Manager → search "Skoogeer-Noise", or:
cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/Skoogeer-Noise
Restart ComfyUI. No models or keys; deps are torch, numpy, einops, pyyaml.
The canonical graph: Mustache Variables → Mustache Variable Sampler → Mustache Template → CLIP Text Encode. If you want a random subset of a big space every run, set sampling_mode: random and randomize the seed; if you want a repeatable grid search, keep sequential. And remember the mental model: definitions vs. concrete sets. The sampler is the only node that converts one to the other, so if Mustache Template is complaining about types, check that the sampler is actually in the chain.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| variable_defs | MUSTACHE_VARIABLES | Mustache variables mapping to expand into concrete variable settings. | |
| sampling_mode | COMBO | sequential | How to generate concrete variable settings. 'sequential' walks the Cartesian product in stable order. 'random' randomizes key order, value order, and the sampled permutation order. |
| seed | INT | 00–18446744073709550000 | 64-bit seed used when sampling_mode is random. The same seed produces the same sampled variable-setting order. |
| limit | INT | -1-1–2147483647 | Maximum number of concrete variable settings to emit. Use -1 to emit the full Cartesian product. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| variable_sets | MUSTACHE_VARIABLE_LIST | — |