ο»Ώ# MagicNodes β ComfyUI Render Pipeline (SD/SDXL)
Simple start. Expert-grade results. Reliable detail.
/
|
TL;DR: MagicNodes, it's a plug-and-play multi-pass "render-machine" for SD/SDXL models. Simple one-node start, expert-grade results. Core is ZeResFDG (Frequency-Decoupled + Rescale + Zero-Projection) and the always-on QSilk Micrograin Stabilizer, complemented by practical stabilizers (NAG, local masks, EPS, Muse Blend, Polish). Ships with a four-pass preset for robust, clean, and highly detailed outputs.
Our pipeline runs through several purposeful passes: early steps assemble global shapes, mid steps refine important regions, and late steps polish without overcooking the texture. We gently stabilize the amplitudes of the "imageβs internal draft" (latent) and adapt the allowed value range per region: where the model is confident we give more freedom, and where itβs uncertain we act more conservatively. The result is clean gradients, crisp edges, and photographic detail even at very high resolutions and, as a side effect on SDXL models, text becomes noticeably more stable and legible. |
Please note that the SDXL architecture itself has limitations and the result depends on the success of the seed, the purity of your prompt and the quality of your model+LoRA.
Draw
![]() |
![]() |
Photo Portrait
![]() |
![]() |
![]() |
![]() |
Photo Cup
![]() |
![]() |
Photo Dog
![]() |
![]() |
Features
- ZeResFDG: LF/HF split, energy rescale, and zero-projection (stable early, sharp late)
- NAG (Normalized Attention Guidance): small attention variance normalization (positive branch)
- Local spatial gating: optional CLIPSeg masks for faces/hands/pose
- EPS scale: small early-step exposure bias
- QSilk Micrograin Stabilizer: gently smooths rare spikes and lets natural micro-texture (skin, fabric, tiny hairs) show through β without halos or grid patterns. Always on, zero knobs, nearβzero cost.
- Adaptive Quantile Clip (AQClip): softly adapts the allowed range per region. Confident areas keep more texture; uncertain ones get cleaner denoising. Tileβbased with seamless blending (no seams). Optional Attn mode uses attention confidence for an even smarter balance.
- MGHybrid scheduler: hybrid Karras/Beta sigma stack with smooth tail blending and tiny schedule jitter (ZeSmart-inspired) for more stable, detail-friendly denoising; used by CADE and SuperSimple by default
- Seed Latent (MG_SeedLatent): fast, deterministic latent initializer aligned to VAE stride; supports pure-noise starts or image-mixed starts (encode + noise) to gently bias content; batch-ready and resolution-agnostic, pairs well with SuperSimple recommended latent sizes for reproducible pipelines
- Muse Blend and Polish: directional post-mix and final low-frequency-preserving clean-up
- SmartSeed (CADE Easy and SuperSimple): set
seed = 0to auto-pick a good seed from a tiny low-step probe. Uses a low-discrepancy sweep, avoids speckles/overexposure, and, if available, leverages CLIP-Vision (withreference_image) and CLIPSeg focus text to favor semantically aligned candidates. LogsSmart_seed_random: Start/End. I highly recommend working with SmartSeed. - CADE2.5 pipeline does not just upscale the image, it iterates and adds small details, doing it carefully, at every stage.
Hardware
- The pipeline is designed for good hardware (tested on RTX5090 (32Gb) and RAM 128Gb), try to keep the starting latent very small, because there is an upscale at the steps and you risk getting errors if you push up the starting values.
- start latent ~ 672x944 -> final ~ 3688x5192 across 4 steps.
- Notes
- Lowering the starting latent (e.g., 512x768) or lower, reduces both VRAM and RAM.
- Disabling hi-res depth/edges (ControlFusion) reduces peaks. (not recommended!)
- Depth weights add a bit of RAM on load; models live under
depth-anything/.
π₯ Memory
- At each step, the image is upscaled from the previous step! Keep this in mind, the final image may not fit into your PC's memory if the starting latent is high.
Install (ComfyUI 0.3.60, tested on this version)
Preparing: I recomend update pytorch version: 2.8.0+cu129.
- PyTorch install:
pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu129 - CUDA manual download and install: https://developer.nvidia.com/cuda-12-9-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_local
- Install
SageAttention 2.2.0, manualyhttps://github.com/thu-ml/SageAttentionor use scriptscripts/check_sageattention.bat. The installation takes a few minutes, wait for the installation to finish. p.s.: To work, you definitely need to installSageAttention v.2.2.0,version 1.0.6is not suitable for pipeline.
Next:
- Clone or download this repo into
ComfyUI/custom_nodes/ - Install helpers:
pip install -r requirements.txt - I recomend, take my negative LoRA
mg_7lambda_negative.safetensorsin HF https://huggingface.co/DD32/mg_7lambda_negative/blob/main/mg_7lambda_negative.safetensors and place the file in ComfyUI, toComfyUI/models/loras - download model
depth_anything_v2_vitl.pthhttps://huggingface.co/depth-anything/Depth-Anything-V2-Large/tree/main and place inside in todepth-anything/folder. - Workflows
Folder
workflows/contains ready-to-use graphs:
mg_SuperSimple-Workflow.jsonβ one-node pipeline (2/3/4 steps) with presetsmg_Easy-Workflow.jsonβ the same logic built from individual Easy nodes You can save this workflow to ComfyUIComfyUI\user\default\workflows
- Restart ComfyUI. Nodes appear under the "MagicNodes" categories.
I strongly recommend use mg_Easy-Workflow workflow + default settings + your model and my negative LoRA mg_7lambda_negative.safetensors, for best result.
π "One-Node" Quickstart (MG_SuperSimple)
Start with MG_SuperSimple for the easiest path:
- Drop
MG_SuperSimpleinto the graph - Connect
model / positive / negative / vae / latentand aLoad ControlNet Modelmodule - Choose
step_count(3/4) and Run
or load mg_SuperSimple-Workflow in panel ComfyUI
Notes:
- When "Custom" is off, presets fully drive parameters
- When "Custom" is on, the visible CADE controls override the Step presets across all steps; Step 1 still enforces
denoise=1.0 - CLIP Vision (if connected) is applied from Step 2 onward; if no reference image is provided, SuperSimple uses the previous step image as reference
- Step 1 and Step 2 it's a prewarming step.
βTips
(!) There are almost always artifacts in the first step, don't pay attention to them, they will be removed in the next steps. Keep your prompt clean and logical, don't duplicate details and be careful with symbols.
MG_SuperSimple-Workflowis a bit less flexible thanMG_Easy-Workflow, but extremely simple to use. If you just want a stable, interesting result, start with SuperSimple.Recommended negative LoRA:
mg_7lambda_negative.safetensorswithstrength_model = -1.0,strength_clip = 0.2. Place LoRA files underComfyUI/models/lorasso they appear in the LoRA selector.Download a CLIP Vision model and place it under
ComfyUI/models/clip_vision(e.g., https://huggingface.co/openai/clip-vit-large-patch14; heavy alternative: https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K). SuperSimple/CADE will use it for reference-based polish.Samplers: i recomend use
ddimfor many cases (Draw and Realism style). Scheduler: useMGHybridin this pipeline.Denoise: higher -> more expressive and vivid; you can go up to 1.0. The same applies to CFG: higher -> more expressive but may introduce artifacts. Suggested CFG range: ~4.5β8.5.
If you see unwanted artifacts on the final (4th) step, slightly lower denoise to ~0.5β0.6 or simply change the seed.
You can get interesting results by repeating steps (in Easy/Hard workflows), e.g.,
1 -> 2 -> 3 -> 3. Just experiment with it!Recommended starting latent close to ~672x944 (other aspect ratios are fine). With that, step 4 produces ~3688x5192. Larger starting sizes are OK if the model and your hardware allow.
Unlucky seeds happen β just try another. (We may later add stabilization to this process.)
Rarely, step 3 can show a strange grid artifact (in both Easy and Hard workflows). If this happens, try changing CFG or seed. Root cause still under investigation.
Results depend on checkpoint/LoRA quality. The pipeline βsqueezesβ everything SDXL and your model can deliver, so prefer highβquality checkpoints and nonβovertrained LoRAs.
Avoid using more than 3 LoRAs at once, and keep only one βleadβ LoRA (one you trust is not overtrained). Too many/strong LoRAs can spoil results.
Try connecting reference images in either workflow β you can get unusual and interesting outcomes.
Very often, the image in
step 3 is of very good quality, but it usually lacks sharpness. But if you have aweak system, you canlimit yourself to 3 steps.SmartSeed (auto seed pick): set
seed = 0in Easy or SuperSimple. The node will sample several candidate seeds and do a quick lowβstep probe to choose a balanced one. Youβll see logsSmart_seed_random: StartandSmart_seed_random: End. Seed is: <number>. Use any nonβzero seed for fully deterministic runs.The 4th step sometimes saves the image for a long time, just wait for the end of the process, it depends on the initial resolution you set.
The
CombiNodenode is optional, you can replace it with standard ComfyUI pipelines.
Repository Layout
Repository Layout
MagicNodes/
ββ README.md
ββ LICENSE # AGPL-3.0-or-later
ββ assets/
ββ docs/
β ββ EasyNodes.md
β ββ HardNodes.md
β ββ hard/
β ββ CADE25.md
β ββ ControlFusion.md
β ββ UpscaleModule.md
β ββ IDS.md
β ββ ZeSmartSampler.md
β
ββ mod/
β ββ easy/
β β ββ mg_cade25_easy.py
β β ββ mg_controlfusion_easy.py
β β ββ mg_supersimple_easy.py
β β ββ preset_loader.py
β ββ hard/
β β ββ mg_cade25.py
β β ββ mg_controlfusion.py
β β ββ mg_tde2.py
β β ββ mg_upscale_module.py
β β ββ mg_ids.py
β β ββ mg_zesmart_sampler_v1_1.py
β β
β ββ mg_cleanup.py
β ββ mg_combinode.py
β ββ mg_latent_adapter.py
β ββ mg_sagpu_attention.py
β ββ mg_seed_latent.py
β
ββ pressets/
β ββ mg_cade25.cfg
β ββ mg_controlfusion.cfg
β
ββ scripts/
β ββ check_sageattention.bat
β ββ check_sageattention.ps1
β
ββ depth-anything/ # place Depth Anything v2 weights (.pth), e.g., depth_anything_v2_vitl.pth
β ββ depth_anything_v2_vitl.pth
β
ββ vendor/
β ββ depth_anything_v2/ # vendored Depth Anything v2 code (Apache-2.0)
β
ββ workflows/
β ββ mg_SuperSimple-Workflow.json
β ββ mg_Easy-Workflow.json
|
ββ requirements.txt
Module Notes and Guides
A compact set of perβmodule notes, knobs, and usage tips covering Control Fusion, CADE 2.5, MG_CleanUp, and the experimental Magic Latent Adapter.
Control Fusion (mg_controlfusion.py, mg_controlfusion_easy.py,)
- Builds depth + edge masks with preserved aspect ratio; hires-friendly mask mode
- Key surface knobs:
edge_alpha,edge_smooth,edge_width,edge_single_line/edge_single_strength,edge_depth_gate/edge_depth_gamma - Preview can optionally reflect ControlNet strength via
preview_show_strengthandpreview_strength_branch
CADE 2.5 (mg_cade25.py, mg_cade25_easy.py)
- Deterministic preflight: CLIPSeg pinned to CPU; preview mask reset; noise tied to
iter_seed - Encode/Decode: stride-aligned, with larger overlap for >2K to avoid artifacts
- Polish mode (final hi-res refinement):
polish_enable,polish_keep_low(global form from reference),polish_edge_lock,polish_sigma- Smooth start via
polish_start_afterandpolish_keep_low_ramp
eps_scalesupported for gentle exposure shaping
MG_CleanUp (final memory cleanup node)
Purpose: a tiny end-of-graph node that aggressively frees RAM/VRAM and asks the OS to return freed pages. Place it at the very end of a workflow (ideally right after SaveImage).
Returns: passthrough
LATENTand a smallIMAGEpreview (32Γ32). For the cleanup to work, be sure to connect thePreviewnode to theIMAGEoutput.What it does (two passes: immediate and +150 ms):
- CUDA sync,
gc.collect(),torch.cuda.empty_cache()+ipc_collect() - Comfy model manager soft cache drop; when
hard_trim=truealso unloads loaded models (will reload on next run) - Drops lightweight LRU/preview caches (when available)
- Windows: trims working set (
SetProcessWorkingSetSize+EmptyWorkingSet) and best-effort system cache/standby purge - Linux:
malloc_trim(0)to release fragmented heap back to the OS - Logs how much RAM/VRAM was freed in each pass
- CUDA sync,
Inputs:
hard_trim(bool): enable the strongest cleanup (unload models, OS-level trims).sync_cuda(bool): synchronize CUDA before cleanup (recommended).hires_only_threshold(int): run only when the latent longest side β₯ threshold;0= always.
Notes:
- Because models are unloaded in
hard_trim, the next workflow run may take a bit longer to start (models will reload). - Use this node only at the end of a graph β it is intentionally aggressive.
Depth Anything v2 (vendor)
- Lives under
vendor/depth_anything_v2; Apache-2.0 license
Depth models (Depth Anything v2)
- Place DA v2 weights (
.pth) indepth-anything/. Recommended:depth_anything_v2_vitl.pth(ViT-L). Supported names include:depth_anything_v2_vits.pth,depth_anything_v2_vitb.pth,depth_anything_v2_vitl.pth,depth_anything_v2_vitg.pth, and the metric variantsdepth_anything_v2_metric_vkitti_vitl.pth,depth_anything_v2_metric_hypersim_vitl.pth. - ControlFusion auto-detects the correct config from the filename and uses this path by default. You can override via the
depth_model_pathparameter (preset) if needed. - If no weights are found, ControlFusion falls back gracefully (luminance pseudo-depth), but results are better with DA v2.
- Where to get weights: see the official Depth Anything v2 repository (https://github.com/DepthAnything/Depth-Anything-V2)
and its Hugging Face models page (https://huggingface.co/Depth-Anything) for pre-trained
.pthfiles.
MG_ZeSmartSampler (Experimental)
- Custom sampler that builds hybrid sigma schedules (Karras/Beta blend) with tail smoothing
- Inputs/Outputs match KSampler:
MODEL/SEED/STEPS/CFG/base_sampler/schedule/CONDITIONING/LATENT->LATENT - Key params:
hybrid_mix,jitter_sigma,tail_smooth, optional PC2-like shaping (smart_strength,target_error,curv_sensitivity)
Seed Latent (mg_seed_latent.py)
- Purpose: quick LATENT initializer aligned to VAE stride (4xC, H/8, W/8). Can start from pure noise or mix an input image encoding with noise to gently bias content.
- Inputs
width,height,batch_sizesigma(noise amplitude) andbias(additive offset)- Optional
vaeandimagewhenmix_imageis enabled
- Output:
LATENTdict{ "samples": tensor }ready to feed into CADE/SuperSimple. - Usage notes
- Keep dimensions multiples of 8; recommended starting sizes around ~672x944 (other aspect ratios work). With SuperSimpleβs default scale, step 4 lands near ~3688x5192.
mix_image=Trueencodes the provided image via VAE and adds noise: a soft way to keep global structure while allowing refinement downstream.- For run-to-run comparability, hold your sampler seed fixed (in SuperSimple/CADE). SeedLatent itself does not expose a seed; variation is primarily controlled by the sampler seed.
- Batch friendly:
batch_size>1produces independent latents of the chosen size.
Magic Latent Adapter (mg_latent_adapter.py) !experimental!
- Purpose: small adapter node that generates or adapts a
LATENTto match the target modelβs latent format (channels and dimensions), including 5D layouts (NCDHW) when required. Two modes:generate(make a fresh latent aligned to VAE stride) andadapt(reshape/channelβmatch an existing latent). - How it works: relies on Comfyβs
fix_empty_latent_channelsand reads the modelβslatent_formatto adjust channel count; aligns spatial size to VAE stride; handles 4D (NCHW) and 5D (NCDHW). - Experimental: added to ease early, experimental support for FLUX/Qwenβlike models by reducing shape/dimension friction. Still evolving; treat as optβin.
- Usage: place before CADE/your sampler. In
generatemode you can also enable image mixing via VAE; inadaptmode feed any upstreamLATENTand the currentMODEL. A simple family switch (auto / SD / SDXL / FLUX) controls stride fallback when VAE isnβt provided. - Notes: quality with FLUX/Qwen models also depends on using the proper text encoders/conditioning nodes for those families; this adapter only solves latent shapes, not conditioning mismatches.
Documentation
- Easy nodes overview and
MG_SuperSimple:docs/EasyNodes.md - Hard nodes documentation index:
docs/HardNodes.md
Dependencies (Why These Packages)
transformers β used by CADE for CLIPSeg (CIDAS/clipseg-rd64-refined) to build textβdriven masks (e.g., face/hands). If missing, CLIPSeg is disabled gracefully.
opencv-contrib-python β ControlFusion edge stack (Pyramid Canny, thinning via ximgproc), morphological ops, light smoothing.
Pillow β image I/O and small conversions in preview/CLIPSeg pipelines.
scipy β preferred Gaussian filtering path for IDS (quality). If not installed, IDS falls back to a PyTorch implementation.
sageattention β accelerated attention kernels (auto-picks a kernel per GPU arch); CADE/attention patch falls back to stock attention if not present.
Optional extras
- controlnet-aux β alternative loader for Depth Anything v2 if you donβt use the vendored implementation (not required by default).
Preprint
CADE 2.5 - ZeResFDG
CADE 2.5 - QSilk
How to Cite
@misc{rychkovskiy2025cade25zeresfdg,
title={CADE 2.5 - ZeResFDG: Frequency-Decoupled, Rescaled and Zero-Projected Guidance for SD/SDXL Latent Diffusion Models},
author={Denis Rychkovskiy},
year={2025},
eprint={2510.12954},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2510.12954},
}
@misc{rychkovskiy2025qsilkmicrograinstabilizationadaptive,
title={QSilk: Micrograin Stabilization and Adaptive Quantile Clipping for Detail-Friendly Latent Diffusion},
author={Denis Rychkovskiy},
year={2025},
eprint={2510.15761},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2510.15761},
}
Attribution (kind request)
If you use this work or parts of it, please consider adding the following credit in your README/About/credits: "Includes CADE 2.5 (ZeResFDG, QSilk) by Denis Rychkovskiy (βDZRoboβ)"
License and Credits
- License: AGPL-3.0-or-later (see
LICENSE)
Support
If this project saved you time, you can leave a tip:
- GitHub Sponsors: https://github.com/sponsors/1dZb1
- Bymeacoffee: https://buymeacoffee.com/dzrobo









