AReA
AReA rewrites FLUX's attention mid-run so 4K stops turning into wallpaper
- model
- Patched Model
The problem AReA is aiming at
FLUX was trained at 1024×1024 and is comfortable to roughly 2 megapixels. Z-Image isn't much different - 1MP baseline, and artifacts start showing up past ~2MP. Ask either one for 4096×4096 and you get 16 megapixels out of a model that has only ever seen one. The usual answers are the ones in our upscaling essay: a low-denoise hi-res pass, or tiling. Both work, both leave fingerprints.
AReA takes the other road. It never touches your image, your sampler or your VAE - it patches the model so image self-attention behaves differently while your own KSampler denoises at the big canvas. Training-free, no upscale pass, and the most ambitious of the half-dozen high-res methods in this pack.
How it actually works
AReA swaps the backbone's attention call for a time-dependent attention graph that mirrors the shape of sampling itself.
Phase I - the leading steps - pools image keys and values down to one token per f x f block (f ramps down to 2 across the phase) and runs cross-scale attention on that coarse position grid, while the queries stay at full resolution. Keys are pooled before the position rotation, so the survivors stay in the query's frame.
Phase II - everything after the handoff - runs windowed attention. Window sizes come from the image's Haar-DWT detail map, so smooth tiles get split into quadrants and busy ones don't. Each window is widened by a Halo ring whose four sides each draw their own width in [0, halo] every step, and also attends a bridge of round(rho·w)² of the canvas's most distinctive unrotated keys, spread over an 8×8 grid so no region starves. Overlapping windows merge back with centre-weighted blending. Budgets are picked so a windowed step never costs more than plain full attention, and the schedule is built per canvas and cached.
Below the native 64-patch extent - 1024px on the longer side - it's a provable no-op: nothing gets patched.
What you set, and what comes out
Wire it in one place: loader → AReA → KSampler. The only output is Patched Model.
width/heightare the ones that bite. Default 2048×2048, multiples of 16, and they must match your empty latent - they build the schedule and drive every apply-time check.phase1_steps(default 8) is the FLUX constant from the reference paper, out of 28 steps. On Z-Image Turbo's 8-step schedule, use 1–3, or letphase1_mode: sigmado the handoff. Pooling every step of a distilled run leaves the sampler nothing to re-detail with.model_typeonautoreads the architecture off the model; the explicit options (flux,zimage,krea2,qwen21) exist in case a probe misfires.phase1_modelikewise resolves per backbone:sigmaon Z-Image and Qwen-Image 2.1, the reference'sstepsmode on FLUX and Krea-2.bootstrap(the paper's Appendix F recipe) ships but its two-sampler construction isn't validated - the README says don't use it on Turbo.
Everything else - pooling, halo 8, bridge_ratio 0.5, bridge_floor_steps 2, window_start / window_hold_steps, seed - has a sane default. pooling: auto picks a different rule per model for a real reason (mean on Z-Image and Krea-2, medoid on Qwen-Image 2.1, where a blended value behind a synthetic key reads as a doubled face). Same seed and step always build the same windows, and cond/uncond share one batched forward - both CFG branches attend identical graphs.
Installing it
The whole pack goes in at once:
cd ComfyUI/custom_nodes/
git clone https://github.com/wildminder/ComfyUI-DyPE.git
Or search ComfyUI-DyPE in ComfyUI Manager. Restart, done - requirements.txt is torch and numpy, both already on your machine, and there are no model downloads. The node lives under WMNodes/image as AReA.
Where people get burned
1024px does nothing, by design. The console says as much, once. Keep the longer side past 1024 or this node is a very expensive resistor.
Nunchaku isn't supported. Quantized/fused attention kernels bypass the seam AReA patches, so the node warns and hands your model back unchanged. If you run Nunchaku FLUX, this isn't your node.
Short schedules need tuning. phase1_steps 8 on an 8-step Turbo run pools every step; the pack caps the effective count at total_steps - 2 and logs the knob, the cap and the effective number. Read that log line before you conclude it's broken.
Odd canvases get adjusted, not refused. A grid with no usable common divisor (512×2000 and friends) gets its pooling factor resolved and a partial edge block, plus one warning. Your resolution is unchanged.
It won't rescue everything. 4K from a 1MP model is still 4K from a 1MP model. Community reports agree: odd aspect ratios go strange past 2K, and hands and faces pick up extra or missing parts. Generate a base, check it, then go big. AReA is one of the better tools for that last step, not a replacement for picking a good seed.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model to patch with AReA. FLUX, Z-Image (Lumina2), Krea-2 and Qwen-Image-2.1 share the same 16 px patch grid, so the same width/height serve any of them. | |
| width | INT | 204816–16384 | Target image width. Must match the width of your empty latent — AReA builds its schedule from this geometry and validates it against the latent at every forward. |
| height | INT | 204816–16384 | Target image height. Must match the height of your empty latent. |
| model_type | COMBO | auto | Specify the model architecture. 'auto' usually works. FLUX and Z-Image (Lumina2 / NextDiT) share a 16 px patch grid, so the same width/height serve either; Krea-2 (SingleStreamDiT) uses the same 16 px token grid (ASSUMED — its VAE downscale is unverified, so a 16x VAE would make its token 32 px) and needs no padding; Qwen-Image-2.1 (QwenImage21Transformer2DModel) uses the same 16 px token grid (MEASURED — its latent format downsamples 16x and 2.1 does not patchify) and pads nothing, and AReA switches its prefix K/V cache off on its own clone (the cached path is indistinguishable from the image segment, so with the cache on AReA would engage on no call at all); Nunchaku's fused kernels bypass the attention seam, so it is reported unchanged. |
| enable_area | BOOLEAN | true | Enable or disable AReA. When disabled, the model is returned with nothing patched. |
| phase1_steps | INT | 80–100 | Number of leading denoising steps that run Phase I (coarse cross-scale attention), clamped to the total step count. 8 = the reference's FLUX constant (of 28). 0 = all Phase II (windowed attention from the first step). Only read when phase1_mode is 'steps'. Z-Image Turbo runs short (8-step) schedules: use 1-3 there (or sigma mode) — 8 of an 8-step run pools every step, which the distilled sampler cannot re-detail. On a SHORT schedule the effective coarse steps are capped at total_steps - 2 (two fine steps must remain, or the pooling footprint never heals): the forward-time log prints the knob, the cap and the effective count once per schedule, so a capped run is readable and the knob stays authoritative below the cap. |
| phase1_mode | COMBO | auto | How the Phase I -> Phase II switch is expressed. 'auto' = resolved per backbone: 'sigma' on Z-Image and Qwen-Image-2.1 (the leading steps still at or above phase1_sigma run Phase I, so the switch follows the schedule) and 'steps' on FLUX and Krea-2. 'steps' = the leading phase1_steps steps run Phase I (the reference's mode). 'sigma' = the leading steps whose noise level is still at or above phase1_sigma run Phase I, so the switch follows the schedule rather than a fixed count (8 of 28 sits at a sigma of roughly 0.88 on a shift-3.0 flow). 'bootstrap' = the paper's Appendix F mode: no Phase I at all, windowed Phase II from the first step; the early steps must have composed the canvas in a separate native-resolution pass whose latent was upscaled and re-noised to phase1_sigma (see the README pattern). |
| phase1_sigma | FLOAT | 0.890–1 | Noise level at which Phase I gives way to Phase II, when phase1_mode is 'sigma'. 0.89 = the paper's value for its first backbone; 0.86 was its Qwen-Image value, so treat this as per-schedule calibration rather than a universal constant. |
| pooling | COMBO | auto | Phase I pooling: which token of each f x f image block the pooled key/value comes from. 'auto' = resolved per backbone: 'subsample' on FLUX, 'mean' on Z-Image and Krea-2, 'medoid' on Qwen-Image-2.1. 'subsample' = block centre. 'mean' = block average for values, and for keys the block-mean direction rescaled to the mean member norm (the centroid keeps every token contributing while the norm keeps the attention temperature at the un-pooled one). 'medoid' = the token closest to the block-mean key — on Qwen-Image-2.1 it keeps ONE real token's key AND value, so the pooled cell carries a single content instead of a synthetic key over a blended value. 'random' = a token drawn per (seed, step, block). Keys must be pooled BEFORE the position rotation, so all four keep the survivors in the query's frame. |
| halo | INT | 80–64 | Widest Halo ring a Phase II window may draw (in patches). Each side of each window draws its own fresh width in [0, halo] at every step; AReA narrows it only when the windowed step would otherwise cost more than a full-attention step. |
| bridge_ratio | FLOAT | 0.500–1 | Rho of the bridge: each Phase II window also attends to R = round(rho * w)^2 of the canvas's most distinctive unrotated keys, spread over an 8x8 cell grid so no region is starved. 0 = no bridge. |
| bridge_floor_steps | INT | 20–16 | How many leading Phase II steps keep the paper's full bridge (R = round(rho*w)^2) and the full halo instead of the cost-capped ones. On short schedules (12 total steps or fewer) the cost cap starves the bridge exactly on the composition-critical steps, so those steps are exempted here; a 28-step FLUX run is never floored (long schedules ignore this knob). 0 = the cost cap on every step. The exemption costs about 1.0-1.4x full attention per floored step (measured 1.25x-1.41x on the 2048px Turbo schedule), and warns once naming the multiplier. |
| window_start | INT | 00–1024 | Window side (patches) Phase II starts its ramp at, instead of the cost-optimal size — smaller gives the early windows more global context. Short schedules only: a long (28-step) schedule ignores this knob. 0 = the cost-optimal start, which is clamped into [w_min, grid]; the ramp still shrinks to w_min. |
| window_hold_steps | INT | 00–8 | Extra Phase II steps that hold the start window before the ramp shrinks it (a start-heavy ramp for short schedules). Short schedules only: a long (28-step) schedule ignores this knob. |
| seed | INT | 00–18446744073709550000 | Seed of every draw (tile placement, Halo widths and reaches, random pooling). Keyed by (seed, step), so the same seed and step always build the same windows and halos — and cond and uncond attend through identical graphs. No global RNG is read. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Patched Model | MODEL | The model patched with AReA. |