Nodes/ComfyUi-MpiNodes/Mpi If Else Probability
ComfyUI Node

Mpi If Else Probability

Roll a weighted die to decide which branch of your graph runs

By MadPonyInteractive·Created 11 months ago·Updated 5 days ago· 3
Mpi If Else Probability
  • true
  • false
  • output
  • boolean
  • seed
probability0.50
seed0

Want your workflow to occasionally do something different - pick a different prompt, a different LoRA, a different seed path - without you having to flip a switch? That's exactly what Mpi If Else Probability is for. You feed it two values, tell it how often you want the left one versus the right one, and it rolls the dice for you. It's the probability-shaped cousin of the pack's plain MpiIfElse, and it's the node you reach for when you want controlled randomness instead of manual decision-making.

The inputs are true and false (both any type - image, text, model, whatever you want to route) plus two knobs: probability and seed. probability runs 0.0 to 1.0, and the tooltip spells out the edges: 1.0 always outputs true, 0.0 always outputs false, 0.5 is a fair coin flip. The seed is the interesting part. The pick isn't actually random - the node hashes the seed with a multiplicative hash (seed * 2654435761 & 0xFFFFFFFF), normalizes that to a 0–1 value, and compares it against probability. What that buys you is reproducibility: the same seed and probability always produce the same pick. You can land on a great variation, note the seed, and rerun it forever. Wire a fresh seed in when you genuinely want a different roll each run.

Three outputs come out: output (the value you picked), boolean (whether it was true - handy for feeding another logic node), and seed (echoed back so you can chain the same seed into other nodes). One detail worth knowing: the inputs are lazy. Only the branch that gets picked is actually evaluated, so whatever's feeding the losing side never runs. That's a small optimization in most graphs and a real one when a branch is expensive, like a second sampler.

Install is painless - this pack has no Python dependencies at all. In ComfyUI Manager, search "ComfyUi-MpiNodes" and hit install, or drop into a terminal:

cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes

Then restart ComfyUI. It's one of over a hundred utilities from Mad Pony Interactive, the same people behind the Cubric Vision desktop app.

Where people get tripped up: they expect the node to re-roll every run when the seed is fixed. It won't - fixed seed means fixed outcome, by design. If you leave seed at the default 0 you'll get the same answer every time and wonder what the "probability" is doing. That's not a bug; connect a randomizing seed source when you want actual variety. And keep in mind boolean is just the pick, not a callback - if you want to gate a whole branch off based on the result, route boolean into an MpiIfElse and let that node's lazy evaluation do the heavy lifting.

CategoryMpiNodes/Logic

Inputs (4)

NameTypeDefaultDescription
true*
false*
probabilityFLOAT0.500–10.0 will always output 'false' and return False 1.0 will always output 'true' and return True 0.5 gives both a 50% chance
seedINT00–18446744073709550000

Outputs (3)

NameTypeDescription
output*
booleanBOOLEAN
seedINT