TE LoRA Extract (Quantile)
Keep enough singular values to reach 90%
- output_path
Here's the friendliest way to think about a LoRA rank: "how much of the signal do I keep?" This node turns that sentence into a number. You extract a LoRA from a fine-tuned text encoder minus its base, and instead of picking a rank you tell it to keep enough singular values to reach a target percentage of the total - 90% by default. It's the quantile variant of the ModelUtils TE extractors, and it's the one that reads most naturally if you're new to this.
The mechanism is the pack's standard extraction pipeline: for each .weight tensor, compute A - B, run SVD, and keep singular values until their cumulative sum crosses the target fraction. Layers that are mostly noise stop early and stay cheap; layers with real structure get the rank they earn. The result is written as PEFT-style lora_A/lora_B factors into your loras folder, ready for a normal LoraLoader. If the target fraction demands a rank as big as the layer itself, the node just saves the full difference instead of pretending a decomposition helps.
The inputs that matter
- model_a / model_b - the fine-tuned and base text encoders from
models/text_encoders. - linear_quantile / conv_quantile - the cumulative singular-value target for linear/attention vs convolution layers (default 0.9). 0.9 keeps enough rank to cover 90% of the spectrum's mass; bump toward 1.0 for higher fidelity at a bigger file, drop it for compression.
- linear_max_rank / conv_max_rank - safety caps (default 128) so one outlier layer can't balloon the rank.
- probe_offset - extra singular values sampled beyond the cap so the "have we hit 90% yet?" decision is made against a spectrum that isn't truncated mid-answer.
- output_filename / save_dtype / device / lazy_load / force_clear_cache - the usual shared knobs: output name, save precision (fp16 default), compute device (with per-layer CPU fallback on OOM), and streaming vs. eager memory behavior.
Like the other extractors it's an output node: it writes the file and reports output_path. Nothing hangs off it.
Install
Search "Model Utility Toolkit" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-ModelUtils
cd ComfyUI-ModelUtils
pip install -r requirements.txt
Restart, and it lives under ModelUtils/LoRA Extract (TE). The dependency doing the heavy lifting is unifiedefficientloader, which lets the node stream both encoders instead of loading them fully.
Watch out
The silent-skip trap is real here too: default mismatch_mode: skip means mismatched or missing tensors disappear without a peep, so comparing an encoder to the wrong base quietly produces a nearly-empty file. And this is a full SVD per layer, so expect minutes of progress bar, not instant. If 90% of the spectrum sounds arbitrary, it is - the Knee variant's whole job is removing that guess, and Frobenius lets you set the target in terms of energy rather than singular-value mass. Quantile is the middle ground: explicit, interpretable, and usually right at 0.9.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model_a | COMBO | Finetuned Text Encoder model (A - B = LoRA) | |
| model_b | COMBO | Base Text Encoder model (A - B = LoRA) | |
| linear_quantile | FLOAT | 0.900–1 | Target cumulative singular-value fraction for linear layers. |
| conv_quantile | FLOAT | 0.900–1 | Target cumulative singular-value fraction for convolution layers. |
| probe_offset | INT | 321–4096 | Extra singular values sampled beyond Max Rank for a reliable bounded rank decision. |
| linear_max_rank | INT | 1281–16384 | Maximum extracted rank for linear layers. |
| conv_max_rank | INT | 1281–16384 | Maximum extracted rank for convolution layers. |
| lazy_load | BOOLEAN | true | Low memory mode: load tensors from disk on demand |
| force_clear_cache | BOOLEAN | false | Clear CUDA cache after each layer; slower but useful under severe VRAM pressure. |
| chunk_large_layers | BOOLEAN | false | Split large fused layers (QKV, MLP) into chunks |
| clamp_quantile | FLOAT | 0.990.5–1 | Clamp outlier singular values |
| min_diff | FLOAT | 0.0000–1 | Skip layers with max difference below this |
| mismatch_mode | COMBO | skip | Handle missing or incompatible text-encoder tensors by skipping them, substituting zeros where supported, or aborting. |
| output_filename | STRING | extracted_te_lora | Output filename without extension, written under the ComfyUI LoRA directory. |
| save_dtype | COMBO | fp16 | Data type used to save extracted text-encoder LoRA factors. |
| device | COMBO | cuda | Device used for per-layer extraction arithmetic; CUDA out-of-memory retries the affected layer on CPU where supported. |
| skip_patterns | STRING | Patterns for layers to skip (regex or glob depending on glob_skip_patterns) | |
| glob_skip_patterns | BOOLEAN | false | When True, skip_patterns use glob syntax (* = any sequence, ? = any char, dots are literal). When False (default), patterns are Python regex matched as substrings. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output_path | * | — |