TeaCache Patcher
The same speedup as TeaCache_Lumina2, with a tuning lab bolted on
- model
- MODEL
- run_id
If you just want Lumina-Image-2.0 to render faster, you want the pack's TeaCache_Lumina2 node and you can stop reading here. TeaCache_Patcher is the same TeaCache speedup but dressed up as an experiment rig: instead of assuming you've found a good threshold, it patches the model with an instrumented forward pass, hands you a run_id, and - depending on which mode you pick - hand-tunes or Bayesian-optimizes the cache coefficients for you. It's the author's tuning harness, shipped as a node.
The mechanism is TeaCache with a lab coat. At each denoising step it compares the current adaLN-modulated input against the previous step's, rescales the relative L1 change through a polynomial, and accumulates; when the drift stays under rel_l1_thresh it reuses the previous step's residual and skips the expensive transformer stack. Same trick as the main node, but it also counts cache hits, times the run, and - if you've hooked up the pack's LPIPS nodes - records a perceptual quality score so you can judge whether a faster setting is actually worth it.
The inputs that matter
model- your Lumina-Image-2.0 UNet.mode- this is where it gets interesting, and a little awkward: the options are the raw strings from the code, so they show up in the dropdown in Chinese. You're choosing between 手动输入 (manual - you type the coefficients), 自动微调 (auto fine-tune - it perturbs one coefficient of the best previous run by 0.8–1.2x), and 贝叶斯优化 (Bayesian optimization via scikit-optimize). If you just want speed without the science, pick 手动输入.evaluation_metric- 速度-命中率权衡 (speed / hit-rate tradeoff) or 质量-命中率权衡 (LPIPS) (quality / hit-rate, requires the LPIPS nodes wired up).rel_l1_thresh(default 0.3) - same threshold knob as the main node, but note the lower default; this rig is calibrated for the older coefficient set.coefficients_str(optional) - the polynomial coefficients as a bracketed list; defaults to[393.7, -603.5, 209.1, -23.0, 0.86].max_lpips_thresh(optional, default 0.6) - a quality gate: runs whose LPIPS distance to the baseline exceed this get scored as zero. Set it to 0 to disable the gate.
Outputs are the patched MODEL and a run_id string. That run_id is the glue - you wire it into the pack's Result Collector and LPIPS Evaluator so the timing, hit counts, and quality score all land in the same record.
How the tuning loop works
The patcher reads and writes teacache_analysis.json in ComfyUI's output folder. Each run appends a record - threshold, coefficients, cache hits, generation time, LPIPS distance. In Bayesian mode, scikit-optimize feeds on that history and proposes the next coefficient set to try; auto-finetune is a cheap random perturbation of whatever scored best so far. The intended loop: run a baseline with rel_l1_thresh = 0 and store it as your reference image, then sweep thresholds and let the modes converge on something fast and not visibly worse.
Installing and the catches
Same install as the rest of the pack - ComfyUI Manager, search CUI-Lumina2-TeaCache, or:
cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/CUI-Lumina2-TeaCache.git
Restart, done. Two things to know before you rely on it. First, Bayesian mode needs scikit-optimize (it's in the pack's requirements, so Manager installs it; manual installs need pip install -r requirements.txt). Second - the honest take - all five of the pack's analysis nodes are flagged EXPERIMENTAL in the source, and they're clearly built for the author's own sweeps. If the Chinese dropdown labels annoy you, or you just don't want a global in-memory state machine deciding what your render is, use TeaCache_Lumina2 for daily driving and keep this one for when you genuinely want to find your optimal threshold.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — | |
| mode | COMBO | 3 options: 手动输入, 自动微调, 贝叶斯优化 | |
| evaluation_metric | COMBO | 2 options: 速度-命中率权衡, 质量-命中率权衡 (LPIPS) | |
| rel_l1_thresh | FLOAT | 0.300 | — |
| coefficients_stropt | STRING | [393.76566581, -603.50993606, 209.10239044, -23.00726601, 0.86377344] | — |
| max_lpips_threshopt | FLOAT | 0.60000–1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |
| run_id | STRING | — |