ComfyUI Node

DyPE for Qwen Image

Generate Qwen Image at 4K natively instead of praying the sampler holds together

By ttulttul·Created 10 months ago·Updated 7 months ago· 62
DyPE for Qwen Image
  • model
  • model
width1024
height1024
auto_detecttrue
base_width1024
base_height1024
methodyarn
enable_dypetrue
dype_exponent2.0
base_shift1.15
max_shift1.35
editing_strength1.00
editing_modeadaptive

Qwen Image is a flow-matching model, and like every model in that family it was trained on a fixed resolution map - roughly 1024×1024. Push past that and the model leaves its map, starts extrapolating positions it never saw in training, and you get the classic tell: repeated clones of the same object marching across the frame, or a wash of mush. The usual answer is to generate at native res and upscale. DyPE for Qwen Image is the alternative: patch the model so it can natively generate at 2K/4K.

DyPE is Dynamic Position Extrapolation, a trick borrowed straight from LLM context-extension (the YaRN/NTK family). The idea is that you don't need the model to understand the whole 4K canvas from step one. Early in sampling, keep the position coordinates pinned close to the native training size so composition locks in on solid ground. Then, as sampling progresses, exponentially ramp the grid outward. The model "sees" the full canvas exactly when it's painting high-frequency detail, instead of being forced off-map the entire time.

Where it sits in a workflow. This is a model patcher - category model_patches/unet - so it slots in exactly like ModelSamplingAuraFlow or a LoRA loader: model in, patched model out, wire that into your KSampler. It replaces the "generate small, then upscale" route with "generate big, directly." Both are legitimate; DyPE gives you true native-resolution composition rather than hallucinated detail on top of an upscaled base. This is the same approach the "4K with Flux DyPE nodes" tutorials in the community lean on, and it's the more detail-native of the two roads.

Inputs that matter:

  • model - your Qwen Image model (any checkpoint, since this patches the architecture).
  • width / height - the target render size. Must match your latent; this isn't an auto-resizer.
  • auto_detect - on by default, and it's good: it pulls patch size and base resolution off the model. If detection fails, base_width/base_height (default 1024) are the fallback.
  • method - yarn (default), ntk, or base. YaRN is the recommended default for images; it handles frequency bands separately and keeps texture. If your output looks jagged or over-sharpened, switch to ntk, which scales uniformly and reads smoother. base turns extrapolation off entirely - good for testing whether DyPE is what changed your output.
  • enable_dype - master toggle. dype_exponent (default 2.0) controls how aggressively the ramp happens; higher keeps the model closer to base resolution longer.
  • base_shift / max_shift - noise-schedule shifts (1.15 → 1.35 by default). This is the flow-model equivalent of the shift knob: it redistributes sampling effort between composition and detail as resolution grows.

If you're doing img2img or inpainting rather than text-to-image, lower editing_strength (1.0 default) to preserve the original structure - that's its entire job - and editing_mode (default adaptive) picks the tapering strategy.

Output. A single model, patched and ready for the KSampler. That's the whole thing: it returns a MODEL, not an image.

Install. Ships in ttulttul/ComfyUI-FlowMatching-Upscaler, alongside the pack's progressive upscaler. ComfyUI Manager, search "ComfyUI-FlowMatching-Upscaler", install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/ttulttul/ComfyUI-FlowMatching-Upscaler

Dependencies are numpy, torch, einops, aiohttp - nothing exotic, no model downloads. Restart ComfyUI and it appears under model_patches/unet.

Gotchas. Width/height not matching your latent is the classic silent failure - the patch runs, the sampler runs, and the output is subtly off because the model was told 2048 while the latent was 1536. Also remember this is for Qwen Image: the Flux2 variant is a separate node with different defaults because Flux2 uses a 4-axis position scheme. And a 4K Qwen pass is a VRAM event; if you're on 8GB, generate at 2K or use the upscaler instead. Start with the defaults, try method=yarn, and only touch shifts once you've seen what the base settings do.

Categorymodel_patches/unet

Inputs (13)

NameTypeDefaultDescription
modelMODELQwen Image model to patch with DyPE.
widthINT102416–16384Target output width in pixels.
heightINT102416–16384Target output height in pixels.
auto_detectBOOLEANtrueAutomatically derive patch size and base resolution from the model when possible.
base_widthINT102416–16384Training width used by the base Qwen model when auto detection fails.
base_heightINT102416–16384Training height used by the base Qwen model when auto detection fails.
methodCOMBOyarnSpatial RoPE extrapolation strategy.
enable_dypeBOOLEANtrueEnable Dynamic Position Extrapolation scaling.
dype_exponentFLOAT2.00–4Controls how strongly DyPE ramps across sampling timesteps.
base_shiftFLOAT1.150–10Baseline shift applied to the flow-matching noise schedule.
max_shiftFLOAT1.350–10Maximum shift applied when operating at the target resolution.
editing_strengthFLOAT1.000–1Scale DyPE while editing images (1.0 = full strength, 0.0 = disable DyPE scaling in edits).
editing_modeCOMBOadaptiveStrategy for tapering DyPE during edits.

Outputs (1)

NameTypeDescription
modelMODEL