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

Analyze Text Encoder Similarity (2 Models)

How different are they, really?

By silveroxides·Created about a year ago·Updated about 24 hours ago· 14
Analyze Text Encoder 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

    Before you extract a LoRA from a text encoder, or merge two of them, or even just wonder whether someone's "fine-tuned" CLIP is actually a fine-tune or a renamed copy - wouldn't it be nice to know how different they are first? That's this node. Point it at two text encoders and it streams both, compares every shared tensor, and hands you two text reports: one with plain statistical metrics, one with the pack's CWB diagnostics. No merging, no output file, nothing modified.

    The "Analyze Text Encoder Similarity (2 Models)" node from silveroxides/ComfyUI-ModelUtils is part of a family that covers checkpoints, diffusion models, LoRAs, and embeddings too - this one is the text-encoder slice. It's flagged experimental by the author, which mostly means "the report format may shift between versions," not "don't use it."

    What you get out

    Three string outputs, and you'll want to wire them to a text viewer or save node:

    • comparison_report - the numbers you'd expect from any model diff: MAE, MSE, RMSE, maximum absolute difference, scale-aware relative L2, cosine similarity, Pearson correlation, exact-equality and sign-agreement counts, norm ratios, and finite-value coverage. It also lists the top_weight_differences - the individual largest parameter deltas with their locations - which is the report section that actually tells you where the models diverged, not just how much.
    • cwb_report - the pack's Consensus-Weighted Blending diagnostics: per-row cosine statistics and each encoder's affinity to the mean and median consensus of the two. It stops before any merge-weighting stage, so it's a diagnostic, not a merge recipe. Text-encoder tensors keep fixed coordinate alignment here (unlike the LoRA/embedding variants, no alignment control is offered).
    • documentation - the full reference for what every metric means, so you don't have to guess from the report headers.

    Only shared, same-shape floating tensors enter the aggregates. Missing keys and shape mismatches are listed separately and never padded or zero-filled - an honest diff, which is more than most "similarity" tools manage. Models carrying ComfyUI quantization metadata are rejected outright, because quantized stored values aren't directly comparable to raw weights.

    The inputs that matter

    • execution_mode - ANALYZE runs the comparison; DOCUMENTATION ONLY loads no model data at all and just returns the documentation string. Handy for reading the metric reference without waiting on two multi-hundred-MB files.
    • model_a / model_b - the two encoders, from models/text_encoders.
    • top_weight_differences - how many of the largest individual differences to keep in the report (default 20, set 0 to disable that list).
    • exclude_patterns / glob_patterns - one pattern per line to exclude tensors from all metrics; regex by default, glob if you flip glob_patterns.

    Install

    ComfyUI Manager → search "Model Utility Toolkit", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-ModelUtils
    cd ComfyUI-ModelUtils
    pip install -r requirements.txt
    

    Restart; it lives under ModelUtils/Analysis. The key dependency is unifiedefficientloader - it streams both files in bounded async pipelines so this comparison doesn't demand you hold two encoders in memory at once.

    Watch out

    Analysis runs in fp32 and does real compute per tensor, so a full T5-class encoder comparison takes a while and a chunk of RAM. force_clear_cache (default on here) trades a bit of speed for keeping memory flat. If CUDA OOMs mid-run, the current layer retries on CPU once - not the whole run. And the honest gotcha: the reports are only as meaningful as your inputs. Comparing an encoder to a different architecture is exactly what the "missing keys / shape mismatches" section will cheerfully tell you, but you should probably already know before you start.

    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