Nodes/Tensor Prism/Model Key Filter (Tensor Prism)
ComfyUI Node

Model Key Filter (Tensor Prism)

Build a mask from model anatomy instead of numbers

By Arctenox·Created 12 months ago·Updated 7 months ago· 2
Model Key Filter (Tensor Prism)
  • model
  • filtered_mask
filter_modeInclude
target_componentsUNet
default_value0.00
target_value1.00
memory_limit_gb2.0
custom_patternattn,resnets
exact_match_customfalse

Mask-based merging lives on one question: which weights should model A control and which should model B control? You could hand-draw that as a mask by layer index - but a cleaner way is to select by what a parameter actually is. Model Key Filter (Tensor Prism) does that: it reads the model's parameter names, filters them by component, and emits a MASK that marks exactly those weights. Feed that mask into Weighted Mask Merge and you've got a merge that only touches the region you named.

It's the "find by name" node of the mask system. Instead of guessing that "attention lives around layer 4," it filters by the actual key naming in the state dict, which is how the model itself organizes its parts.

How it works

Connect a model, then set filter_mode to Include or Exclude and target_components to one of ten anatomy choices: All, UNet, VAE, Text Encoders, Time Embeddings, Input Blocks, Middle Block, Output Blocks, Final UNet Output Layer, or Custom Pattern. Two FLOATs define the mask values: default_value (0) for weights not matched, target_value (1) for weights that are - so you're building a 0/1 mask, and Include vs Exclude just flips which side gets the 1s.

The Custom Pattern target is the power option: type a comma-separated pattern like attn,resnets (the default) into custom_pattern, and exact_match_custom toggles whether matches must be exact or substring. memory_limit_gb (default 2) bounds how much memory the filter may chew through - and per the source, it batches the key scan to stay lean on big checkpoints.

Output is a single filtered_mask (MASK), ready for Mask Blender (to combine with other masks) or straight into Weighted Mask Merge.

The workflow

Generate → filter → apply:

  1. Use Model Mask Generator for structure-based masks (layers, blocks, depth) or Model Key Filter for anatomy-based masks.
  2. Combine several masks with Mask Blender if you want "attention in input blocks only."
  3. Feed the result into Weighted Mask Merge alongside the two models.

That chain is the pack's whole mask philosophy, and this node is the part that speaks the model's native language.

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. Ignore the typo'd clone URL in the README.

The honest caveat

Two practical notes. First, component naming differs across architectures - a mask built on SDXL key names won't mean the same thing on a different model family, so this is effectively an SDXL/SD1.5-era tool. Second, this is a young first-author pack with no community track record to lean on, so verify your filtered mask by testing the merged output, not by trusting the pattern. The good news: Custom Pattern with substring matching is forgiving, and the mask system as a whole is one of the pack's more genuinely useful ideas.

CategoryTensor_Prism/Mask

Inputs (8)

NameTypeDefaultDescription
modelMODEL
filter_modeCOMBOInclude2 options: Include, Exclude
target_componentsCOMBOUNet10 options: All, UNet, VAE, Text Encoders, Time Embeddings, Input Blocks, +4
default_valueFLOAT0.000–1
target_valueFLOAT1.000–1
memory_limit_gbFLOAT2.00.5–16
custom_patternoptSTRINGattn,resnets
exact_match_customoptBOOLEANfalse

Outputs (1)

NameTypeDescription
filtered_maskMASK