ComfyUI Node

CPA DecodeAlpha

Decoding 49 Frames and Throwing Away the Colour

By rik-python·Created about a month ago·Updated 9 days ago· 50
CPA DecodeAlpha
  • samples
  • vae
  • alpha

A matte pass and a picture pass need completely different things out of a VAE decode. If you're generating an image, you want RGB, full precision, every pixel. If you're generating an alpha, you want one channel, and you want it small enough to hold 250 frames of it without swapping.

CPA DecodeAlpha is the pack's answer to the second case, and reading its twenty lines tells you a lot about how this pipeline thinks. It takes a LATENT and a VAE, decodes with ComfyUI core's tiled VAE decode at 512-pixel tiles with 64 overlap and 8 temporal tiles, averages the three colour channels into a single plane, and hands back a float16 MASK.

That's it. samples in, vae in, alpha out.

Why the averaging

Alpha-gen's decoded output carries the matte across the channels - LTX is a video model, and the IC-LoRA shapes its output into an alpha rather than an RGB picture, but "one channel" isn't how a video VAE decode is laid out. Averaging the channels is the cheapest correct-enough collapse to a single plane, and since the three planes carry the same signal, it also knocks down a bit of decode noise. It's the same trick the pack's tile-merge code uses when it gets handed an IMAGE where it expected a MASK.

Casting to float16 and pinning the result to CPU is the RAM play. A 1080p float32 RGB decode of one 49-frame chunk is around 1.2 GB. As half-precision single-channel it's roughly a sixteenth of that, and it can be handed to the cross-fade accumulation without competing with the model for VRAM.

Why it's fused

The docstring is explicit: the node is fused so that "the full-colour float32 decode (about 1.2 GB per 1080p chunk) is never cached or held for Stitch". In a plain ComfyUI graph, the output of every node is a candidate for the cache - which is exactly what makes re-running cheap, right up until the cached object is a gigabyte of colour you're about to discard. Decoding and collapsing in one node means the fat intermediate never exists as a node output, so it can't be cached, and it can't be held while the next chunk decodes.

This is the single most repeated pattern in this pack, and it's a good one to recognise if you're writing your own nodes: cache the thing you want again, not the thing you compute on the way there.

How it fits in the graph

One DecodeAlpha per LTX chunk. All of them feed CPA Stitch, which cross-fades the chunks back into one continuous alpha with triangular weights over the overlap frames, then that MASK goes into CPA Final for the blend and save.

SamplerCustomAdvanced ──samples──► CPA DecodeAlpha ──alpha──► CPA Stitch ──alpha──► CPA Final
LTXV VAE ──────────────vae───────►                  (one per chunk)

Note the sibling nodes, because picking the wrong one is the mistake you'd make here: CPA DecodeStitch does decode-and-cross-fade in a single node for the native-resolution tile path, and CPA DecodeStitchRGB keeps the colour for the Clean Plate pass that v15's perfect edge colour needs. If you want colour out of a latent, DecodeAlpha is the wrong node and you'll get a grey plane of numbers that happens to look like a plausible image.

Install

No install of its own - it's part of the pack, and it's an /internal node, flagged deprecated so it stays out of the node menu and only appears in the graph the Comfy Pro Alpha Generator builds.

cd ComfyUI/custom_nodes
git clone https://github.com/rik-python/ComfyUI-Comfy-Pro-Alpha-Generator.git
pip install -r ComfyUI-Comfy-Pro-Alpha-Generator/requirements.txt

The pack needs ComfyUI 0.38 or newer; the tiled VAE decode it calls is core, so there's no extra Python dependency for this node specifically.

Rough edges

VAE decode is where a mismatched VAE shows up first. The pack is insistent that you use the conv video VAE (ltx-2.5-video-vae-conv-bf16.safetensors), not the plain one - only the conv VAE can encode the plate that guides alpha-gen, and a wrong VAE gives you a matte that's plausible in the middle of the frame and wrong at the edges. If your alphas look like they've been smeared in one direction, check the VAE before you touch any of the tuning.

The other thing worth knowing: decoding is the slow part of a chunk, not the sampling. That's why the pack cross-fades decoded chunks rather than re-running chunks to smooth a join, and why a preview on 49 frames still takes minutes.

CategoryComfy Compositing/internal

Inputs (2)

NameTypeDefaultDescription
samplesLATENT—
vaeVAE—

Outputs (1)

NameTypeDescription
alphaMASK—