# ChebyFlow **Adaptive Chebyshev Flow Sampling for ComfyUI** ChebyFlow is an experimental sampler for rectified-flow / `CONST` models such as **MiniMax H3**. It uses a two-stage Chebyshev-style integration step and adapts the position of the second model evaluation based on the local behavior of the flow field. The sampler also adapts the correction applied after that second evaluation. In Auto mode, this happens through online self-calibration during the current generation. ChebyFlow outputs a standard ComfyUI `SAMPLER` and is intended for use with `SamplerCustomAdvanced`. ## Features - Adaptive two-stage flow sampling - Online self-calibration - Residual, directional and magnitude-based flow analysis - Adaptive internal stage placement - Adaptive correction strength - Optional per-channel correction - Turbo mode for low-step workflows - Auto and Advanced sampler nodes - No additional dependencies - No calibration runs or extra model weights required ChebyFlow normally uses about **2 model evaluations per non-terminal sampling interval**. --- # Installation Copy the folder to: ```text ComfyUI/custom_nodes/ComfyUI-ChebyFlow/ ``` The directory should contain: ```text ComfyUI-ChebyFlow/ ├── __init__.py ├── chebyflow.py └── README.md ``` Restart ComfyUI after installation. --- # Usage ChebyFlow outputs a normal `SAMPLER`. Connect it directly to the `sampler` input of `SamplerCustomAdvanced`. ```text RandomNoise ----------------------\ Guider ----------------------------+--> SamplerCustomAdvanced ChebyFlow Auto Sampler -----------/ Scheduler -----------------------/ Latent --------------------------/ ``` The scheduler continues to provide the `SIGMAS`. ChebyFlow does not replace the scheduler and does not modify MiniMax H3's internal audio/video sigma handling. --- # Recommended Scheduler For MiniMax H3, the current recommendation is: ```text beta ``` `beta` has produced the best results during development. The regular: ```text beta57 ``` scheduler also works well. Other schedulers are fully supported and worth experimenting with. ChebyFlow uses the sigma sequence provided by the workflow and does not require a specific scheduler. Current recommendation: ```text beta57 -> preferred beta -> known to work well other -> supported / experimental ``` --- # ChebyFlow Auto Sampler The Auto sampler is recommended for normal use. It measures the local flow behavior during generation and automatically adjusts: - the position of the second model evaluation - the strength of the Chebyshev correction - optionally, the correction strength of individual latent channels No previous generations or calibration data are required. The first part of the trajectory is used to establish a running baseline. The sampler then compares later intervals against that baseline and reacts to regions that are easier or harder than normal. Recommended starting settings: ```text coordinate = flow_lambda base_stage_position = 0.72 min_stage_position = 0.58 max_stage_position = 0.96 adaptivity = 1.00 quality_bias = balanced turbo_mode = false correction_granularity = per_channel ``` ## Auto Parameters ### `coordinate` Available values: ```text flow_lambda sigma ``` Controls the coordinate system used to place the internal second evaluation. `flow_lambda` is recommended for MiniMax H3. It uses: ```text lambda = log((1 - sigma) / sigma) ``` `sigma` places the internal evaluation directly in raw flow-sigma space. --- ### `base_stage_position` Default: ```text 0.72 ``` The neutral position of the second model evaluation within each sampling interval. Examples: ```text 0.50 -> midpoint 0.72 -> moderately late 0.90 -> close to the next sampling state ``` The Auto controller moves around this value depending on the measured local difficulty. There is also a practical stability/diversity tradeoff associated with stage placement: - **Higher stage positions** place the second model evaluation closer to the next sampling state and generally tend to favor more stable, consistent trajectories. - **Lower stage positions** evaluate the model earlier in the interval and can allow more trajectory freedom, which may increase variation between different seeds or conditioning at the cost of some stability. This is a tendency rather than a strict rule and can depend on the model, scheduler and step count. ChebyFlow itself remains deterministic: lowering the stage position does not introduce randomness. “More diversity” refers to allowing differences between seeds or conditioning to develop more strongly. --- ### `min_stage_position` Default: ```text 0.58 ``` The earliest position the controller may choose for the second evaluation. Increasing this value keeps ChebyFlow consistently more endpoint-biased and generally favors stability. Lowering it gives the adaptive controller more freedom to use earlier internal evaluations, which can allow more trajectory variation and diversity. --- ### `max_stage_position` Default: ```text 0.96 ``` The latest position the controller may choose. Values closer to `1.0` allow the sampler to place its second evaluation very close to the next sampling state when the local trajectory is difficult. A higher maximum therefore gives the controller more room to become strongly endpoint-focused in difficult regions. The node allows values up to `0.99`. --- ### `adaptivity` Default: ```text 1.00 ``` Controls how strongly the adaptive controller may move away from the base stage position. ```text 0.0 -> effectively fixed stage position 0.5 -> reduced adaptation 1.0 -> normal adaptation >1.0 -> stronger response ``` --- ### `quality_bias` Available presets: ```text balanced detail smooth stable dynamic ``` Each preset changes how the Auto controller evaluates and reacts to local flow behavior. The presets do not change the model or prompt. They only change the numerical controller. --- ### `turbo_mode` Available values: ```text false true ``` Turbo mode is intended for low-step workflows such as Turbo LoRAs running at approximately 6–10 steps. It keeps the selected preset but changes the controller's operating regime. Turbo mode: - shortens the calibration period - reacts more quickly to new measurements - biases internal evaluations somewhat later - increases stage-position responsiveness - keeps correction strengths closer to `1.0` This makes the controller more suitable for the larger intervals encountered at low step counts. --- ### `correction_granularity` Available values: ```text global per_channel ``` `global` uses one correction strength for the entire latent tensor. `per_channel` measures local difficulty separately for each latent channel and applies a separate correction multiplier to each channel. The internal stage position remains global. `per_channel` is the recommended default. --- # Auto Presets ## Balanced General-purpose default. Balanced gives similar importance to: - overall flow change - directional flow change with a smaller contribution from changes in flow magnitude. It uses moderate controller responsiveness and a moderate correction range. Recommended when there is no specific reason to prefer another preset. Typical use: - general generation - realism - mixed motion and detail - normal starting point --- ## Detail More responsive to local flow differences. Detail gives slightly more weight to the residual change between the first and second model evaluations. It reacts more strongly when the sampled flow differs from the local prediction. Compared with Balanced, it: - moves the stage position more strongly - reacts faster - allows slightly stronger correction in easy regions Useful for: - faces - fine texture - small objects - detailed environments - crisp spatial structure --- ## Smooth Designed for slower and more stable controller changes. Smooth gives somewhat more importance to changes in flow direction but reacts to them more gradually. It also uses a narrower correction range. Useful for: - temporal consistency - smooth camera movement - reducing texture instability - slower cinematic shots - scenes where consistency is more important than aggressive detail recovery --- ## Stable The most conservative preset. Stable reacts less strongly to isolated changes and gives more importance to persistent trajectory trends. It keeps both stage-position changes and correction-strength changes relatively small. Useful for: - difficult geometry - complex subjects - consistency-sensitive scenes - cases where more aggressive presets occasionally become unstable --- ## Dynamic The most motion-sensitive preset. Dynamic gives the highest weight to changes in the direction of the flow field. It also uses the strongest stage-position response of the Auto presets. Useful for: - action - fast subject motion - strong camera movement - changing viewpoints - complex motion trajectories Dynamic does not directly increase motion. It makes the sampler react more strongly when the model's local flow direction is changing. --- # Turbo Mode Turbo mode works together with every Auto preset. Examples: ```text balanced + turbo detail + turbo smooth + turbo stable + turbo dynamic + turbo ``` Turbo mode is not a separate visual preset. It changes how quickly the controller adapts when only a small number of large sampling intervals are available. Normal mode uses a longer initial calibration period. Turbo mode uses: ```text first interval -> calibration next interval -> partial adaptive control remaining intervals -> full adaptive control ``` It also narrows the adaptive correction range while allowing stronger stage-position changes. The basic idea is to rely more heavily on **where the second model evaluation is placed** and less on large correction-strength changes. For an 8-step Turbo-LoRA workflow, a good starting point is: ```text quality_bias = balanced turbo_mode = true correction_granularity = per_channel ``` --- # How Auto Self-Calibration Works ChebyFlow measures three properties of the local flow field between the first and second evaluation. ## Residual change Measures the relative difference between the two local flow estimates. This is a general measure of local numerical difficulty. ## Angular change Measures how strongly the flow direction changes. A larger value means the local trajectory is turning more strongly. ## Magnitude change Measures how strongly the magnitude of the flow increases or decreases. The Auto sampler maintains internal running statistics for these values. It uses: - a slower baseline - a faster recent estimate - a running deviation estimate This allows the sampler to judge each interval relative to the current generation instead of relying on fixed absolute thresholds. The resulting normalized difficulty controls: ```text global difficulty -> next internal stage position global/per-channel difficulty -> correction strength ``` Harder intervals generally use: ```text later internal evaluation + more conservative correction ``` Easier intervals can use: ```text earlier internal evaluation + slightly stronger correction ``` The calibration uses the same two model evaluations already required by the sampler. --- # ChebyFlow Advanced Sampler Advanced exposes the controller parameters directly. Default configuration: ```text coordinate = flow_lambda base_stage_position = 0.70 min_stage_position = 0.55 max_stage_position = 0.95 adapt_strength = 1.00 curvature_smoothing = 0.50 stage_curvature_scale = 0.12 curvature_metric = combined residual_weight = 1.00 angle_weight = 1.00 magnitude_weight = 0.50 correction_mode = curvature_down correction_granularity = per_channel correction_min = 0.88 correction_max = 1.08 correction_curvature_scale = 0.12 ``` The Advanced node is intended for users who want direct control over the adaptive behavior. --- # Advanced Parameter Reference ## `coordinate` ```text flow_lambda sigma ``` Controls the integration coordinate used for internal stage placement. `flow_lambda` is recommended for MiniMax H3. --- ## `base_stage_position` Neutral internal evaluation position. ```text 0.50 -> midpoint 0.70 -> moderately late 0.85 -> strongly endpoint-biased ``` Higher values generally favor a more stable, endpoint-informed trajectory, while lower values allow more freedom in how the trajectory develops. --- ## `min_stage_position` Lower bound for adaptive stage placement. Higher values keep the sampler more consistently stability-oriented. Lower values give the controller more freedom to use earlier internal evaluations. --- ## `max_stage_position` Upper bound for adaptive stage placement. Higher values allow the controller to place the second evaluation closer to the endpoint in difficult regions. --- ## `adapt_strength` Controls how strongly measured curvature changes the stage position. ```text 0.0 -> fixed stage 0.5 -> gentle adaptation 1.0 -> normal adaptation >1.0 -> stronger adaptation ``` --- ## `curvature_smoothing` Controls smoothing of the measured curvature signal. Higher values: - slower response - smoother controller behavior - less sensitivity to individual spikes Lower values: - faster response - more local variation --- ## `stage_curvature_scale` Controls how much curvature is required to strongly move the stage position. Lower values make stage adaptation more sensitive. Higher values make it more conservative. --- ## `curvature_metric` Available values: ```text rms_delta angle magnitude combined ``` ### `rms_delta` Measures relative RMS change in the local flow field. ### `angle` Measures directional change in the local flow. ### `magnitude` Measures change in flow magnitude. ### `combined` Uses all three metrics. This is the recommended Advanced default. --- ## `residual_weight` Weight of the RMS residual component when using: ```text curvature_metric = combined ``` --- ## `angle_weight` Weight of flow-direction change when using `combined`. Increasing it makes the controller more sensitive to trajectory turning. --- ## `magnitude_weight` Weight of flow-magnitude change when using `combined`. The default is lower than the residual and angle weights. --- # Correction Parameters The two-stage sampler produces: ```text x_first x_cheb ``` and the correction vector: ```text correction = x_cheb - x_first ``` The following settings control how that correction is applied. --- ## `correction_mode` Available values: ```text constant curvature_down curvature_up ``` ### `constant` Uses a fixed correction strength. ### `curvature_down` Recommended. Higher local difficulty reduces correction strength. This allows difficult regions to use a later model evaluation while applying the resulting correction more cautiously. ### `curvature_up` Higher local difficulty increases correction strength. More aggressive and mainly intended for experimentation. --- ## `correction_granularity` ```text global per_channel ``` `global` applies one correction strength to the full latent. `per_channel` adapts correction strength independently for each latent channel. --- ## `correction_min` Minimum adaptive correction strength. With `curvature_down`, difficult intervals move toward this value. Example: ```text 0.88 ``` --- ## `correction_max` Maximum adaptive correction strength. With `curvature_down`, easy intervals move toward this value. Values above `1.0` allow mild extrapolation beyond the standard Chebyshev correction. Example: ```text 1.08 ``` --- ## `correction_curvature_scale` Controls the sensitivity of the correction-strength controller. Lower values make correction strength react more strongly to measured curvature. Higher values keep it closer to the middle of the configured correction range. --- # Compatibility ChebyFlow currently targets rectified-flow / `CONST` model sampling in ComfyUI. Development and testing have focused primarily on: **MiniMax H3** Other rectified-flow models may also work, but are currently experimental.