Guider math
Modify the sampler's steering mid-generation, per step
- V
- F
- Expression
- Expression1
- stack
- GUIDER
- STACK
A guider is what steers a sampler toward your prompt - CFG is the best-known one, and any guidance tweak (freeu, perturbed attention, style-aligned) is a guider under the hood. Guider math from More Math is a node that wraps one or more guiders, runs an expression on the tensor at every step, and - critically - can remember state between steps. This is the pack's answer to "I want my guidance to change over the course of the sample."
How it works
You feed it guider(s) in V (V0, V1, ...), floats in F (F0, ...), and a main Expression that's evaluated during sampling with a step context: steps and current_step are in scope, alongside the usual variables. The default is just V0 - pass-through. The useful version looks like V0 * clamp(1.2 - current_step/steps, 0, 1) - guidance that eases off as sampling progresses. The pack's aliases are worth knowing: a=G0, b=G1, c=G2, d=G3, and w, x, y, z for the first four floats.
Expression1 is a second expression applied after generation finishes (default sample), for post-hoc adjustments. And remember_stack matters here more than anywhere: because a guider node runs once per step, the STACK is how you carry values across steps - a running accumulator, an envelope counter, anything stateful. The pack ships an example workflow (stack_guider.json) showing exactly this pattern.
Inputs and outputs
V (guiders), F (floats), Expression, Expression1, remember_stack, and the optional stack. Outputs are GUIDER and STACK. The guider feeds a sampler node's guider input - this is advanced ComfyUI plumbing, not a beginner node.
Installing it
Same as the whole pack:
cd ComfyUI/custom_nodes
git clone https://github.com/mcDandy/more_math
cd more_math
pip install -r requirements.txt
Restart ComfyUI, or install "More math" from ComfyUI Manager. Only real dependency is antlr4-python3-runtime beyond torch.
Gotchas
This is the node where people overreach first. Changing the tensor at every step can destabilize a sample fast - small, clamped deltas are your friend, and print() is in the function library if you need to see what's happening at a given step. Remember remember_stack: if it's off, each step gets its own copy of the stack and your accumulator goes nowhere. And know that guiders are model-dependent - an expression tuned on one checkpoint may do nothing useful on another. It's a brand-new, solo-maintained pack, and this is the deepest node in it, so expect to experiment. When it clicks, though, per-step guidance is a genuinely powerful dial that stock ComfyUI just doesn't give you.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| V | COMFY_AUTOGROW_V3 | — | |
| F | COMFY_AUTOGROW_V3 | — | |
| Expression | STRING,SYNTAX_TREE | V0 | Expression to apply on input guiders. Aliases: a=G0, b=G1, c=G2, d=G3, w=F0, x=F1, y=F2, z=F3. Context: steps, current_step |
| Expression1 | STRING,SYNTAX_TREE | sample | Expression to apply after generation finishes. |
| remember_stack | BOOLEAN | false | If enabled, stack is copied at output leading to changes being remembered during batch operations (node runs multiple times in sucession). If disabled each batch gets it's own copy of the stack. |
| stackopt | STACK | Access stack between nodes |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| GUIDER | GUIDER | — |
| STACK | STACK | — |