ComfyUI Node

TwinFlow Sampler

TwinFlow's sampler, for people who build their own chain

By mengqin·Created 8 months ago·Updated 6 months ago· 44
TwinFlow Sampler
    • SAMPLER
    sampling_methodeuler
    stochast_ratio1.00
    extrapol_ratio0.00
    sampling_stylefew

    The TwinFlow Sampler is the modular route to the same one-/few-step magic the TwinFlow KSampler bundles up. Instead of an all-in-one box, it emits just a SAMPLER object - the exact type the standard SamplerCustom node accepts - so you assemble the chain yourself: this node for the sampler, the TwinFlow Scheduler for the SIGMAS, a SamplerCustom in the middle, and every step visible in the graph.

    It exists for two reasons. First, modularity - the same reason anyone reaches for SamplerCustom over a KSampler. Second, honesty about the mechanism: TwinFlow's sampling isn't the stock sampler logic. It solves a rectified-flow ODE with a target-timestep twist, and that twist is exactly what makes the distilled model behave. A stock sampler won't do it; this node is how you bolt it into a custom chain.

    How it works

    This pack reimplements TwinFlow's sampling to ComfyUI's spec rather than vendoring the reference implementation, so the node plugs into anything that accepts a SAMPLER. Internally it:

    • runs euler (1st order) or heun (2nd order) on the flow,
    • mixes fresh noise into each step according to stochast_ratio (1.0 = fully stochastic, 0.0 = deterministic ODE),
    • applies extrapol_ratio to extrapolate the reconstruction (off at 0.0),
    • and uses sampling_style to choose what timestep the model aims at: few targets the fully-denoised endpoint every step (the 2-4 step mode), any targets the next step (flexible counts), mul keeps the current step as its target (multi-step).

    All of it runs through comfy.samplers.KSAMPLER, so it works anywhere a SAMPLER is expected - not just SamplerCustom.

    The inputs that matter

    There are only four, which is the whole appeal:

    • sampling_style - few / any / mul. Start with few if you're chasing speed.
    • sampling_method - euler (default) or heun.
    • stochast_ratio - default 1.0; the noise-mixing dial.
    • extrapol_ratio - default 0.0; leave it unless you're experimenting.

    Output is a single SAMPLER. Wire it up like this:

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

    Feed the patched model and conditioning into SamplerCustom like any custom-sampling chain. Install is the standard pack route - ComfyUI Manager, search "TwinFlow", or:

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

    When it goes wrong

    • Wrong look entirely - if you're feeding a patched TwinFlow model into a stock Euler or DDIM sampler instead of this node, stop. The target-timestep conditioning never gets set, and you're just running the base model awkwardly.
    • Chain misses a piece - SamplerCustom needs SIGMAS from the TwinFlow Scheduler, not a stock scheduler. The stock ones assume a different schedule and produce garbage at 2-4 steps.
    • Model unpatched - no sampler fixes a model that wasn't patched first. TwinFlow Model Patcher, then this, in that order.

    If you just want an image without assembling a chain, the TwinFlow KSampler does all of this internally. Reach for this node when you want control, or plan to reuse the sampler in a bigger custom pipeline.

    Categorysampling/custom_sampling/samplers

    Inputs (4)

    NameTypeDefaultDescription
    sampling_methodCOMBOeuler2 options: euler, heun
    stochast_ratioFLOAT1.000–1
    extrapol_ratioFLOAT0.000–1
    sampling_styleCOMBOfew3 options: few, any, mul

    Outputs (1)

    NameTypeDescription
    SAMPLERSAMPLER