comfyUI-JigSaw-Hi-Res
A ComfyUI node extending Flux/Krea2 model image generation beyond native resolution using YaRN and NTK-aware frequency scaling to prevent repeating-pattern artifacts. (Description by CC)
🧩 Jigsaw Hi-Res
Generate beyond your model's native resolution — without the repeating-pattern artifacts.
A ComfyUI node that patches a Flux/Krea2-family model's rotary positional embedder (RoPE) with YaRN and NTK-aware frequency scaling, the same technique used to extend context length in LLMs — applied here to 2D image positions instead of 1D token sequences.
The problem
Flux/Krea2-style diffusion transformers encode spatial position with RoPE, tuned for a specific training resolution (commonly ~1024×1024). Ask for a significantly larger image and the position embeddings extrapolate past what the model has ever seen — the usual symptom is duplicated limbs/faces, tiled repetition, or a hazy "gray veil" wash over the image.
What Jigsaw Hi-Res does
At apply time, it:
- Reads your target resolution (explicit
width/height, or auto-detected from a connectedlatent). - Computes an adaptive YaRN ratio from how far the target resolution sits above the ~1024px reference (blending a linear and an area-based ratio, softly capped at 1.25× to keep contrast stable at extreme resolutions/aspect ratios — this cap is what keeps the classic "gray veil" oversaturation from creeping in on the more aggressive high-res attempts).
- Swaps the model's
pe_embedderfor a custom RoPE implementation that reproducescomfy.ldm.flux.math.rope()'s exact output format ([..., N, dim/2, 2, 2]rotation matrices), but computes each frequency band's scaling individually — near-DC frequencies stay untouched (extrapolated), high frequencies get interpolated/compressed, following the standard YaRN "NTK-by-parts" ramp (beta_fast/beta_slowcutoffs). - Does all of this without retraining or fine-tuning — it's a pure inference-time patch on the position embedder.
Installation
Drop the folder into ComfyUI/custom_nodes/, restart ComfyUI. The node
appears under Jigsaw/Patches → 🧩 Jigsaw Hi-Res.
Usage
Connect your MODEL in, plug a LATENT in (optional — auto-detects the
real target resolution from it) or set width/height explicitly, and
sample as usual at your target resolution.
Parameters
| Parameter | Default | Description |
|---|---|---|
| width / height | 1024 / 1024 | Target resolution. Overridden automatically if latent is connected. |
| method | yarn | yarn — per-frequency-band interpolation (recommended, best quality at large upscales). ntk — single global frequency-base rescale (cheaper, less precise). base — disables scaling entirely (pass-through RoPE). |
| rope_percentage | 1.0 | Blend factor for how much of the computed scaling to actually apply (1.0 = full effect). |
| dype_enabled | True | Master switch for the whole dynamic scaling path. Off = falls back to the model's original, untouched RoPE. |
| max_pe_length | 64 | (currently reserved — not yet wired into the scaling math) |
| latent (optional) | — | If connected, its shape is used to auto-derive the true target width/height (×8 VAE factor) instead of the manual width/height inputs. |
Compatibility
Requires a model whose diffusion backbone exposes a pe_embedder module
with .theta and .axes_dim attributes, and whose native RoPE kernel
consumes the same [..., dim/2, 2, 2] rotation-matrix format as
comfy.ldm.flux.math.rope() (Flux.1 and Krea2/Flux.2-Klein-family models).
Models using a different RoPE convention are not supported and will raise a
clear error on load rather than silently producing garbage.
Credits
By Jigsaw & Zeus — zeus.onl