ComfyUI Node

SEGA

The spectral patch that lets FLUX draw 4K natively

By wildminder·Created 11 months ago·Updated a day ago· 625
SEGA
  • model
  • Patched Model
width1024
height1024
model_typeauto
methodsega
mscale_alpha0.15
mscale_beta1.5
mscale_min1.00
spread_min0.00
spread_max1.00
spread_alpha1.5
base_mscale_formulapower_res
base_mscale_coefficient0.08
base_resolution1024
base_shift0.50
max_shift1.15

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 auto unless it misdetects; the explicit options are flux, 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) or ntk (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.
CategoryWMNodes/image

Inputs (16)

NameTypeDefaultDescription
modelMODELThe model to patch with SEGA.
widthINT102416–8192Target image width. Must match the width of your empty latent.
heightINT102416–8192Target image height. Must match the height of your empty latent.
model_typeCOMBOautoSpecify the model architecture. 'auto' usually works.
methodCOMBOsegaSEGA = NTK base + spectral per-dim mscale. NTK = base NTK only (no spectral).
mscale_alphaFLOAT0.150–1SEGA amplitude. Controls how much spectral redistribution is applied.
mscale_betaFLOAT1.50–10SEGA tanh sharpness. Higher = more binary redistribution.
mscale_minFLOAT1.000.1–2Floor for per-frequency mscale values.
spread_minFLOAT0.000–1Minimum spectral spread (early denoising steps).
spread_maxFLOAT1.000–1Maximum spectral spread (late denoising steps).
spread_alphaFLOAT1.50.1–5Non-linear mapping exponent for spread schedule.
base_mscale_formulaCOMBOpower_respower_res: m_ref = s^kappa. log_res: m_ref = 1 + kappa*ln(s).
base_mscale_coefficientFLOAT0.080–1Kappa coefficient for base mscale. Paper uses 0.08.
base_resolutionINT1024256–4096The native training resolution.
base_shiftoptFLOAT0.500–10Advanced: Base shift for the noise schedule (mu).
max_shiftoptFLOAT1.150–10Advanced: Max shift for the noise schedule (mu) at high resolutions.

Outputs (1)

NameTypeDescription
Patched ModelMODELThe model patched with SEGA.