Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

Fix DyPE high-resolution noise by simplifying NTK scaling

Summary

  • Replace complex YaRN 3-band frequency blending with direct NTK interpolation
  • Update mscale formula: 1.0 + 0.1 * log(s) / sqrt(s)
  • Add k_t calculation: dype_scale * (sigma ^ dype_exponent)
  • Interpolate ntk_factor from 1.0 (late steps) to base_ntk (early steps)
  • Make mscale timestep-dependent for smoother transitions
  • Add helper functions: find_correction_factor, find_correction_range, linear_ramp_mask
  • Update tests for new implementation

Related Issues / Discussions

Fixes noise/grain artifacts in high-resolution (2K+) image generation with DyPE enabled.

QA Instructions

  1. Generate images at 1024x1024 with DyPE auto - should behave like base model (DyPE disabled)
  2. Generate images at 2048x2048 with DyPE auto - should produce clean results without noise
  3. Generate images at 4096x4096 with DyPE auto - should scale properly without artifacts
  4. Run tests: pytest tests/backend/flux/dype/test_dype.py -v

Merge Plan

No special merge considerations. Changes are isolated to the DyPE module.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

  - Replace complex YaRN 3-band frequency blending with direct NTK interpolation
  - Update mscale formula: 1.0 + 0.1 * log(s) / sqrt(s)
  - Add k_t calculation: dype_scale * (sigma ^ dype_exponent)
  - Interpolate ntk_factor from 1.0 (late steps) to base_ntk (early steps)
  - Make mscale timestep-dependent for smoother transitions
  - Add helper functions: find_correction_factor, find_correction_range, linear_ramp_mask
  - Update tests for new implementation
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files python-tests PRs that change python tests labels Feb 6, 2026
@JPPhoto JPPhoto self-assigned this Feb 6, 2026
Copy link
Collaborator

@JPPhoto JPPhoto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's anything wrong with the code, and results are definitely sharper overall. But I'm still seeing "chroma noise" (for lack of a better word) and wider scenes are now left-biased as a result of these changes. Any insight?

@lstein lstein added the v6.12.0 Intended for 6.12.0 release label Feb 6, 2026
Pfannkuchensack and others added 5 commits February 6, 2026 17:58
   Aligns InvokeAI's DyPE implementation with ComfyUI-DyPE to fix chroma
   noise and left-biased composition on wide images.

   Key changes:
   - Skip DyPE scaling on axis 0 (time/channel), only scale spatial axes
   - Implement YaRN 3-band frequency blending (base/linear/NTK) with
     DyPE-modulated beta/gamma correction masks
   - Use per-axis linear_scale with global ntk_scale for non-square images
   - Fix FLUX_BASE_PE_LEN (256 -> 64) to match actual spatial positions
   - Add timestep-dependent mscale matching ComfyUI's _get_mscale
   - Use floor/ceil in find_correction_range matching reference impl
   The previous implementation used a simplified NTK-only approach that
   destroyed positional information at high resolutions. This restores
   proper YaRN 3-band blending (base/linear/NTK) with correct mask
   inversion and timestep-dependent mscale, matching ComfyUI-DyPE's
   get_1d_dype_yarn_pos_embed implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files python PRs that change python files python-tests PRs that change python tests v6.12.0 Intended for 6.12.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants