SEGA
The spectral patch that lets FLUX draw 4K natively
- model
- Patched Model
Most "high-res" workflows are a lie: you generate at 1K and then invent the extra pixels afterwards with a hi-res fix, ESRGAN, or SUPIR. SEGA goes the other way. It's a model patch from the ComfyUI-DyPE pack that lets a diffusion transformer like FLUX or Qwen-Image draw a big canvas natively - no upscale pass, no second sampler, no tiling. Drop it between your model loader and your KSampler, tell it your target resolution, and the model suddenly handles 2K–4K without the repeating-artifact mess it usually falls into.
The name is recycled, which confuses everyone. AUTOMATIC1111's old SEGA (Semantic Guidance) was a prompt-injection trick for SD 1.5. This one is Spectral-Energy Guided Attention, the method from the SEGA paper (arXiv 2605.22668) by Rajabi et al. - and it's new enough that people on r/StableDiffusion were literally asking "waiting for it to come in ComfyUI" the day it dropped. This node is that port, added to ComfyUI-DyPE in v2.5.0.
How it works
DiTs like FLUX position their attention with rotary embeddings (RoPE), and those embeddings only know their training resolution (~1 megapixel). Push past that and attention gets confused - that's your repeating tiles and structural degradation. The old fixes, NTK scaling and YaRN, are static: they just stretch the frequency base once and hope.
SEGA is content-aware. At every denoising step it grabs the actual latent, computes a 2D FFT power spectrum, bins the energy into concentric frequency rings, and uses that to derive a per-frequency mscale - a per-RoPE-dimension rescaling that sharpens the frequencies the current image actually needs. Early steps see mostly low-frequency structure, so the spread is narrow; late steps widen out to resolve detail. Because the spectrum comes from your latent, different compositions get different scaling. NTK is still the base extrapolation underneath; SEGA is the refinement layer on top.
The practical cost is real but small: computing an FFT on the hidden states every step is cheap relative to a FLUX forward pass, though it's not the "zero inference overhead" the pack advertises for its DyPE node. It's also the reason SEGA can't help models where NTK itself fails - if NTK won't extrapolate a model, the spectral layer sits on top of nothing.
The inputs that matter
The node's full schema is long, but a beginner sets maybe four fields:
- width / height - must match your Empty Latent exactly (the node snaps to a multiple of 16 internally). Default 1024, up to 8192.
- model_type - leave on
autounless it misdetects; the explicit options areflux,nunchaku,qwen(also Krea-2),zimage,anima. - base_resolution - the model's native training resolution: 1024 for FLUX/Z-Image, 1328 for Qwen-family, 1920 for Anima.
- method -
sega(default, NTK + spectral) orntk(pure NTK, for A/B testing whether the spectral layer is helping).
Then the knobs: mscale_alpha (0.15) is how much spectral redistribution gets applied - your main sharpness-vs-artifacts dial. mscale_beta (1.5) is tanh sharpness, effectively binary versus smooth redistribution. spread_min/spread_max set the gate range over the denoising schedule, and base_mscale_coefficient (κ, 0.08) is the paper's default for the resolution-scaling term. The optional base_shift/max_shift control the noise-schedule shift (mu) - the README notes these are the "advanced" knobs and there's been community head-scratching about exactly what they change, so don't touch them first.
The single output, Patched Model, wires straight into your KSampler's model input.
Installing it
Via ComfyUI Manager, search ComfyUI-DyPE and install, then restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/wildminder/ComfyUI-DyPE
No extra dependencies (it only needs torch, which you have) and no model files to download - it patches whatever FLUX/Qwen checkpoint you already load. If you don't see the SEGA node after installing, update the pack; SEGA shipped in v2.5.0.
Where people get burned
- It's FLUX/Qwen territory. The README is explicit: SEGA uses NTK as its base, so on architectures where NTK misbehaves (notably Anima/Cosmos), SEGA won't help either - the pack recommends its other node, DyPE with
vision_yarn, for those. - 4K is still 4K. You're pushing a model trained on ~1MP to generate 16MP. Expect speckle noise in hair and eyes at extreme scales; that's the model's ceiling, not a bug you've caused. Start at 2K where the payoff is clean.
- It's one flavor of a live argument. The generate-native-at-high-res school (DyPE, SEGA) has real skeptics who prefer generating small and refining with tiled upscalers, citing VRAM and time. Fair enough - but SEGA is worth a couple of test renders if you're tired of your upscale pass melting detail.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | The model to patch with SEGA. | |
| width | INT | 102416–8192 | Target image width. Must match the width of your empty latent. |
| height | INT | 102416–8192 | Target image height. Must match the height of your empty latent. |
| model_type | COMBO | auto | Specify the model architecture. 'auto' usually works. |
| method | COMBO | sega | SEGA = NTK base + spectral per-dim mscale. NTK = base NTK only (no spectral). |
| mscale_alpha | FLOAT | 0.150–1 | SEGA amplitude. Controls how much spectral redistribution is applied. |
| mscale_beta | FLOAT | 1.50–10 | SEGA tanh sharpness. Higher = more binary redistribution. |
| mscale_min | FLOAT | 1.000.1–2 | Floor for per-frequency mscale values. |
| spread_min | FLOAT | 0.000–1 | Minimum spectral spread (early denoising steps). |
| spread_max | FLOAT | 1.000–1 | Maximum spectral spread (late denoising steps). |
| spread_alpha | FLOAT | 1.50.1–5 | Non-linear mapping exponent for spread schedule. |
| base_mscale_formula | COMBO | power_res | power_res: m_ref = s^kappa. log_res: m_ref = 1 + kappa*ln(s). |
| base_mscale_coefficient | FLOAT | 0.080–1 | Kappa coefficient for base mscale. Paper uses 0.08. |
| base_resolution | INT | 1024256–4096 | The native training resolution. |
| base_shiftopt | FLOAT | 0.500–10 | Advanced: Base shift for the noise schedule (mu). |
| max_shiftopt | FLOAT | 1.150–10 | Advanced: Max shift for the noise schedule (mu) at high resolutions. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| Patched Model | MODEL | The model patched with SEGA. |