Skip to content

Smart cfg#11

Merged
Aatricks merged 2 commits intomainfrom
Smart-CFG
Nov 1, 2025
Merged

Smart cfg#11
Aatricks merged 2 commits intomainfrom
Smart-CFG

Conversation

@Aatricks
Copy link
Copy Markdown
Owner

@Aatricks Aatricks commented Nov 1, 2025

This pull request adds comprehensive documentation for several advanced performance and quality optimizations in the LightDiffusion-Next project. It introduces new guides for CFG-Free Sampling, Token Merging (ToMe), and advanced Classifier-Free Guidance (CFG) techniques, and updates the documentation navigation to include these new resources. These changes help users understand, configure, and troubleshoot cutting-edge optimizations for image generation.

New Optimization Documentation

Classifier-Free Guidance (CFG) Techniques

  • Added advanced-cfg-optimizations.md detailing three advanced CFG optimizations: Batched CFG Computation (speed), Dynamic CFG Rescaling (quality), and Adaptive Noise Scheduling (quality & speed). Each section includes explanations, configuration examples, usage scenarios, troubleshooting, and credits.

CFG-Free Sampling

  • Introduced cfg-free-sampling.md explaining CFG-Free Sampling, which gradually reduces guidance strength during late denoising steps to improve photorealism and detail. The guide covers theoretical background, configuration, usage via UI/API/Python, quality analysis, troubleshooting, and implementation details.

Token Merging (ToMe)

  • Added tome.md describing Token Merging, a performance optimization that speeds up attention computation by merging similar tokens. The document includes configuration advice, usage instructions, troubleshooting, technical implementation, algorithm details, and compatibility notes.

Documentation Navigation Update

mkdocs Navigation

  • Updated mkdocs.yml to add the new guides (cfg-free-sampling.md, tome.md, and advanced-cfg-optimizations.md) under the "Performance Optimizations" section, improving discoverability and organization of advanced optimization topics.

… Token Merging (ToMe) support

- Add documentation pages for CFG-Free sampling and Token Merging (docs/cfg-free-sampling.md, docs/tome.md) and register in mkdocs.yml
- Implement CFG-Free scheduling: CFG.CFGGuider supports cfg-free params, sigmas tracking and dynamic CFG reduction; sampling APIs and KSampler propagate cfg_free_enabled / cfg_free_start_percent
- Add Token Merging (ToMe) integration: ModelPatcher imports tomesd, provides apply_tome/remove_tome and named_modules compatibility for tomesd
- Wire pipeline/server/UI: accept cfg-free and tome parameters (settings, pages, generation, server, pipeline) and propagate to sampling/model patching; apply and remove ToMe around generation paths
- Update defaults and settings to expose CFG-Free and ToMe options in the UI
- Minor import/order cleanup and logging/console messages for activation/failure cases
…ons (batched CFG, dynamic rescaling, adaptive noise)

- Add docs/advanced-cfg-optimizations.md describing batched CFG, dynamic CFG rescaling, and adaptive noise scheduling.
- Extend CFGGuider with dynamic rescaling and adaptive noise scheduling:
  - implement _apply_dynamic_cfg_rescaling and _calculate_complexity_metric
  - integrate dynamic rescaling into cfg_function and sampling flow
  - collect complexity metrics and adjust sigma schedule
- Expose new options across sampling API: batched_cfg, dynamic_cfg_rescaling, dynamic_cfg_method, dynamic_cfg_percentile, dynamic_cfg_target_scale, adaptive_noise_enabled, adaptive_noise_method.
- Thread options through sample/sample1/common_ksampler/KSampler and model_options; default batched_cfg=True.
- Surface controls and defaults in UI: ui/pages, ui/generation and ui/settings; accept params in server GenerateRequest and user pipeline.
- Add logging/debug messages and clamp bounds for stability.
@Aatricks Aatricks self-assigned this Nov 1, 2025
@Aatricks Aatricks merged commit 17c96dd into main Nov 1, 2025
1 check failed
@Aatricks Aatricks deleted the Smart-CFG branch November 1, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant