Extensions/Seren Sampler
ComfyUI Extension

Seren Sampler

Seren Sampler: momentum-predicted, tolerance-controlled rectified flow sampling, for ComfyUI (Anima family)

By seren-alegro·Created 27 days ago·Updated 3 days ago· 0
seren-alegro/ComfyUI-SerenSampler
Nodes—
On cloudLocal install
Stars0
Updated3 days ago
Readme

ComfyUI-SerenSampler

Seren Sampler - an experimental sampler for rectified flow models (Anima family), for ComfyUI.

v0.3.0 - this release adds two samplers (seren_detail, seren_soft), pod-tested on a real model (Anima base v1.0, A40): Detail raised high-frequency energy +18-25% and Soft lowered it -15-21%, with composition and colour effectively unchanged (pixel RMS 3.5-3.9/255) and no plastic skin at the default strength. A third beta sampler, seren_refine, showed no visible difference from base Seren in the same A/B, so per the design's honesty gate it was demoted to a preset (see Usage) instead of shipping as a sampler. The original three keep their v0.2.2 behaviour, mirror-verified unchanged.

The idea

Two earlier packs meet in one mechanism:

  • From FlowMomentum: a momentum vector, an exponential moving average of past velocities.
  • From AdaptiveFlow: tolerance control - no fixed step grid; each step must earn its size.

Seren uses the momentum as a predictor. It proposes the next point for free (x_pred = x + m * dSigma); a single model evaluation there plus a trapezoid correction gives the candidate step, and the gap between prediction and correction is the error estimate that grows or shrinks the next step. A typical accepted step costs one model evaluation - the error estimate does not need a second one.

This is a deterministic rectified-flow ODE walk: no stochastic noise term, no look-ahead evaluation blended back into the step, no adaptive noise. The momentum never touches the model input; it only proposes points and measures surprise.

Node

Seren Sampler (momentum x adaptive) - sampling/seren

Inputs:

  • seed, cfg, flow_shift - as usual for this family of packs.
  • tolerance (default 0.01) - allowed per-step prediction error, relative RMS. Smaller = slower and more faithful.
  • beta (default 0.5) - momentum memory: 0 follows only the last velocity, higher values remember longer. Long memory predicts smoothly but can go stale where the trajectory curves hard.
  • max_steps (default 120) - budget cap, not a step count. If the trial budget (2 x max_steps) ever runs out, the remainder is finished with plain fixed-step Euler.

Outputs: latent, steps_used, evals_used - so you can see what a run actually cost.

Seren SDE Sampler (error-shaken) - sampling/seren

The stochastic sibling. After each accepted step, part of the state's implied noise is swapped for fresh noise along the rectified-flow interpolation line. The swap amount is gated by how hard the step just was (err / tolerance, capped by sde_strength, default 0.3): calm stretches stay nearly deterministic, uncertain stretches get shaken. The noise follows the local error topography of this walk - not a schedule tied to overall progress - and the tolerance controller still governs step sizes. Extra input: sde_strength (0-1; 0 = base Seren).

Seren Color Sampler (chroma steering) - sampling/seren

Colour handled inside the walk instead of as an after-the-fact boost: in the low-sigma stretch (sigma <= color_start, default 0.35) where colour settles, each accepted step's denoised estimate is pushed away from its per-channel spatial mean and the state is shifted to match, bending the trajectory toward richer colour while the model keeps re-denoising it. The per-step gain is scaled by the fraction of the steered band the step covers, so the total bend is set by color_strength alone and does not grow with step count; the per-step shift is also capped at 10% of the state RMS as a runaway guard. Extra inputs: color_strength (default 0.15), color_start.

Seren Detail Sampler (high-frequency steering) - sampling/seren

Texture handled inside the walk, on the same steering pattern as Color but against a different reference: in the band sigma <= detail_start (default 0.45), each accepted step's denoised estimate is split by a spatial low-pass (5x5 box blur) into low and high frequency parts, and only the high part - hair, fabric folds, skin texture - is amplified. The low part (composition, broad shading, colour masses) is untouched, the total bend is set by detail_strength alone (default 0.20) at any step count, and the per-step shift is capped at 10% of the state RMS. Above detail_start it is exactly the base walk. Extra inputs: detail_strength (0-1), detail_start.

