Nodes/Twinflow Node for ComfyUI/TwinFlow Scheduler
ComfyUI Node

TwinFlow Scheduler

The unglamorous node TwinFlow can't run without

By mengqin·Created 8 months ago·Updated 6 months ago· 44
TwinFlow Scheduler
    • SIGMAS
    steps2
    dist_ctrl_a1.00
    dist_ctrl_b1.00
    dist_ctrl_c1.00
    gap_start0.001
    gap_end0.600

    Every sampler needs a schedule - the map of how much noise is left at each step - and TwinFlow's isn't in the standard set. The TwinFlow Scheduler produces the SIGMAS for TwinFlow's rectified-flow path, using a Kumaraswamy time transform and a "gap" that confines the steps to the slice of the flow where a distilled model actually does its work. On its own it does nothing visible; wired into SamplerCustom next to the TwinFlow Sampler, it's what makes 2-4 step generation come out right instead of as mush.

    If the TwinFlow KSampler is the easy button, this node is the manual lever. Stock schedulers assume a full denoising trajectory; TwinFlow's few-step models want a schedule that spends its steps in the transport region and then jumps - and that part doesn't survive a stock scheduler. It's the least glamorous node in the pack and the one the whole thing quietly depends on.

    How it works

    Short chain of math on a grid of steps points:

    1. build a 0→1 linspace,
    2. rescale it into the window [gap_start, 1 - gap_end],
    3. push it through a Kumaraswamy transform - (1 - (1 - t^a)^b)^c, with dist_ctrl_a/b/c - to redistribute the steps,
    4. convert to sigma values (1 - t) and append a trailing zero.

    With all three dist_ctrl values at 1.0 the transform is identity, so you get a linear schedule. The defaults tell you where the design lives: gap_start 0.001, gap_end 0.6 - meaning the schedule covers only the first ~40% of normalized time, the noisy end, which is where the flow's transport happens. Move the gaps to shift where the steps land.

    The inputs

    • steps - how many sampling steps (default 2; the few-step regime lives at 2-4).
    • dist_ctrl_a / dist_ctrl_b / dist_ctrl_c - Kumaraswamy shape controls; 1.0 = linear. Tune these when you want to push step density toward the start or end of the window.
    • gap_start / gap_end - the flow boundaries; the defaults are what the author ships.

    Output: a single SIGMAS, which feeds SamplerCustom alongside the TwinFlow Sampler:

    TwinFlowScheduler (SIGMAS)  ──▶ SamplerCustom
    TwinFlowSampler (SAMPLER)   ──▶ SamplerCustom
    

    Installing it and what goes wrong

    Same as every node in this pack - ComfyUI Manager, search "TwinFlow", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/mengqin/ComfyUI-TwinFlow.git
    pip install -r requirements.txt
    

    No extra models, no special dependencies beyond the pack's requirements. Restart ComfyUI and it appears under custom_sampling/schedulers.

    The failure modes here are mostly about the chain around it:

    • Stock scheduler instead of this one - a Karras or normal schedule on a 2-step TwinFlow run produces mush; the gap logic is load-bearing.
    • Patcher missing upstream - the scheduler feeds sigmas, but the model still needs the patcher's restored embedder, or none of this means anything.
    • Steps drifting up - this schedule is designed for the few/multi-step styles; cranking to 30 steps with the defaults isn't the point. Want more steps? Switch the TwinFlow Sampler's sampling_style to any rather than fighting the defaults.

    If you don't need to see the chain, the TwinFlow KSampler embeds this exact logic and spares you the wiring.

    Categorysampling/custom_sampling/schedulers

    Inputs (6)

    NameTypeDefaultDescription
    stepsINT21–100
    dist_ctrl_aFLOAT1.000.01–10
    dist_ctrl_bFLOAT1.000.01–10
    dist_ctrl_cFLOAT1.000.01–10
    gap_startFLOAT0.0010–1
    gap_endFLOAT0.6000–1

    Outputs (1)

    NameTypeDescription
    SIGMASSIGMAS