Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(ui): improve DyPE field ordering and add 'On' preset option (#8793)
Alexander Eichhorn736f4ffeb128
diff --git a/invokeai/app/invocations/flux_denoise.py b/invokeai/app/invocations/flux_denoise.pyindex 9bb0d8c133..ff002b15cf 100644--- a/invokeai/app/invocations/flux_denoise.py+++ b/invokeai/app/invocations/flux_denoise.py@@ -32,7 +32,12 @@ from invokeai.app.services.shared.invocation_context import InvocationContextfrom invokeai.backend.flux.controlnet.instantx_controlnet_flux import InstantXControlNetFluxfrom invokeai.backend.flux.controlnet.xlabs_controlnet_flux import XLabsControlNetFluxfrom invokeai.backend.flux.denoise import denoise-from invokeai.backend.flux.dype.presets import DyPEPreset, get_dype_config_from_preset+from invokeai.backend.flux.dype.presets import (+ DYPE_PRESET_LABELS,+ DYPE_PRESET_OFF,+ DyPEPreset,+ get_dype_config_from_preset,+)from invokeai.backend.flux.extensions.dype_extension import DyPEExtensionfrom invokeai.backend.flux.extensions.instantx_controlnet_extension import InstantXControlNetExtensionfrom invokeai.backend.flux.extensions.kontext_extension import KontextExtension@@ -66,7 +71,7 @@ from invokeai.backend.util.devices import TorchDevicetitle="FLUX Denoise",tags=["image", "flux"],category="image",- version="4.3.0",+ version="4.5.0",)class FluxDenoiseInvocation(BaseInvocation):"""Run denoising process with a FLUX transformer model."""@@ -170,20 +175,24 @@ class FluxDenoiseInvocation(BaseInvocation):# DyPE (Dynamic Position Extrapolation) for high-resolution generationdype_preset: DyPEPreset = InputField(- default=DyPEPreset.OFF,+ default=DYPE_PRESET_OFF,description="DyPE preset for high-resolution generation. 'auto' enables automatically for resolutions > 1536px. '4k' uses optimized settings for 4K output.",+ ui_order=100,+ ui_choice_labels=DYPE_PRESET_LABELS,)dype_scale: Optional[float] = InputField(default=None,ge=0.0,le=8.0,description="DyPE magnitude (λs). Higher values = stronger extrapolation. Only used when dype_preset is not 'off'.",+ ui_order=101,)dype_exponent: Optional[float] = InputField(default=None,ge=0.0,le=1000.0,description="DyPE decay speed (λt). Controls transition from low to high frequency detail. Only used when dype_preset is not 'off'.",+ ui_order=102,)@torch.no_grad()@@ -464,9 +473,13 @@ class FluxDenoiseInvocation(BaseInvocation):target_width=self.width,)context.logger.info(- f"DyPE enabled: {self.width}x{self.height}, preset={self.dype_preset.value}, "- f"scale={dype_config.dype_scale:.2f}, method={dype_config.method}"+ f"DyPE enabled: resolution={self.width}x{self.height}, preset={self.dype_preset}, "+ f"method={dype_config.method}, scale={dype_config.dype_scale:.2f}, "+ f"exponent={dype_config.dype_exponent:.2f}, start_sigma={dype_config.dype_start_sigma:.2f}, "+ f"base_resolution={dype_config.base_resolution}")+ else:+ context.logger.debug(f"DyPE disabled: resolution={self.width}x{self.height}, preset={self.dype_preset}")x = denoise(model=transformer,diff --git a/invokeai/backend/flux/dype/__init__.py b/invokeai/backend/flux/dype/__init__.pyindex 488144201d..9e82c27fad 100644--- a/invokeai/backend/flux/dype/__init__.py+++ b/invokeai/backend/flux/dype/__init__.py@@ -8,11 +8,24 @@ Based on: https://github.com/wildminder/ComfyUI-DyPEfrom invokeai.backend.flux.dype.base import DyPEConfigfrom invokeai.backend.flux.dype.embed import DyPEEmbedND-from invokeai.backend.flux.dype.presets import DyPEPreset, get_dype_config_for_resolution+from invokeai.backend.flux.dype.presets import (+ DYPE_PRESET_4K,+ DYPE_PRESET_AUTO,+ DYPE_PRESET_LABELS,+ DYPE_PRESET_MANUAL,+ DYPE_PRESET_OFF,+ DyPEPreset,+ get_dype_config_for_resolution,+)__all__ = ["DyPEConfig","DyPEEmbedND","DyPEPreset",+ "DYPE_PRESET_OFF",+ "DYPE_PRESET_MANUAL",+ "DYPE_PRESET_AUTO",+ "DYPE_PRESET_4K",+ "DYPE_PRESET_LABELS","get_dype_config_for_resolution",]diff --git a/invokeai/backend/flux/dype/base.py b/invokeai/backend/flux/dype/base.pyindex 53f072efc7..7b25a7f71f 100644--- a/invokeai/backend/flux/dype/base.py+++ b/invokeai/backend/flux/dype/base.py@@ -99,13 +99,17 @@ def compute_vision_yarn_freqs(The NTK-aware approach smoothly interpolates frequencies to cover largerposition ranges without breaking the attention patterns.+ DyPE (Dynamic Position Extrapolation) modulates the NTK scaling based on+ the current timestep - stronger extrapolation in early steps (global structure),+ weaker in late steps (fine details).+Args:pos: Position tensordim: Embedding dimensiontheta: RoPE base frequencyscale_h: Height scaling factorscale_w: Width scaling factor- current_sigma: Current noise level (reserved for future timestep-aware scaling)+ current_sigma: Current noise level (1.0 = full noise, 0.0 = clean)dype_config: DyPE configurationReturns:@@ -124,7 +128,24 @@ def compute_vision_yarn_freqs(# This increases the wavelength of position encodings proportionallyif scale > 1.0:ntk_alpha = scale ** (dim / (dim - 2))- scaled_theta = theta * ntk_alpha++ # Apply timestep-dependent DyPE modulation+ # mscale controls how strongly we apply the NTK extrapolation+ # Early steps (high sigma): stronger extrapolation for global structure+ # Late steps (low sigma): weaker extrapolation for fine details+ mscale = get_timestep_mscale(+ scale=scale,+ current_sigma=current_sigma,+ dype_scale=dype_config.dype_scale,+ dype_exponent=dype_config.dype_exponent,+ dype_start_sigma=dype_config.dype_start_sigma,+ )++ # Modulate NTK alpha by mscale+ # When mscale > 1: interpolate towards stronger extrapolation+ # When mscale = 1: use base NTK alpha+ modulated_alpha = 1.0 + (ntk_alpha - 1.0) * mscale+ scaled_theta = theta * modulated_alphaelse:scaled_theta = theta@@ -151,14 +172,15 @@ def compute_yarn_freqs() -> tuple[Tensor, Tensor]:"""Compute RoPE frequencies using YARN/NTK method.- Uses NTK-aware theta scaling for high-resolution support.+ Uses NTK-aware theta scaling for high-resolution support with+ timestep-dependent DyPE modulation.Args:pos: Position tensordim: Embedding dimensiontheta: RoPE base frequencyscale: Uniform scaling factor- current_sigma: Current noise level (reserved for future use)+ current_sigma: Current noise level (1.0 = full noise, 0.0 = clean)dype_config: DyPE configurationReturns:@@ -169,10 +191,22 @@ def compute_yarn_freqs(device = pos.devicedtype = torch.float64 if device.type != "mps" else torch.float32- # NTK-aware theta scaling+ # NTK-aware theta scaling with DyPE modulationif scale > 1.0:ntk_alpha = scale ** (dim / (dim - 2))- scaled_theta = theta * ntk_alpha++ # Apply timestep-dependent DyPE modulation+ mscale = get_timestep_mscale(+ scale=scale,+ current_sigma=current_sigma,+ dype_scale=dype_config.dype_scale,+ dype_exponent=dype_config.dype_exponent,+ dype_start_sigma=dype_config.dype_start_sigma,+ )++ # Modulate NTK alpha by mscale+ modulated_alpha = 1.0 + (ntk_alpha - 1.0) * mscale+ scaled_theta = theta * modulated_alphaelse:scaled_theta = thetadiff --git a/invokeai/backend/flux/dype/presets.py b/invokeai/backend/flux/dype/presets.pyindex 5071b51f9b..97499ae239 100644--- a/invokeai/backend/flux/dype/presets.py+++ b/invokeai/backend/flux/dype/presets.py@@ -1,17 +1,26 @@"""DyPE presets and automatic configuration."""from dataclasses import dataclass-from enum import Enum+from typing import Literalfrom invokeai.backend.flux.dype.base import DyPEConfig--class DyPEPreset(str, Enum):- """Predefined DyPE configurations."""-- OFF = "off" # DyPE disabled- AUTO = "auto" # Automatically enable based on resolution- PRESET_4K = "4k" # Optimized for 3840x2160 / 4096x2160+# DyPE preset type - using Literal for proper frontend dropdown support+DyPEPreset = Literal["off", "manual", "auto", "4k"]++# Constants for preset values+DYPE_PRESET_OFF: DyPEPreset = "off"+DYPE_PRESET_MANUAL: DyPEPreset = "manual"+DYPE_PRESET_AUTO: DyPEPreset = "auto"+DYPE_PRESET_4K: DyPEPreset = "4k"++# Human-readable labels for the UI+DYPE_PRESET_LABELS: dict[str, str] = {+ "off": "Off",+ "manual": "Manual",+ "auto": "Auto (>1536px)",+ "4k": "4K Optimized",+}@dataclass@@ -27,7 +36,7 @@ class DyPEPresetConfig:# Predefined preset configurationsDYPE_PRESETS: dict[DyPEPreset, DyPEPresetConfig] = {- DyPEPreset.PRESET_4K: DyPEPresetConfig(+ DYPE_PRESET_4K: DyPEPresetConfig(base_resolution=1024,method="vision_yarn",dype_scale=2.0,@@ -92,41 +101,39 @@ def get_dype_config_from_preset(preset: The DyPE preset to usewidth: Target image widthheight: Target image height- custom_scale: Optional custom dype_scale (overrides preset)- custom_exponent: Optional custom dype_exponent (overrides preset)+ custom_scale: Optional custom dype_scale (only used with 'manual' preset)+ custom_exponent: Optional custom dype_exponent (only used with 'manual' preset)Returns:DyPEConfig if DyPE should be enabled, None otherwise"""- if preset == DyPEPreset.OFF:- # Check if custom values are provided even with preset=OFF- if custom_scale is not None:- return DyPEConfig(- enable_dype=True,- base_resolution=1024,- method="vision_yarn",- dype_scale=custom_scale,- dype_exponent=custom_exponent if custom_exponent is not None else 2.0,- dype_start_sigma=1.0,- )+ if preset == DYPE_PRESET_OFF:return None- if preset == DyPEPreset.AUTO:- config = get_dype_config_for_resolution(+ if preset == DYPE_PRESET_MANUAL:+ # Manual mode - custom values can override defaults+ max_dim = max(width, height)+ scale = max_dim / 1024+ dynamic_dype_scale = min(2.0 * scale, 8.0)+ return DyPEConfig(+ enable_dype=True,+ base_resolution=1024,+ method="vision_yarn",+ dype_scale=custom_scale if custom_scale is not None else dynamic_dype_scale,+ dype_exponent=custom_exponent if custom_exponent is not None else 2.0,+ dype_start_sigma=1.0,+ )++ if preset == DYPE_PRESET_AUTO:+ # Auto preset - custom values are ignored+ return get_dype_config_for_resolution(width=width,height=height,base_resolution=1024,activation_threshold=1536,)- # Apply custom overrides if provided- if config is not None:- if custom_scale is not None:- config.dype_scale = custom_scale- if custom_exponent is not None:- config.dype_exponent = custom_exponent- return config-- # Use preset configuration++ # Use preset configuration (4K etc.) - custom values are ignoredpreset_config = DYPE_PRESETS.get(preset)if preset_config is None:return None@@ -135,7 +142,7 @@ def get_dype_config_from_preset(enable_dype=True,base_resolution=preset_config.base_resolution,method=preset_config.method,- dype_scale=custom_scale if custom_scale is not None else preset_config.dype_scale,- dype_exponent=custom_exponent if custom_exponent is not None else preset_config.dype_exponent,+ dype_scale=preset_config.dype_scale,+ dype_exponent=preset_config.dype_exponent,dype_start_sigma=preset_config.dype_start_sigma,)diff --git a/invokeai/frontend/web/public/locales/en.json b/invokeai/frontend/web/public/locales/en.jsonindex f819ae10ce..5327b6d825 100644--- a/invokeai/frontend/web/public/locales/en.json+++ b/invokeai/frontend/web/public/locales/en.json@@ -835,7 +835,9 @@"cfgRescaleMultiplier": "$t(parameters.cfgRescaleMultiplier)","clipSkip": "$t(parameters.clipSkip)","createdBy": "Created By",- "dypePreset": "DyPE Preset",+ "dypePreset": "$t(parameters.dypePreset)",+ "dypeScale": "$t(parameters.dypeScale)",+ "dypeExponent": "$t(parameters.dypeExponent)","generationMode": "Generation Mode","guidance": "Guidance","height": "Height",@@ -1381,6 +1383,8 @@"scaledWidth": "Scaled W","scheduler": "Scheduler","dypePreset": "DyPE",+ "dypeScale": "DyPE λs",+ "dypeExponent": "DyPE λt","seamlessXAxis": "Seamless X Axis","seamlessYAxis": "Seamless Y Axis","colorCompensation": "Color Compensation",@@ -1626,6 +1630,22 @@"Off: Standard generation. Auto: Automatically enables for images > 1536px. 4K: Optimized settings for 4K resolution output."]},+ "fluxDypeScale": {+ "heading": "DyPE Scale (λs)",+ "paragraphs": [+ "Controls the magnitude of the DyPE modulation. Higher values = stronger extrapolation.",+ "Default: 2.0. Range: 0.0-8.0."+ ]+ },+ "fluxDypeExponent": {+ "heading": "DyPE Exponent (λt)",+ "paragraphs": [+ "Controls the strength of the dynamic effect over time.",+ "2.0: Recommended for 4K+ resolutions. Aggressive schedule that transitions quickly to clean up artifacts.",+ "1.0: Good starting point for ~2K-3K resolutions.",+ "0.5: Gentler schedule for resolutions just above native (1024px)."+ ]+ },"seedVarianceEnhancer": {"heading": "Seed Variance Enhancer","paragraphs": [diff --git a/invokeai/frontend/web/src/common/components/InformationalPopover/constants.ts b/invokeai/frontend/web/src/common/components/InformationalPopover/constants.tsindex fddb7b4439..35f2ac3378 100644--- a/invokeai/frontend/web/src/common/components/InformationalPopover/constants.ts+++ b/invokeai/frontend/web/src/common/components/InformationalPopover/constants.ts@@ -4,6 +4,8 @@ import denoisingStrength from 'public/assets/images/denoising-strength.png';export type Feature =| 'clipSkip'| 'fluxDypePreset'+ | 'fluxDypeScale'+ | 'fluxDypeExponent'| 'hrf'| 'paramNegativeConditioning'| 'paramPositiveConditioning'@@ -92,6 +94,12 @@ export const POPOVER_DATA: { [key in Feature]?: PopoverData } = {fluxDypePreset: {placement: 'right',},+ fluxDypeScale: {+ placement: 'right',+ },+ fluxDypeExponent: {+ placement: 'right',+ },inpainting: {href: 'https://support.invoke.ai/support/solutions/articles/151000096702-inpainting-outpainting-and-bounding-box',},diff --git a/invokeai/frontend/web/src/features/controlLayers/store/paramsSlice.ts b/invokeai/frontend/web/src/features/controlLayers/store/paramsSlice.tsindex a1a76be51c..1f8ad18d35 100644--- a/invokeai/frontend/web/src/features/controlLayers/store/paramsSlice.ts+++ b/invokeai/frontend/web/src/features/controlLayers/store/paramsSlice.ts@@ -72,9 +72,15 @@ const slice = createSlice({setFluxScheduler: (state, action: PayloadAction<'euler' | 'heun' | 'lcm'>) => {state.fluxScheduler = action.payload;},- setFluxDypePreset: (state, action: PayloadAction<'off' | 'auto' | '4k'>) => {+ setFluxDypePreset: (state, action: PayloadAction<'off' | 'manual' | 'auto' | '4k'>) => {state.fluxDypePreset = action.payload;},+ setFluxDypeScale: (state, action: PayloadAction<number>) => {+ state.fluxDypeScale = action.payload;+ },+ setFluxDypeExponent: (state, action: PayloadAction<number>) => {+ state.fluxDypeExponent = action.payload;+ },setZImageScheduler: (state, action: PayloadAction<'euler' | 'heun' | 'lcm'>) => {state.zImageScheduler = action.payload;},@@ -488,6 +494,8 @@ export const {setScheduler,setFluxScheduler,setFluxDypePreset,+ setFluxDypeScale,+ setFluxDypeExponent,setZImageScheduler,setZImageSeedVarianceEnabled,setZImageSeedVarianceStrength,@@ -638,6 +646,8 @@ export const selectModelSupportsOptimizedDenoising = createSelector(export const selectScheduler = createParamsSelector((params) => params.scheduler);export const selectFluxScheduler = createParamsSelector((params) => params.fluxScheduler);export const selectFluxDypePreset = createParamsSelector((params) => params.fluxDypePreset);+export const selectFluxDypeScale = createParamsSelector((params) => params.fluxDypeScale);+export const selectFluxDypeExponent = createParamsSelector((params) => params.fluxDypeExponent);export const selectZImageScheduler = createParamsSelector((params) => params.zImageScheduler);export const selectZImageSeedVarianceEnabled = createParamsSelector((params) => params.zImageSeedVarianceEnabled);export const selectZImageSeedVarianceStrength = createParamsSelector((params) => params.zImageSeedVarianceStrength);diff --git a/invokeai/frontend/web/src/features/controlLayers/store/types.ts b/invokeai/frontend/web/src/features/controlLayers/store/types.tsindex 71b6a8453a..77d3eeeec4 100644--- a/invokeai/frontend/web/src/features/controlLayers/store/types.ts+++ b/invokeai/frontend/web/src/features/controlLayers/store/types.ts@@ -9,7 +9,9 @@ import {zParameterCLIPGEmbedModel,zParameterCLIPLEmbedModel,zParameterControlLoRAModel,+ zParameterFluxDypeExponent,zParameterFluxDypePreset,+ zParameterFluxDypeScale,zParameterFluxScheduler,zParameterGuidance,zParameterImageDimension,@@ -616,6 +618,8 @@ export const zParamsState = z.object({scheduler: zParameterScheduler,fluxScheduler: zParameterFluxScheduler,fluxDypePreset: zParameterFluxDypePreset,+ fluxDypeScale: zParameterFluxDypeScale,+ fluxDypeExponent: zParameterFluxDypeExponent,zImageScheduler: zParameterZImageScheduler,upscaleScheduler: zParameterScheduler,upscaleCfgScale: zParameterCFGScale,@@ -680,6 +684,8 @@ export const getInitialParamsState = (): ParamsState => ({scheduler: 'dpmpp_3m_k',fluxScheduler: 'euler',fluxDypePreset: 'off',+ fluxDypeScale: 2.0,+ fluxDypeExponent: 2.0,zImageScheduler: 'euler',upscaleScheduler: 'kdpm_2',upscaleCfgScale: 2,diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/ImageMetadataActions.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/ImageMetadataActions.tsxindex c6bab63698..8d04aad101 100644--- a/invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/ImageMetadataActions.tsx+++ b/invokeai/frontend/web/src/features/gallery/components/ImageMetadataViewer/ImageMetadataActions.tsx@@ -45,6 +45,8 @@ export const ImageMetadataActions = memo((props: Props) => {<SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.CFGRescaleMultiplier} /><SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.Guidance} /><SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.FluxDypePreset} />+ <SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.FluxDypeScale} />+ <SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.FluxDypeExponent} /><SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.DenoisingStrength} /><SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.SeamlessX} /><SingleMetadataDatum metadata={metadata} handler={ImageMetadataHandlers.SeamlessY} />diff --git a/invokeai/frontend/web/src/features/metadata/parsing.tsx b/invokeai/frontend/web/src/features/metadata/parsing.tsxindex 90eef87079..e8a152d499 100644--- a/invokeai/frontend/web/src/features/metadata/parsing.tsx+++ b/invokeai/frontend/web/src/features/metadata/parsing.tsx@@ -18,7 +18,9 @@ import {setCfgRescaleMultiplier,setCfgScale,setClipSkip,+ setFluxDypeExponent,setFluxDypePreset,+ setFluxDypeScale,setFluxScheduler,setGuidance,setImg2imgStrength,@@ -54,7 +56,9 @@ import type {ParameterCFGRescaleMultiplier,ParameterCFGScale,ParameterCLIPSkip,+ ParameterFluxDypeExponent,ParameterFluxDypePreset,+ ParameterFluxDypeScale,ParameterGuidance,ParameterHeight,ParameterModel,@@ -78,7 +82,9 @@ import {zParameterCFGRescaleMultiplier,zParameterCFGScale,zParameterCLIPSkip,+ zParameterFluxDypeExponent,zParameterFluxDypePreset,+ zParameterFluxDypeScale,zParameterGuidance,zParameterImageDimension,zParameterNegativePrompt,@@ -393,6 +399,56 @@ const FluxDypePreset: SingleMetadataHandler<ParameterFluxDypePreset> = {};//#endregion FluxDypePreset+//#region FluxDypeScale+const FluxDypeScale: SingleMetadataHandler<ParameterFluxDypeScale> = {+ [SingleMetadataKey]: true,+ type: 'FluxDypeScale',+ parse: (metadata, _store) => {+ // Only parse if preset is 'manual' (custom values)+ const preset = getProperty(metadata, 'dype_preset');+ if (preset !== 'manual') {+ throw new Error('DyPE scale only available when preset is "manual"');+ }+ const raw = getProperty(metadata, 'dype_scale');+ const parsed = zParameterFluxDypeScale.parse(raw);+ return Promise.resolve(parsed);+ },+ recall: (value, store) => {+ store.dispatch(setFluxDypeScale(value));+ },+ i18nKey: 'metadata.dypeScale',+ LabelComponent: MetadataLabel,+ ValueComponent: ({ value }: SingleMetadataValueProps<ParameterFluxDypeScale>) => (+ <MetadataPrimitiveValue value={value} />+ ),+};+//#endregion FluxDypeScale++//#region FluxDypeExponent+const FluxDypeExponent: SingleMetadataHandler<ParameterFluxDypeExponent> = {+ [SingleMetadataKey]: true,+ type: 'FluxDypeExponent',+ parse: (metadata, _store) => {+ // Only parse if preset is 'manual' (custom values)+ const preset = getProperty(metadata, 'dype_preset');+ if (preset !== 'manual') {+ throw new Error('DyPE exponent only available when preset is "manual"');+ }+ const raw = getProperty(metadata, 'dype_exponent');+ const parsed = zParameterFluxDypeExponent.parse(raw);+ return Promise.resolve(parsed);+ },+ recall: (value, store) => {+ store.dispatch(setFluxDypeExponent(value));+ },+ i18nKey: 'metadata.dypeExponent',+ LabelComponent: MetadataLabel,+ ValueComponent: ({ value }: SingleMetadataValueProps<ParameterFluxDypeExponent>) => (+ <MetadataPrimitiveValue value={value} />+ ),+};+//#endregion FluxDypeExponent+//#region Schedulerconst Scheduler: SingleMetadataHandler<ParameterScheduler> = {[SingleMetadataKey]: true,@@ -1140,6 +1196,8 @@ export const ImageMetadataHandlers = {CLIPSkip,Guidance,FluxDypePreset,+ FluxDypeScale,+ FluxDypeExponent,Width,Height,Seed,diff --git a/invokeai/frontend/web/src/features/nodes/hooks/useInputFieldNamesByStatus.ts b/invokeai/frontend/web/src/features/nodes/hooks/useInputFieldNamesByStatus.tsindex 23fc490e34..bd7f9b1e96 100644--- a/invokeai/frontend/web/src/features/nodes/hooks/useInputFieldNamesByStatus.ts+++ b/invokeai/frontend/web/src/features/nodes/hooks/useInputFieldNamesByStatus.ts@@ -1,10 +1,29 @@import { createSelector } from '@reduxjs/toolkit';import { useAppSelector } from 'app/store/storeHooks';+import { isNil } from 'es-toolkit/compat';import { useInvocationNodeContext } from 'features/nodes/components/flow/nodes/Invocation/context';import type { FieldInputTemplate } from 'features/nodes/types/field';import { isSingleOrCollection, isStatefulFieldType } from 'features/nodes/types/field';import { useMemo } from 'react';+/**+ * Sort input fields: unordered fields first (preserving original order),+ * then explicitly ordered fields sorted by ui_order ascending.+ */+const sortInputFields = (fields: FieldInputTemplate[]): string[] => {+ const visibleFields = fields.filter((field) => !field.ui_hidden);++ const unorderedFields = visibleFields.filter((f) => isNil(f.ui_order));+ const orderedFields = visibleFields+ .filter((f) => !isNil(f.ui_order))+ .sort((a, b) => (a.ui_order ?? 0) - (b.ui_order ?? 0));++ return unorderedFields+ .concat(orderedFields)+ .map((f) => f.name)+ .filter((fieldName) => fieldName !== 'is_intermediate');+};+const isConnectionInputField = (field: FieldInputTemplate) => {return (field.input === 'connection' && !isSingleOrCollection(field.type)) || !isStatefulFieldType(field.type);};@@ -34,13 +53,13 @@ export const useInputFieldNamesAnyOrDirect = () => {const selector = useMemo(() =>createSelector([ctx.selectNodeTemplateSafe], (template) => {- const fieldNames: string[] = [];- for (const [fieldName, fieldTemplate] of Object.entries(template?.inputs ?? {})) {+ const fields: FieldInputTemplate[] = [];+ for (const fieldTemplate of Object.values(template?.inputs ?? {})) {if (isAnyOrDirectInputField(fieldTemplate)) {- fieldNames.push(fieldName);+ fields.push(fieldTemplate);}}- return fieldNames;+ return sortInputFields(fields);}),[ctx]);@@ -52,13 +71,13 @@ export const useInputFieldNamesConnection = () => {const selector = useMemo(() =>createSelector([ctx.selectNodeTemplateSafe], (template) => {- const fieldNames: string[] = [];- for (const [fieldName, fieldTemplate] of Object.entries(template?.inputs ?? {})) {+ const fields: FieldInputTemplate[] = [];+ for (const fieldTemplate of Object.values(template?.inputs ?? {})) {if (isConnectionInputField(fieldTemplate)) {- fieldNames.push(fieldName);+ fields.push(fieldTemplate);}}- return fieldNames;+ return sortInputFields(fields);}),[ctx]);diff --git a/invokeai/frontend/web/src/features/nodes/types/common.ts b/invokeai/frontend/web/src/features/nodes/types/common.tsindex af91ebe1e1..25ab951ca2 100644--- a/invokeai/frontend/web/src/features/nodes/types/common.ts+++ b/invokeai/frontend/web/src/features/nodes/types/common.ts@@ -72,7 +72,13 @@ export const zFluxSchedulerField = z.enum(['euler', 'heun', 'lcm']);export const zZImageSchedulerField = z.enum(['euler', 'heun', 'lcm']);// Flux DyPE (Dynamic Position Extrapolation) preset options for high-resolution generation-export const zFluxDypePresetField = z.enum(['off', 'auto', '4k']);+export const zFluxDypePresetField = z.enum(['off', 'manual', 'auto', '4k']);++// Flux DyPE scale (magnitude λs) - 0.0-8.0, default 2.0+export const zFluxDypeScaleField = z.number().min(0).max(8);++// Flux DyPE exponent (decay speed λt) - 0.0-1000.0, default 2.0+export const zFluxDypeExponentField = z.number().min(0).max(1000);// #endregion// #region Model-related schemasdiff --git a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.tsindex c47e8d6d1c..d460167917 100644--- a/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts+++ b/invokeai/frontend/web/src/features/nodes/util/graph/generation/buildFLUXGraph.ts@@ -53,6 +53,8 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuildersteps,fluxScheduler,fluxDypePreset,+ fluxDypeScale,+ fluxDypeExponent,fluxVAE,t5EncoderModel,clipEmbedModel,@@ -193,6 +195,9 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuildernum_steps: steps,scheduler: fluxScheduler,dype_preset: fluxDypePreset,+ // Only send custom scale/exponent when DyPE is not off+ dype_scale: fluxDypeScale,+ dype_exponent: fluxDypeExponent,});posCondCollect = g.addNode({@@ -239,6 +244,8 @@ export const buildFLUXGraph = async (arg: GraphBuilderArg): Promise<GraphBuildersteps,scheduler: fluxScheduler,dype_preset: fluxDypePreset,+ dype_scale: fluxDypePreset !== 'off' ? fluxDypeScale : undefined,+ dype_exponent: fluxDypePreset !== 'off' ? fluxDypeExponent : undefined,vae: fluxVAE,t5_encoder: t5EncoderModel,clip_embed_model: clipEmbedModel,diff --git a/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeExponent.tsx b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeExponent.tsxnew file mode 100644index 0000000000..8c0cf108ed--- /dev/null+++ b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeExponent.tsx@@ -0,0 +1,58 @@+import { CompositeNumberInput, CompositeSlider, FormControl, FormLabel } from '@invoke-ai/ui-library';+import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';+import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';+import { selectFluxDypeExponent, setFluxDypeExponent } from 'features/controlLayers/store/paramsSlice';+import { memo, useCallback } from 'react';+import { useTranslation } from 'react-i18next';++// DyPE Exponent (λt) - Controls the strength of the dynamic effect over time+// 2.0: Recommended for 4K+ resolutions - aggressive schedule that transitions quickly+// 1.0: Good starting point for ~2K-3K resolutions+// 0.5: Gentler schedule for resolutions just above native+const CONSTRAINTS = {+ initial: 2.0,+ sliderMin: 0,+ sliderMax: 10,+ numberInputMin: 0,+ numberInputMax: 1000,+ fineStep: 0.1,+ coarseStep: 0.5,+};++const MARKS = [0, 0.5, 1, 2, 5, 10];++const ParamFluxDypeExponent = () => {+ const fluxDypeExponent = useAppSelector(selectFluxDypeExponent);+ const dispatch = useAppDispatch();+ const { t } = useTranslation();+ const onChange = useCallback((v: number) => dispatch(setFluxDypeExponent(v)), [dispatch]);++ return (+ <FormControl>+ <InformationalPopover feature="fluxDypeExponent">+ <FormLabel>{t('parameters.dypeExponent')}</FormLabel>+ </InformationalPopover>+ <CompositeSlider+ value={fluxDypeExponent}+ defaultValue={CONSTRAINTS.initial}+ min={CONSTRAINTS.sliderMin}+ max={CONSTRAINTS.sliderMax}+ step={CONSTRAINTS.coarseStep}+ fineStep={CONSTRAINTS.fineStep}+ onChange={onChange}+ marks={MARKS}+ />+ <CompositeNumberInput+ value={fluxDypeExponent}+ defaultValue={CONSTRAINTS.initial}+ min={CONSTRAINTS.numberInputMin}+ max={CONSTRAINTS.numberInputMax}+ step={CONSTRAINTS.coarseStep}+ fineStep={CONSTRAINTS.fineStep}+ onChange={onChange}+ />+ </FormControl>+ );+};++export default memo(ParamFluxDypeExponent);diff --git a/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypePreset.tsx b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypePreset.tsxindex e1e8c2b4c4..69f3892ce0 100644--- a/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypePreset.tsx+++ b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypePreset.tsx@@ -10,6 +10,7 @@ import { useTranslation } from 'react-i18next';// DyPE (Dynamic Position Extrapolation) preset options for high-resolution generationconst FLUX_DYPE_PRESET_OPTIONS: ComboboxOption[] = [{ value: 'off', label: 'Off' },+ { value: 'manual', label: 'Manual' },{ value: 'auto', label: 'Auto (> 1536px)' },{ value: '4k', label: '4K Optimized' },];diff --git a/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeScale.tsx b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeScale.tsxnew file mode 100644index 0000000000..5261257b42--- /dev/null+++ b/invokeai/frontend/web/src/features/parameters/components/Core/ParamFluxDypeScale.tsx@@ -0,0 +1,56 @@+import { CompositeNumberInput, CompositeSlider, FormControl, FormLabel } from '@invoke-ai/ui-library';+import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';+import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';+import { selectFluxDypeScale, setFluxDypeScale } from 'features/controlLayers/store/paramsSlice';+import { memo, useCallback } from 'react';+import { useTranslation } from 'react-i18next';++// DyPE Scale (λs) - Controls the magnitude of the DyPE modulation+// Higher values = stronger extrapolation for high-resolution generation+const CONSTRAINTS = {+ initial: 2.0,+ sliderMin: 0,+ sliderMax: 8,+ numberInputMin: 0,+ numberInputMax: 8,+ fineStep: 0.1,+ coarseStep: 0.5,+};++const MARKS = [0, 2, 4, 6, 8];++const ParamFluxDypeScale = () => {+ const fluxDypeScale = useAppSelector(selectFluxDypeScale);+ const dispatch = useAppDispatch();+ const { t } = useTranslation();+ const onChange = useCallback((v: number) => dispatch(setFluxDypeScale(v)), [dispatch]);++ return (+ <FormControl>+ <InformationalPopover feature="fluxDypeScale">+ <FormLabel>{t('parameters.dypeScale')}</FormLabel>+ </InformationalPopover>+ <CompositeSlider+ value={fluxDypeScale}+ defaultValue={CONSTRAINTS.initial}+ min={CONSTRAINTS.sliderMin}+ max={CONSTRAINTS.sliderMax}+ step={CONSTRAINTS.coarseStep}+ fineStep={CONSTRAINTS.fineStep}+ onChange={onChange}+ marks={MARKS}+ />+ <CompositeNumberInput+ value={fluxDypeScale}+ defaultValue={CONSTRAINTS.initial}+ min={CONSTRAINTS.numberInputMin}+ max={CONSTRAINTS.numberInputMax}+ step={CONSTRAINTS.coarseStep}+ fineStep={CONSTRAINTS.fineStep}+ onChange={onChange}+ />+ </FormControl>+ );+};++export default memo(ParamFluxDypeScale);diff --git a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.tsindex 6cfd4b3fa5..38808fdddc 100644--- a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts+++ b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts@@ -2,7 +2,9 @@ import { NUMPY_RAND_MAX } from 'app/constants';import { roundToMultiple } from 'common/util/roundDownToMultiple';import { buildZodTypeGuard } from 'common/util/zodUtils';import {+ zFluxDypeExponentField,zFluxDypePresetField,+ zFluxDypeScaleField,zFluxSchedulerField,zModelIdentifierField,zSchedulerField,@@ -82,6 +84,16 @@ export const [zParameterFluxDypePreset, isParameterFluxDypePreset] = buildParameexport type ParameterFluxDypePreset = z.infer<typeof zParameterFluxDypePreset>;// #endregion+// #region Flux DyPE Scale (magnitude λs)+export const [zParameterFluxDypeScale, isParameterFluxDypeScale] = buildParameter(zFluxDypeScaleField);+export type ParameterFluxDypeScale = z.infer<typeof zParameterFluxDypeScale>;+// #endregion++// #region Flux DyPE Exponent (decay speed λt)+export const [zParameterFluxDypeExponent, isParameterFluxDypeExponent] = buildParameter(zFluxDypeExponentField);+export type ParameterFluxDypeExponent = z.infer<typeof zParameterFluxDypeExponent>;+// #endregion+// #region seedexport const [zParameterSeed, isParameterSeed] = buildParameter(z.number().int().min(0).max(NUMPY_RAND_MAX));export type ParameterSeed = z.infer<typeof zParameterSeed>;diff --git a/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx b/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsxindex eb40acf912..179641cbbf 100644--- a/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx+++ b/invokeai/frontend/web/src/features/settingsAccordions/components/GenerationSettingsAccordion/GenerationSettingsAccordion.tsx@@ -5,6 +5,7 @@ import { createMemoizedSelector } from 'app/store/createMemoizedSelector';import { useAppSelector } from 'app/store/storeHooks';import { selectLoRAsSlice } from 'features/controlLayers/store/lorasSlice';import {+ selectFluxDypePreset,selectIsCogView4,selectIsFLUX,selectIsFlux2,@@ -14,7 +15,9 @@ import {import { LoRAList } from 'features/lora/components/LoRAList';import LoRASelect from 'features/lora/components/LoRASelect';import ParamCFGScale from 'features/parameters/components/Core/ParamCFGScale';+import ParamFluxDypeExponent from 'features/parameters/components/Core/ParamFluxDypeExponent';import ParamFluxDypePreset from 'features/parameters/components/Core/ParamFluxDypePreset';+import ParamFluxDypeScale from 'features/parameters/components/Core/ParamFluxDypeScale';import ParamFluxScheduler from 'features/parameters/components/Core/ParamFluxScheduler';import ParamGuidance from 'features/parameters/components/Core/ParamGuidance';import ParamScheduler from 'features/parameters/components/Core/ParamScheduler';@@ -41,6 +44,7 @@ export const GenerationSettingsAccordion = memo(() => {const isSD3 = useAppSelector(selectIsSD3);const isCogView4 = useAppSelector(selectIsCogView4);const isZImage = useAppSelector(selectIsZImage);+ const fluxDypePreset = useAppSelector(selectFluxDypePreset);const selectBadges = useMemo(() =>@@ -80,11 +84,13 @@ export const GenerationSettingsAccordion = memo(() => {<FormControlGroup formLabelProps={formLabelProps}>{!isFLUX && !isFlux2 && !isSD3 && !isCogView4 && !isZImage && <ParamScheduler />}{(isFLUX || isFlux2) && <ParamFluxScheduler />}- {isFLUX && <ParamFluxDypePreset />}{isZImage && <ParamZImageScheduler />}<ParamSteps />{(isFLUX || isFlux2) && modelConfig && !isFluxFillMainModelModelConfig(modelConfig) && <ParamGuidance />}{!isFLUX && !isFlux2 && <ParamCFGScale />}+ {isFLUX && <ParamFluxDypePreset />}+ {isFLUX && fluxDypePreset === 'manual' && <ParamFluxDypeScale />}+ {isFLUX && fluxDypePreset === 'manual' && <ParamFluxDypeExponent />}</FormControlGroup>{isZImage && <ParamZImageSeedVarianceSettings />}</Flex>diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.tsindex 5df3146489..98e43bcb72 100644--- a/invokeai/frontend/web/src/services/api/schema.ts+++ b/invokeai/frontend/web/src/services/api/schema.ts@@ -6990,12 +6990,6 @@ export type components = {*/download_path: string;};- /**- * DyPEPreset- * @description Predefined DyPE configurations.- * @enum {string}- */- DyPEPreset: "off" | "auto" | "4k";/*** Dynamic Prompt* @description Parses a prompt using adieyal/dynamicprompts' random or combinatorial generator@@ -8748,10 +8742,12 @@ export type components = {*/kontext_conditioning?: components["schemas"]["FluxKontextConditioningField"] | components["schemas"]["FluxKontextConditioningField"][] | null;/**+ * Dype Preset* @description DyPE preset for high-resolution generation. 'auto' enables automatically for resolutions > 1536px. '4k' uses optimized settings for 4K output.* @default off+ * @enum {string}*/- dype_preset?: components["schemas"]["DyPEPreset"];+ dype_preset?: "off" | "manual" | "auto" | "4k";/*** Dype Scale* @description DyPE magnitude (λs). Higher values = stronger extrapolation. Only used when dype_preset is not 'off'.@@ -8940,10 +8936,12 @@ export type components = {*/kontext_conditioning?: components["schemas"]["FluxKontextConditioningField"] | components["schemas"]["FluxKontextConditioningField"][] | null;/**+ * Dype Preset* @description DyPE preset for high-resolution generation. 'auto' enables automatically for resolutions > 1536px. '4k' uses optimized settings for 4K output.* @default off+ * @enum {string}*/- dype_preset?: components["schemas"]["DyPEPreset"];+ dype_preset?: "off" | "manual" | "auto" | "4k";/*** Dype Scale* @description DyPE magnitude (λs). Higher values = stronger extrapolation. Only used when dype_preset is not 'off'.diff --git a/tests/backend/flux/dype/test_dype.py b/tests/backend/flux/dype/test_dype.pyindex 1c027e298f..1dbcaee7ee 100644--- a/tests/backend/flux/dype/test_dype.py+++ b/tests/backend/flux/dype/test_dype.py@@ -12,8 +12,11 @@ from invokeai.backend.flux.dype.base import ()from invokeai.backend.flux.dype.embed import DyPEEmbedNDfrom invokeai.backend.flux.dype.presets import (+ DYPE_PRESET_4K,+ DYPE_PRESET_AUTO,+ DYPE_PRESET_MANUAL,+ DYPE_PRESET_OFF,DYPE_PRESETS,- DyPEPreset,get_dype_config_for_resolution,get_dype_config_from_preset,)@@ -213,7 +216,7 @@ class TestDyPEPresets:def test_preset_4k_exists(self):"""Test that 4K preset is defined."""- assert DyPEPreset.PRESET_4K in DYPE_PRESETS+ assert DYPE_PRESET_4K in DYPE_PRESETSdef test_get_dype_config_for_resolution_below_threshold(self):"""When resolution is below threshold, should return None."""@@ -264,7 +267,7 @@ class TestDyPEPresets:def test_get_dype_config_from_preset_off(self):"""Preset OFF should return None."""config = get_dype_config_from_preset(- preset=DyPEPreset.OFF,+ preset=DYPE_PRESET_OFF,width=2048,height=2048,)@@ -273,7 +276,7 @@ class TestDyPEPresets:def test_get_dype_config_from_preset_auto(self):"""Preset AUTO should use resolution-based config."""config = get_dype_config_from_preset(- preset=DyPEPreset.AUTO,+ preset=DYPE_PRESET_AUTO,width=2048,height=2048,)@@ -283,19 +286,19 @@ class TestDyPEPresets:def test_get_dype_config_from_preset_4k(self):"""Preset 4K should use 4K settings."""config = get_dype_config_from_preset(- preset=DyPEPreset.PRESET_4K,+ preset=DYPE_PRESET_4K,width=3840,height=2160,)assert config is not Noneassert config.enable_dype is True- def test_get_dype_config_from_preset_custom_overrides(self):- """Custom scale/exponent should override preset values."""+ def test_get_dype_config_from_preset_manual_custom_overrides(self):+ """Custom scale/exponent should override defaults only with 'manual' preset."""config = get_dype_config_from_preset(- preset=DyPEPreset.PRESET_4K,- width=3840,- height=2160,+ preset=DYPE_PRESET_MANUAL,+ width=2048,+ height=2048,custom_scale=5.0,custom_exponent=10.0,)@@ -303,6 +306,20 @@ class TestDyPEPresets:assert config.dype_scale == 5.0assert config.dype_exponent == 10.0+ def test_get_dype_config_from_preset_4k_ignores_custom(self):+ """4K preset should ignore custom scale/exponent values."""+ config = get_dype_config_from_preset(+ preset=DYPE_PRESET_4K,+ width=3840,+ height=2160,+ custom_scale=5.0,+ custom_exponent=10.0,+ )+ assert config is not None+ # Custom values should be ignored - preset values used instead+ assert config.dype_scale == 2.0 # 4K preset default+ assert config.dype_exponent == 2.0 # 4K preset default+class TestFrequencyComputation:"""Tests for frequency computation functions."""