Nodes/ComfyUI-Prediction/Switch Predictions
ComfyUI Node

Switch Predictions

Swap prediction strategies at whatever timesteps you choose

By redhottensors·Created 3 years ago·Updated 2 years ago· 15
Switch Predictions
  • prediction_A
  • prediction_B
  • sigmas_B
  • prediction

Conceptually, this is the heart of the whole pack: run prediction A everywhere except the timesteps you've chosen, where you run prediction B instead. One line in the README says it all - prediction_B when current_sigma in sigmas_B otherwise prediction_A. Switch Predictions is the node that turns "different strategies at different times" from a theory into a graph, and it's the tool the pack's own README recommends for taming the expensive Characteristic Guidance node.

What it does

At each denoising step it checks whether the current sigma appears in the sigmas_B list. If yes, that step uses prediction_B; otherwise it uses prediction_A. Value-based matching, so you don't need to know step numbers - you tell it which sigma values are B-territory, and it routes each latent accordingly.

Inputs:

  • prediction_A (PREDICTION) - the default strategy.
  • prediction_B (PREDICTION) - the strategy for the chosen timesteps.
  • sigmas_B (SIGMAS) - the timesteps where B takes over.

Output: one prediction.

The partner node

You'll basically never construct sigmas_B by hand - that's what Select Sigmas is for. Its whole job is to produce the filtered sigma list you feed here. The canonical pairing:

  • Select Sigmas takes your full schedule, selects the range you want B to own (say mod 2 for every other step, or 0, 1 for the first couple), and feeds the result into sigmas_B.
  • Switch Predictions takes A, B, and that selection.

Want three strategies? Chain switches, or grab the convenience node Early/Middle/Late Prediction (which is literally two of these in a trench coat). Two strategies is exactly what this node is for.

The classic use

The README's own example is the expensive Characteristic Guidance node: run plain CFG on the first timestep (where CHG rarely converges) and during the tail (where it adds nothing), and let CHG own the middle. That's a Switch with sigmas_B selecting the middle of the schedule. Any cost-heavy strategy deserves the same treatment - it's how you keep a research-grade predictor from turning a 30-step render into a 30-hour one.

A warning about matching

The switch matches by sigma value (torch.isin under the hood). That means sigmas_B must contain values that actually appear in the schedule you're sampling with. If your Select Sigmas produced a range that drifted - the classic cause is forgetting the chained flag, which drops the trailing 0.0 sigma - B just never fires, and you'll burn GPU time wondering why your workflow changed nothing. Log your sigmas (Log Sigmas), verify the selection, and remember a 30-step schedule is 31 sigmas ending in 0.0.

Installing it

Ships in the ComfyUI-Prediction pack by @RedHotTensors (Project RedRocket). ComfyUI Manager → search "ComfyUI-Prediction", or:

cd ComfyUI/custom_nodes
git clone https://github.com/redhottensors/ComfyUI-Prediction

Restart ComfyUI. No extra dependencies or model files. It's under Add Node > sampling > prediction.

Common issues

  • B never activates. Selected sigmas don't match the actual schedule. Check chained on Select Sigmas and the trailing sigma.
  • B activates everywhere. If sigmas_B accidentally covers the whole schedule (or the switch logic surprises you), re-check the selection expression.
  • ControlNet unsupported, so don't plan a ControlNet-conditional switch graph here.
Categorysampling/prediction

Inputs (3)

NameTypeDefaultDescription
prediction_APREDICTION
prediction_BPREDICTION
sigmas_BSIGMAS

Outputs (1)

NameTypeDescription
predictionPREDICTION