Nodes/Skoogeer-Noise/Mustache Variable Sampler
ComfyUI Node

Mustache Variable Sampler

The engine that turns candidate pools into real prompts

By ttulttul·Created 9 months ago·Updated 3 months ago· 14
Mustache Variable Sampler
  • variable_defs
  • variable_sets
sampling_modesequential
seed0
limit-1

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. random randomizes 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 for random mode. 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, set limit: 25 and 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 VariablesMustache Variable SamplerMustache TemplateCLIP 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.

Categorytext/template

Inputs (4)

NameTypeDefaultDescription
variable_defsMUSTACHE_VARIABLESMustache variables mapping to expand into concrete variable settings.
sampling_modeCOMBOsequentialHow to generate concrete variable settings. 'sequential' walks the Cartesian product in stable order. 'random' randomizes key order, value order, and the sampled permutation order.
seedINT00–1844674407370955000064-bit seed used when sampling_mode is random. The same seed produces the same sampled variable-setting order.
limitINT-1-1–2147483647Maximum number of concrete variable settings to emit. Use -1 to emit the full Cartesian product.

Outputs (1)

NameTypeDescription
variable_setsMUSTACHE_VARIABLE_LIST