Pt Prod
Pt Prod is the reduction nobody thinks about
- tens
- TENSOR
PtProd computes the product of a tensor along one dimension - torch.prod() as a node. Sums get all the attention; products are the quiet cousin you forget exists until you need to multiply an entire axis of values down to a single number. That's exactly what this node is for: collapse a dimension by multiplying everything in it.
How it works
Three inputs, one TENSOR output:
- tens - the tensor you're reducing.
- dim - which axis to multiply along, as a text field (e.g.
0or1). This is a string in the node's schema because the pack parses it, but you'll almost always type a single integer. A product over dim 0 of a(3, 4)tensor gives you a(4,)tensor where each element is the product down that column. - keepdim - whether to keep the reduced axis as a size-1 dimension (so a
(3, 4)tensor reduced over dim 0 becomes(1, 4)instead of(4,)). DefaultFalse. Leave itTrueif you're feeding the result into something that expects the original rank.
Output is a single TENSOR you can chain into any Pt* node.
When you'd actually reach for it
The honest use cases are narrower than sum's: probability-style math (a product of independent probabilities), volume-style computations over a dimension, factorial-ish reductions, or feature-aggregation experiments where you genuinely want a multiplicative aggregate instead of an average. There's also a classic numerical footgun that makes this node worth understanding: multiplying many values between 0 and 1 shrinks the result toward zero alarmingly fast, and multiplying large values can overflow to inf. If your product comes out as 0.0 or inf, that's floating-point reality doing its thing, not a broken node - you're often better off summing logs.
Installing it
Part of ComfyUI-Pt-Wrapper (HowToSD's no-code PyTorch pack, a spin-off of ComfyUI-Data-Analysis). ComfyUI Manager → search "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart after; first boot is slow while pandas, scikit-learn, transformers, sentencepiece, peft and friends install. No model downloads needed.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| tens | TENSOR | — | |
| dim | STRING | — | |
| keepdim | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |