Nodes/Tensor Prism/Analyze Model Weights (Tensor Prism)
ComfyUI Node

Analyze Model Weights (Tensor Prism)

Let math pick your merge ratios instead of guessing

By Arctenox·Created 12 months ago·Updated 7 months ago· 2
Analyze Model Weights (Tensor Prism)
  • model_a
  • model_b
  • merge_recipe
optimization_method
global_alpha0.50
optimization_strength0.80
target_mean_weight0.50
target_std_dev-1.00
smooth_weightsfalse
smoothing_strength0.30
use_model_a_as_basetrue
fp16_modetrue
verbosetrue
auto_detect_optimalfalse

Picking a merge ratio is usually a vibe check: start at 0.5, squint at renders, nudge, repeat. Analyze Model Weights (Tensor Prism) is the "stop vibing, measure" option. Feed it two models and it studies their weights block by block and hands back a per-block recipe - the exact ratios that, by its math, produce the best blend. It's the analysis half of a two-node workflow; the Apply Merge Recipe node is what actually applies the recipe it spits out.

Is it magic? No. It's statistics: it compares the two models' weights and scores how much each block should lean one way or the other. But it replaces twenty minutes of eyeballing with one analysis pass, and it's CPU-based, so it won't fight your GPU for VRAM while it thinks.

How it works

You feed in model_a and model_b, then pick an optimization_method - five ways to score block similarity and quality:

  • combined - a blend of the others; the README's pick for general use.
  • similarity - favors blocks where the models agree.
  • variance - favors blocks with richer internal variation.
  • gradient_magnitude - weights blocks by how strongly they'd respond to change.
  • entropy - favors blocks with higher information content.

global_alpha (0.5) is the starting point for the optimization (tooltip: "Starting point for optimization"), and optimization_strength (0.8, "How much to trust automated optimization") decides how far the analysis may push ratios away from that start. Two target_* fields shape the result: target_mean_weight (0.5, "-1 = auto-detect") is the average ratio across all blocks, and target_std_dev (-1) controls how much variation between blocks you allow - set higher for more aggressive block-by-block differences, 0 for a flat uniform recipe. smooth_weights with smoothing_strength (0.3) flattens the recipe if the raw output is too jumpy.

Optional niceties: use_model_a_as_base (on) builds the recipe around A; auto_detect_optimal lets it pick target_mean_weight from measured similarity instead of your guess; fp16_mode and verbose mostly affect speed and console chatter.

The single output is merge_recipe of type MERGE_RECIPE - a custom type that only this pack's Apply Merge Recipe node understands, so the pairing is mandatory.

The workflow

[Model A] ─┐
           → [Analyze Model Weights] → [merge_recipe] → [Apply Merge Recipe] → [Merged MODEL]
[Model B] ─┘                                             ↑
                                                [Model A]  [Model B]

Run the analysis once, save the recipe if you like the result - the README explicitly suggests keeping good recipes around as text for reproducible merges.

Installing it

Part of ComfyUI-Tensor-Prism-Node-Pack. ComfyUI Manager → search "Tensor Prism" → Install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/AstrionX/ComfyUI-Tensor-Prism-Node-Pack

No model downloads; deps are torch, numpy, psutil. Skip the README's clone URL (typo'd), use Manager or the URL above.

The honest caveat

This is a young pack from a first-time author, built with heavy LLM assistance, and "analyze then merge" is the kind of tool that sounds more rigorous than it is - the scoring heuristics are reasonable but unproven at scale. Treat the recipe as a strong starting point, not gospel: if optimization_strength at 0.8 gives you a weird recipe, dial it back to 0.3–0.5 and see if the result makes more sense. The README also notes analysis failures are usually a RAM problem - the models stay on GPU but analysis runs on CPU, so give it enough system memory.

CategoryTensor_Prism/Analysis

Inputs (13)

NameTypeDefaultDescription
model_aMODEL
model_bMODEL
optimization_methodCOMBO5 options: combined, similarity, variance, gradient_magnitude, entropy
global_alphaFLOAT0.500–1Starting point for optimization
optimization_strengthFLOAT0.800–1How much to trust automated optimization
target_mean_weightFLOAT0.50-1–1Target mean weight across all blocks (-1 = auto-detect)
target_std_devFLOAT-1.00-1–0.5Target standard deviation (-1 = auto, 0 = uniform, higher = more variation)
smooth_weightsBOOLEANfalseApply smoothing to reduce weight variance
smoothing_strengthFLOAT0.300–1How much to smooth (0=none, 1=completely flatten)
use_model_a_as_baseoptBOOLEANtrue
fp16_modeoptBOOLEANtrue
verboseoptBOOLEANtrue
auto_detect_optimaloptBOOLEANfalseAuto-detect optimal mean weight based on model similarity

Outputs (1)

NameTypeDescription
merge_recipeMERGE_RECIPE