Skip to content

Conversation

@Pfannkuchensack
Copy link
Collaborator

@Pfannkuchensack Pfannkuchensack commented Jan 13, 2026

Summary

Add DyPE (Dynamic Position Extrapolation) support to FLUX models for improved high-resolution image generation.

Features:

  • Linear UI integration with DyPE preset selector (Off / Auto / 4K) in Generation Settings
  • Metadata recall support for DyPE preset
  • NTK-aware theta scaling for position embeddings at resolutions > 1024px

Technical Details:

  • DyPE extends FLUX's RoPE position encoding using the formula: theta_scaled = theta * scale^(dim/(dim-2))
  • Auto mode activates DyPE when resolution exceeds 1536px
  • 4K preset optimized for 3840x2160 / 4096x2160 resolutions

Related Issues / Discussions

DyPE paper: Dynamic Position Extrapolation for high-resolution diffusion models

QA Instructions

  1. Select a FLUX model
  2. In Generation Settings, verify "DyPE Preset" dropdown appears
  3. Test with different presets:
    • Off: Standard generation (no scaling)
    • Auto: Generates normally at ≤1536px, applies DyPE at higher resolutions
    • 4K: Always applies 4K-optimized scaling
  4. Generate images at various resolutions (1024, 1536, 2048, 4096)
  5. Verify DyPE preset is saved in metadata and can be recalled

Merge Plan

Standard merge. Redux slice changes include new fluxDypePreset state field.

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)

claude and others added 8 commits January 2, 2026 22:18
Add detailed plan for porting ComfyUI-DyPE (Dynamic Position Extrapolation)
to InvokeAI, enabling 4K+ image generation with FLUX models without
training. Estimated effort: 5-7 developer days.
- Integrate DyPE directly into FluxDenoise (no separate node)
- Add 4K preset and "auto" mode for automatic activation
- Confirm FLUX Schnell support (same base resolution as Dev)
FLUX can handle resolutions up to ~1.5x natively without artifacts.
Set activation_threshold=1536 so DyPE only kicks in above that.
Add Dynamic Position Extrapolation (DyPE) support to FLUX models,
enabling artifact-free generation at 4K+ resolutions.

New files:
- invokeai/backend/flux/dype/base.py: DyPEConfig and scaling calculations
- invokeai/backend/flux/dype/rope.py: DyPE-enhanced RoPE functions
- invokeai/backend/flux/dype/embed.py: DyPEEmbedND position embedder
- invokeai/backend/flux/dype/presets.py: Presets (off, auto, 4k)
- invokeai/backend/flux/extensions/dype_extension.py: Pipeline integration

Modified files:
- invokeai/backend/flux/denoise.py: Add dype_extension parameter
- invokeai/app/invocations/flux_denoise.py: Add UI parameters

UI parameters:
- dype_preset: off | auto | 4k
- dype_scale: Custom magnitude override (0-8)
- dype_exponent: Custom decay speed override (0-1000)

Auto mode activates DyPE for resolutions > 1536px.

Based on: https://github.com/wildminder/ComfyUI-DyPE
Merged main to get latest changes including:
- FLUX scheduler support (heun, lcm)
- Z-Image Seed Variance Enhancer
- Canvas transform smoothing
- Various fixes and improvements

DyPE now works with both the original Euler sampler
and the new diffusers scheduler support.
Add Linear UI integration for FLUX DyPE (Dynamic Position Extrapolation):

- Add ParamFluxDypePreset component with Off/Auto/4K options
- Integrate preset selector in GenerationSettingsAccordion for FLUX models
- Add state management (paramsSlice, types) for fluxDypePreset
- Add dype_preset to FLUX denoise graph builder and metadata
- Add translations for DyPE preset label and popover
- Add zFluxDypePresetField schema definition

Fix DyPE frequency computation:
- Remove incorrect mscale multiplication on frequencies
- Use only NTK-aware theta scaling for position extrapolation
- Add FluxDypePreset handler to ImageMetadataHandlers
- Parse dype_preset from metadata and dispatch setFluxDypePreset on recall
- Add translation key metadata.dypePreset
Remove internal planning document from the branch.
@github-actions github-actions bot added python PRs that change python files invocations PRs that change invocations backend PRs that change backend files frontend PRs that change frontend files python-tests PRs that change python tests docs PRs that change docs labels Jan 13, 2026
activation_threshold: int = 1536,
) -> DyPEConfig | None:
"""Automatically determine DyPE config based on target resolution.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you experimented with looking at the area of the desired image and comparing to the base area instead of a pure dimensional comparison? Curious if this yields better results for something like 1152x1440 images.

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 docs PRs that change docs frontend PRs that change frontend files invocations PRs that change invocations python PRs that change python files python-tests PRs that change python tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants