Nodes/Model Utility Toolkit/Analyze Diffusion Model Similarity (2 Models)
ComfyUI Node

Analyze Diffusion Model Similarity (2 Models)

Two diffusion models, zero merges — see how similar they really are first

By silveroxides·Created about a year ago·Updated about 24 hours ago· 14
Analyze Diffusion Model Similarity (2 Models)
    • comparison_report
    • cwb_report
    • documentation
    execution_mode
    model_a
    model_b
    top_weight_differences20
    process_device
    force_clear_cachetrue
    exclude_patterns
    glob_patternsfalse

    Same idea as its sibling node for checkpoints, but pointed at a different folder and a slightly different thing. A checkpoint bundles everything - UNet/DiT, text encoder, often a VAE - into one file. A standalone diffusion model in models/diffusion_models is just the denoiser: the UNet or DiT that does the actual generating. If you want to compare two UNets - say, a base Flux and a finetune built from it - without the text-encoder and VAE layers muddying the numbers, this is the node.

    How it works

    It streams two safetensors files from models/diffusion_models in low-memory mode (via the pack's Unified Efficient Loader, same as everything else in Model Utility Toolkit), and compares them layer by layer in fp32. You get the standard metric set - MAE, MSE, RMSE, max absolute difference, relative L2, cosine similarity, Pearson correlation, exact equality, sign agreement, norm ratio - plus a per-tensor breakdown, plus a second report with CWB diagnostics: row-wise cosine statistics and each model's affinity to a mean and median consensus, computed with the same machinery the pack's CWB merger nodes use when they actually blend two diffusion models.

    Same honest rules as the checkpoint version: missing keys and shape mismatches are listed, never padded or zero-filled. Quantized models carrying ComfyUI quantization metadata are rejected, because stored quantized values aren't comparable to raw weights. If you've been eyeing a GGUF UNet and want to compare it to fp16, you can't - you'll get an error instead of misleading numbers, which is the right behavior.

    Inputs you'll actually set

    • model_a / model_b - the two files. Model A is the anchor; keys unique to each input are reported separately.
    • top_weight_differences (default 20) - how many of the largest individual weight differences get their own list entries. Zero turns the list off; up to 1000 if you want the full picture.
    • exclude_patterns / glob_patterns - leave matching tensors out of all metrics and topology counts. Regex by default. This is genuinely useful on diffusion models: skip a known-identical conditioning branch or a norm layer so it doesn't flatten the aggregate stats.
    • process_device - cuda or cpu for the per-work-unit math. A CUDA OOM only retries the affected layer on CPU rather than dying.
    • force_clear_cache (default on) - garbage-collect and clear the CUDA allocator after every work unit. Saves retained memory, costs time. Leave it on for big DiTs; turn it off if you're on a big machine and want speed.
    • execution_mode - ANALYZE does the work; DOCUMENTATION ONLY returns the reference doc and loads nothing.

    Outputs and wiring

    You get comparison_report, cwb_report, and documentation as plain text. Wire them into a Show Text node. No model comes out the other end - this is a read-only diagnostic.

    Why you'd reach for it

    The classic move: you downloaded a fine-tune of an architecture you already have, and you want to know how far it actually drifted before you decide whether a CWB merge between it and another fine-tune makes sense. This node tells you which blocks moved and how much. It's also the sane first step before running CWBModelTwoMerger or CWBModelThreeMerger from the same pack - the CWB report is literally a preview of the merging math.

    Install

    Same pack as all of these: Model Utility Toolkit (silveroxides/ComfyUI-ModelUtils). ComfyUI Manager → "Install Custom Nodes" → search the pack title, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-ModelUtils
    

    Restart ComfyUI. The heavyweight dependency is unifiedefficientloader (UEL); requests, Pillow, mutagen, and av in requirements.txt belong to the pack's downloader nodes, not this one. These nodes use ComfyUI's newer extension API, so update ComfyUI if the node doesn't appear after install.

    CategoryModelUtils/Analysis

    Inputs (8)

    NameTypeDefaultDescription
    execution_modeCOMBOANALYZE streams both files and produces standard and CWB diagnostic reports. DOCUMENTATION ONLY performs no model loading.
    model_aCOMBOFirst file in the comparison. Reports identify values and keys unique to this input separately from Model B.
    model_bCOMBOSecond file in the comparison. Inputs are analyzed only; neither file is modified or merged.
    top_weight_differencesINT200–1000Number of largest individual absolute parameter differences retained for the detailed report. Zero disables this list.
    process_deviceCOMBODevice for per-work-unit floating-point analysis. A CUDA OOM retries only the affected unit on CPU.
    force_clear_cacheBOOLEANtrueRun garbage collection and clear the CUDA allocator cache after every analyzed work unit. Saves retained memory but slows analysis.
    exclude_patternsSTRINGOne pattern per line. Matching tensors are excluded from all comparison metrics and topology counts. Uses regex unless Glob Patterns is enabled.
    glob_patternsBOOLEANfalseInterpret exclusion entries as shell-style glob patterns instead of regular expressions.

    Outputs (3)

    NameTypeDescription
    comparison_reportSTRING
    cwb_reportSTRING
    documentationSTRING