ComfyUI Node Runs on cloud

Permutations

Test every ordering of a list, not just every value

By ali1234·Created 3 years ago·Updated 3 months ago· 130
Permutations
  • sequence
  • sequence
count0

Most parameter sweeps just want to try each value once - cfg 3, then 5, then 7. Permutations is for the narrower, weirder case: you have a handful of things and you actually care about the order they're applied in. Stacking three LoRAs A→B→C can give a visibly different result than C→B→A, and if you want to check every ordering instead of guessing, this is the node that generates them.

How it works

Under the hood it's a direct wrap of Python's itertools.permutations(sequence, count) - nothing fancier than that. Given a SEQUENCE of items, it produces every possible arrangement of count items drawn from that sequence, in order, without repeats. Feed it ["A", "B", "C"] with count 3 and you get all six orderings back as a new SEQUENCE of tuples. That output is meant to flow straight into MakeJob, which names it and turns it into something the rest of the pack can iterate over - so in practice, Permutations is the node you reach for before MakeJob, specifically when order matters.

Two things worth knowing before you wire this up, both straight from how itertools.permutations actually behaves:

  • The default count of 0 is not "give me everything." itertools.permutations(seq, 0) mathematically has exactly one result: a single empty tuple. If you leave count at its default and wonder why you got one useless step instead of a full sweep, that's why - set count to the length of your sequence for full orderings.
  • This grows factorially, fast. Four items with count 4 is 24 orderings. Six items is 720. Eight is over 40,000. Each one is a full run of your workflow, so it's very easy to accidentally queue an afternoon's worth of GPU time by adding one more item to the list.

The inputs and outputs that matter

  • sequence (SEQUENCE) - the items you want ordered, from an earlier node in the pack that builds a SEQUENCE.
  • count (INT, default 0, min 0, max 9999999) - how many items go into each permutation. Set it equal to your sequence length for full orderings, or lower for partial arrangements (e.g. "give me every 2-item ordering out of these 5 LoRAs").
  • sequence (SEQUENCE, output) - the list of permutation tuples. Wire it into MakeJob next.

How to install it

Via ComfyUI Manager: search "comfyui-job-iterator", install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ali1234/comfyui-job-iterator

No dependencies to fight, no models to download - restart ComfyUI and the node is available.

Common issues & troubleshooting

You got one step and it looked empty. That's the count = 0 trap above. Bump it up to match (or fit within) your sequence length.

Your queue exploded. This is the most common complaint with this node in general - not a bug, just factorial growth doing what factorial growth does. Before you hit queue, do the arithmetic: n! / (n-count)! is how many runs you're about to trigger. If that number is in the thousands, you almost certainly want Combinations instead (a sibling node in this pack that doesn't care about order) or you want to trim your input sequence first.

Honest gap: do orderings actually matter for what you're testing? For most parameters - seed, cfg, steps - order is meaningless and this node is the wrong tool; reach for a plain SEQUENCE into MakeJob instead. Permutations earns its keep specifically for things like LoRA stack order, prompt fragment order, or ControlNet stacking order, where the community has repeatedly found that sequence genuinely changes the output.

Categoryali1234/sequence

Inputs (2)

NameTypeDefaultDescription
sequenceSEQUENCE
countINT00–9999999

Outputs (1)

NameTypeDescription
sequenceSEQUENCE