File size: 16,452 Bytes
3595a38 ba4d215 3595a38 ba4d215 3595a38 ba4d215 3595a38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 | # 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. |