Skip to content

Fix DyPE high-resolution noise by simplifying NTK scaling#8847

Open
Pfannkuchensack wants to merge 16 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/dype-ntk-scaling
Open

Fix DyPE high-resolution noise by simplifying NTK scaling#8847
Pfannkuchensack wants to merge 16 commits intoinvoke-ai:mainfrom
Pfannkuchensack:fix/dype-ntk-scaling

Conversation

@Pfannkuchensack
Copy link
Copy Markdown
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
Copy Markdown
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 6 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.
@JPPhoto
Copy link
Copy Markdown
Collaborator

JPPhoto commented Feb 21, 2026

@lstein Recommend retargeting for 6.13.x since this needs more of @Pfannkuchensack's time.

@lstein lstein added v6.13.x and removed v6.12.0 Intended for 6.12.0 release labels Feb 24, 2026
@lstein
Copy link
Copy Markdown
Collaborator

lstein commented Feb 24, 2026

@lstein Recommend retargeting for 6.13.x since this needs more of @Pfannkuchensack's time.

Done.

JPPhoto and others added 5 commits February 24, 2026 12:33
- Cap FLUX noise schedule shift (mu) at base resolution when DyPE is
  active. Previously mu extrapolated
  linearly with resolution (e.g. mu=3.39 at 2496x1776 vs correct 1.15),
  causing the model to spend nearly all denoising at high noise levels,
  producing "crumpled paper" texture artifacts.
@Pfannkuchensack Pfannkuchensack requested a review from JPPhoto March 15, 2026 05:32
@github-actions github-actions bot added the invocations PRs that change invocations label Mar 15, 2026
@JPPhoto
Copy link
Copy Markdown
Collaborator

JPPhoto commented Mar 29, 2026

I recommend we abandon this and switch to #8980 to re-align DyPE implementation more closely with the original paper and accept the loss of high-frequency detail.

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 invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

3 participants