ComfyUI/comfy/k_diffusion
PR Author 983d6a1566 Support bounded feedback loops in the DAG execution engine
Allow sampler nodes' internal iteration variables (e.g. step_index)
to flow back upstream through ComfyMathExpression nodes to control
per-step parameters (cfg, s_noise, eta, r) without triggering a
dependency cycle error.

Architecture: Two-level cycle handling
- Static validation: _is_bounded_feedback_cycle() allows cycles
  where any node declares BOUNDED_FEEDBACK
- Graph building: _is_feedback_output() skips strong links for
  declared feedback sockets, records them in feedback_links

Multi-hop chain walking via _build_feedback_fns() resolves
expression->CFGGuider/Sampler chains with simple_eval + MATH_FUNCTIONS,
composing per-step fn(step, total_steps) callables.

Sampler functions now re-read s_noise/eta/r each iteration via
_init_dynamic_options() / _refresh_dynamic_params() / _apply_dynamic_s_noise().
KSAMPLER.sample() conditionally injects mutable extra_options ref.

Safety: _dynamic_sampler_options popped at function top before model() calls.
One-line opt-in: BOUNDED_FEEDBACK = {'step_index'} on any node.
2026-06-19 18:56:13 +08:00
..
deis.py Lint all unused variables (#5989) 2024-12-12 17:59:16 -05:00
sa_solver.py Add SA-Solver sampler (#8834) 2025-07-08 16:17:06 -04:00
sampling.py Support bounded feedback loops in the DAG execution engine 2026-06-19 18:56:13 +08:00
utils.py Remove useless code. 2023-06-13 02:40:58 -04:00