Pt Add
The node under everything
- tens_a
- tens_b
- TENSOR
Pt Add adds two tensors element by element. That's it. And yet if you build models out of ComfyUI-Pt-Wrapper's pieces instead of using a prebuilt node, add is the connective tissue: residual connections are additions, biases are additions, combining embedding and positional signals is an addition. Half of modern architecture is "add the thing back to what it came from."
It's the arithmetic workhorse in HowToSD's 200-node PyTorch pack (the spin-off of ComfyUI-Data-Analysis). The README's from-scratch Transformer guide uses it everywhere - the residual connection in every block (layer output plus the block's input), the positional-encoding sum, merging attention heads' contributions. If you're going to hand-build any network in this pack, you'll use Pt Add before you use most of the other math nodes.
How it works. Two inputs, tens_a and tens_b; one output, TENSOR. Straight tens_a + tens_b, element-wise, with PyTorch broadcasting: if the shapes don't match but are broadcast-compatible (e.g. (8, 512) plus (512,)), PyTorch stretches the smaller one. That's a feature - it's how bias terms and per-channel additions work - but it's also where surprises come from.
The two things that trip people up. First, broadcasting means mismatched shapes don't always error - they silently produce a result of the larger shape, and if the shapes can't broadcast at all, you get an error at runtime, mid-graph, not at the node. Debugging tip: if an add outputs a shape you didn't expect, one of your tensors is shaped wrong upstream, and PyTorch was too polite to complain. Second, the residual trap: "adding" doesn't concatenate. New people sometimes wire Pt Add expecting two (8, 512) tensors to become (16, 512) - that's Concat's job. Add merges by value: (8, 512) + (8, 512) = (8, 512). If your shapes grow unexpectedly, you grabbed the wrong join node.
Also worth a moment: Pt Add is the node that makes residual connections trivially correct - that's why the pack's deeper models train as well as they do. A residual block is "add the block's output back to its input," which is one node after one block. If you're new to building models here, start with a residual connection; it's the single most instructive graph you'll wire, and Pt Add is its center.
Install: ComfyUI Manager → "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
then restart. No model downloads; the pack's heavy requirements.txt (transformers, sklearn, sentencepiece, pinned gensim) is the only install cost.
Troubleshooting: output shape unexpectedly large or small - check broadcasting and whether you meant Concat. Runtime "sizes of tensors must match" - one tensor is genuinely wrong-shaped; trace it upstream. Values explode or drift - you're adding the same signal repeatedly without scaling (e.g. adding a positional encoding on every layer); that's a design issue, not a node bug. If the pack's model nodes reject your output, confirm you fed it TENSORs, not images or latents.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |