ComfyUI Extension: ComfyUI-DyPE
DyPE for FLUX. Artifact-free 4K+ image generation.
Custom Nodes (0)
README
About The Project
DyPE is a training-free method that allows pre-trained DiT models to generate images at resolutions far beyond their training data, with no additional sampling cost.
It works by taking advantage of the spectral progression inherent to the diffusion process. By dynamically adjusting the model's positional encodings at each step, DyPE matches their frequency spectrum with the current stage of the generative processβfocusing on low-frequency structures early on and resolving high-frequency details in later steps. This prevents the repeating artifacts and structural degradation typically seen when pushing models beyond their native resolution.
<div align="center"> <img alt="ComfyUI-DyPE example workflow" width="70%" src="https://github.com/user-attachments/assets/31f5d254-68a7-435b-8e1f-c4e636d4f3c2" /> <p><sub><i>A simple, single-node integration to patch your model for high-resolution generation.</i></sub></p> </div>This node provides a seamless, "plug-and-play" integration of DyPE into your workflow.
β¨ Key Features:
- Multi-Architecture Support: Supports FLUX (Standard), Nunchaku (Quantized Flux), Qwen Image, and Z-Image (Lumina 2).
- High-Resolution Generation: Push models to 4096x4096 and beyond.
- Single-Node Integration: Simply place the
DyPE for FLUXnode after your model loader to patch the model. No complex workflow changes required. - Full Compatibility: Works seamlessly with your existing ComfyUI workflows, samplers, schedulers, and other optimization nodes.
- Fine-Grained Control: Exposes key DyPE hyperparameters, allowing you to tune the algorithm's strength and behavior for optimal results at different target resolutions.
- Zero Inference Overhead: DyPE's adjustments happen on-the-fly with negligible performance impact.
Example output
<div align="center"> <img alt="Example dype" src="https://github.com/user-attachments/assets/f85861fd-4d2f-4b57-8058-26881600b7ca" /> </div> <p align="right">(<a href="#readme-top">back to top</a>)</p>Getting Started
The easiest way to install is via ComfyUI Manager. Search for ComfyUI-DyPE and click "Install".
Alternatively, to install manually:
-
Clone the Repository:
Navigate to your
ComfyUI/custom_nodes/directory and clone this repository:git clone https://github.com/wildminder/ComfyUI-DyPE.git -
Start/Restart ComfyUI: Launch ComfyUI. No further dependency installation is required.
π οΈ Usage
Using the node is straightforward and designed for minimal workflow disruption.
- Load Your Model: Use your preferred loader (e.g.,
Load Checkpointfor Flux,Nunchaku Flux DiT Loader, orZImageloader). - Add the DyPE Node: Add the
DyPE for FLUXnode to your graph (found undermodel_patches/unet). - Connect the Model: Connect the
MODELoutput from your loader to themodelinput of the DyPE node. - Set Resolution: Set the
widthandheighton the DyPE node to match the resolution of yourEmpty Latent Image. - Connect to KSampler: Use the
MODELoutput from the DyPE node as the input for yourKSampler. - Generate! That's it. Your workflow is now DyPE-enabled.
[!NOTE] This node specifically patches the diffusion model (UNet) positional embeddings. It does not modify the CLIP or VAE models.
Node Inputs
1. Model Configuration
model_type:auto: Attempts to automatically detect the model architecture. Recommended.flux: Forces Standard Flux logic.nunchaku: Forces Nunchaku (Quantized Flux) logic.qwen: Forces Qwen Image logic.zimage: Forces Z-Image (Lumina 2) logic.
base_resolution: The native resolution the model was trained on.- Flux / Z-Image:
1024 - Qwen:
1328(Recommended setting for Qwen models)
- Flux / Z-Image:
2. Method Selection
method:vision_yarn: A novel variant designed specifically for aspect-ratio robustness. It decouples structure from texture: low frequencies (shapes) are scaled to fit your canvas aspect ratio, while high frequencies (details) are scaled uniformly. It uses a dynamic attention schedule to ensure sharpness.yarn: The standard YaRN method. Good general performance but can struggle with extreme aspect ratios.ntk: Neural Tangent Kernel scaling. Very stable but tends to be softer/blurrier at high resolutions.base: No positional interpolation (standard behavior).
Scaling Options
yarn_alt_scaling(Only affectsyarnmethod):- Anisotropic (High-Res): Scales Height and Width independently. Can cause geometric stretching if the aspect ratio differs significantly from the training data.
- Isotropic (Stable Default): Scales both dimensions based on the largest axis. .
- Note:
vision_yarnautomatically handles this balance internally, so this switch is ignored whenvision_yarnis selected.
[!TIP] Z-Image (Lumina 2) Specifics:
- Z-Image models use a very low RoPE base frequency (
theta=256).- Geometric Stretching: To prevent vertical stretching, the node automatically enforces Isotropic Scaling for Z-Image, regardless of user settings.
- Method Choice: recommend
vision_yarnorntk. Standardyarnmay produce artifacts.
3. Dynamic Control
enable_dype: Enables or disables the dynamic, time-aware component of DyPE.- Enabled (True): Both the noise schedule and RoPE will be dynamically adjusted throughout sampling. This is the full DyPE algorithm.
- Disabled (False): The node will only apply the dynamic noise schedule shift. The RoPE will use static extrapolation.
dype_scale: (Ξ»s) Controls the "magnitude" of the DyPE modulation. Default is2.0.dype_exponent: (Ξ»t) 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.
4. Advanced Noise Scheduling
base_shift/max_shift: These parameters control the Noise Schedule Shift (mu). In this implementation,max_shift(Default 1.15) acts as the target shift for any resolution larger than the base.
Changelog
v2.3.0
- Z-Image Overhaul: Fixed geometric stretching artifacts
- Method Fixes
v2.2.0
- Z-Image Support: Added experimental support for Z-Image (Lumina 2) architecture.
v2.1.0
- New Architecture Support: Added support for Qwen Image and Nunchaku (Quantized Flux) models.
- Modular Architecture: Refactored codebase into a modular adapter pattern (
src/models/) to ensure stability and easier updates for future models. - UI Updates: Added
model_typeselector for explicit model definition.
v2.0.0
- Vision-YaRN: Introduced the
vision_yarnmethod for decoupled aspect-ratio handling. - Dynamic Attention: Implemented quadratic decay schedule for
mscaleto balance sharpness and artifacts. - Start Sigma: Added
dype_start_sigmacontrol.
v1.0.0
- Initial Release: Core DyPE implementation for Standard Flux models.
- Basic Modes: Support for
yarn(Isotropic/Anisotropic) andntk.
β Important Notes & Best Practices
[!IMPORTANT] Limitations at Extreme Resolutions (4K) While DyPE significantly extends the capabilities of DiT models, generating perfectly clean 4096x4096 images is still a limitation of the base model itself. Even with DyPE, you are pushing a model trained on ~1 megapixel to generate 16 megapixels. You may still encounter minor artifacts at these extreme scales.
[!TIP] Dealing with Speckle Noise At extreme resolutions (4K+), you may notice high-frequency "speckle" noise in focused areas (e.g., hair, eyes). This is a side effect of scaling the model's attention mechanism beyond its training limits.
How to fix:
- Increase
dype_exponent: Try raising this to3.0or4.0or any other higher values.- Use LoRAs: Smoothing or "Detailer" LoRAs can help suppress high-frequency artifacts.
<p align="center">ββββββββββββββββββββββββββββββββββ</p>[!TIP] Experimentation is Required There is no single "magic setting" that works for every prompt and every resolution. To achieve the best results:
- Test different Methods: Start with
vision_yarn, but tryyarnif you encounter issues.- Adjust
dype_exponent: This is your main knob for balancing sharpness vs. artifacts.
Beyond the code, I believe in the power of community and continuous learning. I invite you to join the 'TokenDiff AI News' and 'TokenDiff Community Hub'
<table border="0" align="center" cellspacing="10" cellpadding="0"> <tr> <td align="center" valign="top"> <h4>TokenDiff AI News</h4> <a href="https://t.me/TokenDiff"> <img width="40%" alt="tokendiff-tg-qw" src="https://github.com/user-attachments/assets/e29f6b3c-52e5-4150-8088-12163a2e1e78" /> </a> <p><sub>AI for every home, creativity for every mind!</sub></p> </td> <td align="center" valign="top"> <h4>TokenDiff Community Hub</h4> <a href="https://t.me/TokenDiff_hub"> <img width="40%" alt="token_hub-tg-qr" src="https://github.com/user-attachments/assets/da544121-5f5b-4e3d-a3ef-02272535929e" /> </a> <p><sub>questions, help, and thoughtful discussion.</sub> </p> </td> </tr> </table> <p align="center">ββββββββββββββββββββββββββββββββββ</p> <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- ACKNOWLEDGMENTS -->Acknowledgments
- Noam Issachar, Guy Yariv, and the co-authors for their groundbreaking research and for open-sourcing the DyPE project.
- The ComfyUI team for creating such a powerful and extensible platform for diffusion model research and creativity.