Pt Concat
Stitch tensors together without leaving the graph
- tens_a
- tens_b
- TENSOR
Somewhere in almost every serious PyTorch workflow you need to glue two tensors together - stack samples into a batch, join two feature vectors, concatenate token sequences. Pt Concat is the pack's torch.cat as a node: two tensors in, one tensor out, along the dimension you pick.
ComfyUI-Pt-Wrapper (HowToSD's 200-node PyTorch-in-ComfyUI pack) models everything as its private TENSOR type, and Pt Concat is one of the workhorses that moves data between shapes. In the README's Transformer-from-scratch example, concat is everywhere - joining embedding outputs with positional encodings, stacking hidden states, merging the pieces a multi-head attention block splits apart. If you're building a model out of the pack's pieces instead of using a prebuilt one, this node is how you reassemble what other nodes split.
How it works. Straight torch.concat([tens_a, tens_b], dim=dim).
tens_a,tens_b- the twoTENSORs to join. Shapes must match on every dimension except the one you're concatenating along.dim- the axis (default 0). 0 is the batch axis in PyTorch convention: two tensors of shape(8, 512)become(16, 512), which is how you build a bigger batch from smaller chunks. Concatenating along dim 1 joins features:(8, 256)+(8, 128)→(8, 384). Negative dims work too (-1means the last axis).
Output is a TENSOR with the summed size on dim.
Where beginners get bitten. Shape mismatches are the whole game. Concat adds a dimension's size - it does not broadcast, and it doesn't stack (stacking inserts a new axis; if you want (8,512) + (8,512) to become (2,8,512), that's a different operation). The classic error is trying to concat a (8,512) tensor with a (512,) tensor and getting a rank mismatch - you need Pt Unsqueeze first to give the second one its batch axis. Another common one: concatenating along dim 1 when you meant dim 0, which silently produces garbage-shaped data instead of erroring. And remember this is a tensor-to-tensor op - if you're trying to merge images or latents in normal ComfyUI land, the native batch-merge nodes are the better fit; Pt Concat works on the pack's TENSOR streams.
Install: ComfyUI Manager → "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
then restart. This node needs nothing beyond the pack's core install - no model downloads. The pack's requirements.txt is heavy (transformers, sklearn, sentencepiece, pinned gensim), so the first install is the slow part.
Troubleshooting: "Sizes of tensors must match" - check every dim except dim, and check ranks (use Pt Unsqueeze for the missing axis). Output shape surprising - print mentally what dim means in your data: batch is 0, sequence is 1, features are usually the last axis. If the pack's other nodes won't accept your output, you probably concat'd in the wrong place in the flow - the TENSOR type is strict about shape expectations downstream.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — | |
| dim | INT | 0-10–10 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |