Nodes/ComfyUI_DyPE/DyPE Patch (rope extrapolation)
ComfyUI Node

DyPE Patch (rope extrapolation)

Stop Flux from drawing two of everything at 4K

By smthemex·Created about a year ago·Updated 6 days ago· 32
DyPE Patch (rope extrapolation)
  • model
  • model
◄methodyarn►
◄dypetrue►
◄base_resolution0►
◄lambda_t2.0►
◄mscaletrue►
◄verbosefalse►

If you've tried to generate a Flux image at 2048×2048 and got a second, smaller person growing out of the first one's shoulder, you've met the problem this node exists for. DyPEPatch doesn't improve the model - it replaces one table inside it, the rotary position embedding, with a version that keeps making sense past the resolution the model was trained at.

That's it. Weights, VAE, text encoders and sampler stay stock, and you plug it in between your model loader and whatever samples.

Why you'd reach for it

Every DiT-based image model has a hard-ish native window: Flux 1 at 1024², Qwen-Image at 1328², Z-Image around 1MP with artifacts creeping in past ~2MP. Above that you get composition collapse, repeated limbs, detail that looks like a texture swatch rather than a subject. The usual answer is generate small and upscale - genuinely fine, but it's a second model doing the work.

DyPE is the other lane: fix the mechanism that breaks so the native model can just run at 4K. When it landed in November 2025 there was a burst of excitement, and the top-voted reply in the big r/comfyui thread was, roughly, "coherence matters more than resolution, upscaling is easy." Both halves are worth holding onto. The position fix is real; the model's imagination about fine detail is not improved one bit.

How it works, minus the hand-waving

A transformer needs to know where each patch of the image sits. It encodes that with sinusoids at a set of frequencies (RoPE), tuned for the patch count of a 1024² image - for Flux, 64 tokens per axis, since the latent is 1/8 scale and the patch is 2, so 16 pixels per token.

Run a 2048² image and the axis spans 128 tokens, twice what the table was built for, so every position past 64 is out of distribution. DyPE re-mixes the frequency bands YaRN-style - high frequencies scaled linearly, low ones NTK theta-scaled, a ramp blending between them - then does the clever part: widens the mixing bands by kappa = t^lambda, where t is the normalised timestep (1 = pure noise). Early noisy steps get aggressive extrapolation; as the image resolves, the rope slides back toward normal. That's the "dynamic" in the name.

Inside the training window the node takes Comfy's own rope path, so at or below base resolution the output is bit-identical to stock. No penalty for leaving it installed everywhere.

The inputs that matter

Wire model from any stock loader - Load Diffusion Model, a GGUF loader, whatever - and take the model output into your sampler.

The only knob you'll actually touch is base_resolution. Leave it at 0 and it auto-detects per family (Flux 1024, Qwen 1328, Z-Image 1024); set it manually only if you're running a fine-tune trained at something unusual.

method is your A/B switch: yarn is the paper, ntk is a cheaper variant, base gives you stock Comfy rope. Wire it once, then flip to base and back at the same seed instead of trusting someone's before/after screenshots.

Leave dype, lambda_t and mscale alone - dype off is plain static YaRN, lambda_t is the paper's 2.0 exponent, mscale is the magnitude correction. Do turn verbose on once: it prints the detected family, theta, axes and base pixels-to-patches, the fastest way to confirm the node is patching rather than silently doing nothing.

Where people get burned

DyPE fixes position extrapolation only. The flow-matching shift is also resolution dependent, and it lives elsewhere in the graph. Patch with DyPEPatch, sample with a vanilla KSampler at default shift, and you get a half-corrected result that makes the whole thing look like snake oil.

Either use the companion DyPESampler, which reads shift off the latent, or for Flux keep stock ModelSamplingFlux and make sure its width/height match your actual latent size.

Installing it

ComfyUI Manager, search ComfyUI_DyPE, or:

cd ComfyUI/custom_nodes
git clone https://github.com/smthemex/ComfyUI_DyPE

Restart ComfyUI. No model downloads, no API key. The pyproject.toml lists diffusers, transformers and peft, but the shipped code imports none of them - it's native Comfy and needs only torch and numpy, with the old diffusers pipelines unused. There's no requirements.txt, so a clone install installs nothing extra.

You do need a recent ComfyUI: the pack uses the V3 node API (from comfy_api.latest import ComfyExtension, io), which landed mid-2026. On an old build the nodes won't appear at all.

Common issues

Nodes missing after restart. Almost always a ComfyUI too old for comfy_api.latest. Update first, then check the console for import errors.

unsupported model family at queue time. Deliberate: Flux 2 and Flux 3 have a different rope (patch size 1, four axes) and Klein needs diffusers-only weights. Supported: Flux 1 and derivatives, Qwen-Image, Z-Image / Lumina2.

Identical output with the node in or out. You're at or below base_resolution (extrapolation only starts above it), or method is base.

OOM at 2048². That's the resolution budget, not the patch - the example workflow ships a tiled VAE decode (VAEDecodeTiled, 512 tiles) for exactly this. Keep dimensions on multiples of 16.

CategoryDyPE

Inputs (7)

NameTypeDefaultDescription
modelMODEL—
methodCOMBOyarnyarn = DyPE paper (YaRN bands, recommended) / ntk = NTK-aware theta scaling / base = stock comfy rope (A/B switch)
dypeBOOLEANtruekappa = t^lambda timestep modulation. False = plain static YaRN.
base_resolutionINT00–8192Training resolution in pixels (0 = auto: flux 1024, qwen 1328, z-image 1024). Extrapolation starts above this.
lambda_tFLOAT2.00–8DyPE exponent lambda (paper: 2.0)
mscaleBOOLEANtrueYaRN magnitude scaling 0.1*ln(scale)+1 on cos/sin
verboseBOOLEANfalse—

Outputs (1)

NameTypeDescription
modelMODEL—