Seren Soft Sampler (high-frequency softening) - sampling/seren

The signed pair of Detail: the same low/high split, with the gain exponent negated, so the high-frequency part is attenuated instead of amplified and the trajectory bends toward softer, dreamier texture while composition and colour stay put. Because softening is harder to undo than sharpening, the per-step shift is capped tighter, at 7% of the state RMS. Extra inputs: soft_strength (default 0.20), soft_start (default 0.45).

KSampler registration

The pack also registers seren, seren_sde, seren_color, seren_detail and seren_soft in the standard KSampler sampler_name dropdown, with fixed defaults (tolerance 0.01, beta 0.5; sde_strength 0.3 / color_strength 0.15 / detail_strength 0.20 / soft_strength 0.20 for the siblings; shift estimated from the incoming sigma grid). Use any scheduler with them; the walk adapts its own steps between the grid's endpoints. The standalone nodes remain the way to tune the knobs.

Usage

Two ways to run every sampler: the standalone nodes (all knobs exposed) or the KSampler dropdown registrations (fixed defaults, any scheduler - the walk builds its own steps between the grid's endpoints). With a fixed seed everything in this pack is fully reproducible, including the SDE sibling: its noise is seed-driven, so the same seed returns the same image.

Seren (base) - start from the defaults. tolerance is the main quality/speed dial: 0.01 is a good middle, smaller is slower and more faithful, larger is faster and looser. beta 0.5 is the balanced memory; longer memory (0.7+) walks smoother but can drag stale direction through hard curves. max_steps is a budget cap, not a step count - the steps_used / evals_used outputs show what a run cost.

Seren SDE - sde_strength 0 is exactly the base walk. 0.2-0.3 gives visible variation while staying close to the deterministic trajectory; expect the endpoint to move more as strength rises, because every hard step gets shaken. If a result looks unstable, lower strength before touching tolerance.

Seren Color - color_strength sets the total bend across the steered band: each step applies the fraction of it that the step actually covers, so the effect is the same at any step count - a standalone run and a dense refine walk read the number the same way. Start at 0.1-0.15 (the registered default is 0.15, calibrated after 0.35 proved garish in practice). For a stronger effect, raise color_start (steer more of the trajectory) rather than cranking strength; the per-step shift is capped at 10% of the state RMS as a guard.

Seren Detail - detail_strength sets the total texture bend across the band, read the same way at any step count, like Color. Start at the default 0.2: this is deliberately weak, because over-amplified high frequencies are exactly what makes skin look plastic. If a result looks harsh, lower strength before raising detail_start.

Seren Soft - the opposite dial for dreamy checkpoints. Start at 0.2; if edges (eyes, hair strands) start dying before the rough texture settles, lower soft_start to 0.35 so the softening acts later in the walk.

Refine preset - the beta's seren_refine sampler became a preset after pod A/B showed no visible difference from base Seren (pixel RMS 5.3-5.5/255, no detail gain, no colour wash). For a deterministic finishing pass, use the base Seren node as the stage-2 sampler at denoise 0.3-0.4 with tolerance 0.005 and beta 0.35 - that is the whole recipe; the warm start and tighter step-growth cap did not earn their keep.

Two-stage refine recipe - a good pairing is: stage 1 any sampler at denoise 1.0, stage 2 seren or seren_color at denoise 0.3-0.4 for a deterministic finishing pass (or the refine preset above). One warning: splitting denoise across two KSamplers does not split this walk - a registered Seren run always walks to completion from the sigma it is handed (img2img semantics), so for a true mid-trajectory hand-off put a grid sampler (euler, dpmpp_2m_sde, ...) in stage 1.

Forge Neo port - the Forge Neo extension still ships the original three samplers (seren, seren_sde, seren_color). Detail and Soft passed pod testing and will be mirrored there next; the refine preset needs no port - it is just base Seren settings.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/seren-alegro/ComfyUI-SerenSampler

Then restart ComfyUI.

Example

examples/seren_sampler_basic.json - a minimal workflow using the standalone Seren Sampler node (core nodes only; swap in your own checkpoint, TE and VAE loaders as needed).

Tests

tests/test_seren.py - numpy mirror of the core walk (no torch needed): tolerance sweep, evaluation economy (~1 eval per step), beta variations, and the trial-budget fallback. tests/test_seren_sde.py - shake mirror: strength 0 is exactly deterministic, strength > 0 diversifies endpoints and completes in budget (error bounds are loose by design - the test field is expansive and punishes any stochasticity far more than a trained denoiser does). tests/test_seren_color.py - steering mirror: strength 0 is exactly the base walk, strength > 0 stays finite and moves the endpoint. tests/test_seren_detail.py / tests/test_seren_soft.py - high-frequency steering mirrors: strength 0 is exactly the base walk, strength > 0 moves the endpoint and raises (Detail) or lowers (Soft) its high-frequency energy, and the steering displacement is step-count invariant (measured ratios 0.95 / 1.04 between ~30-step and ~100-step walks). tests/test_seren_refine.py - historical mirror of the demoted beta sampler, kept for the record: it documents the warm-start walk and the design's honesty gate that the pod A/B later settled (no visible difference, so preset it is).

License

MIT


한국어 요약

FlowMomentum의 모멘텀과 AdaptiveFlow의 허용 오차 제어를 하나로 합친 실험 샘플러예요. 모멘텀이 다음 지점을 공짜로 예측하고, 거기서 모델을 한 번만 평가해 보정하면, 예측과 보정의 차이가 곧 오차 추정이 돼요. 그래서 채택 스텝 하나에 모델 호출이 보통 한 번이면 되고, 스텝 크기는 tolerance가 알아서 조절해요. 결정적 rectified flow 전용이며, KSampler 드롭다운에도 seren이라는 이름으로 등록돼요.

자매 샘플러가 둘 있어요. seren_sde는 확률형으로, 채택된 스텝이 얼마나 힘들었는지(오차/허용치)에 비례해 그 스텝의 노이즈 일부를 새 노이즈로 갈아 끼워요 — 잔잔한 구간은 거의 결정적이고, 불안한 구간만 흔들려요. seren_color는 색을 결과물에 사후 보정하지 않고 보행 도중에 다뤄요: 색이 자리 잡는 낮은 시그마 구간에서 매 스텝의 예측 완성본을 채널 평균에서 밀어내 궤적 자체를 풍부한 색 쪽으로 굽혀요.

사용법 요점: color의 총량은 strength 하나로 정해지고 스텝 수에 따라 불어나지 않아요. 0.1~0.15에서 시작하세요 (0.35는 실측에서 과했어요). 2단 리파인으로는 1단 아무 샘플러 denoise 1.0 + 2단 seren/seren_color 0.3~0.4 조합이 잘 맞아요. 고정 시드에서는 확률형 포함 전부 재현돼요.

v0.3.0에서 자매 샘플러가 둘 더 늘었어요. seren_detail은 낮은 시그마 구간에서 예측 완성본을 공간 저역통과(5×5 블러)로 나눠 고주파만 증폭해요 — 구도와 색은 그대로, 머리카락·옷 주름·피부 질감 같은 결만 또렷해져요. 기본값 0.20은 피부 플라스틱감을 피하려고 일부러 약하게 잡았어요. seren_soft는 그 부호 쌍으로, 고주파를 감쇠시켜 궤적 자체가 부드럽고 몽환한 쪽으로 굽어요 (캡은 7%로 더 조였어요). 둘 다 총량은 strength 하나로 정해지고 스텝 수에 따라 불어나지 않아요. 포드 실측(Anima base v1.0)에서도 판정이 그대로 나왔어요: detail은 고주파 +18~25%, soft는 −15~21%, 구도·색은 사실상 불변이고 피부에 플라스틱감도 없었어요. 베타에 있던 seren_refine은 같은 실측에서 본체와 눈에 보이는 차이가 없어서, 설계안의 정직성 게이트대로 샘플러에서 내리고 프리셋으로 강등했어요 — 2단 denoise 0.3~0.4에 본체 tolerance 0.005·beta 0.35가 레시피의 전부예요. Forge Neo판은 아직 기존 3종만 있고, detail·soft를 다음에 미러링할 예정이에요.