ComfyUI Node

Pt Min

The min along a dimension, values only

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Min
  • tens
  • TENSOR
dim
keepdimfalse

The mirror image of Pt Max: Pt Min computes the minimum along a dimension and returns only the values, via torch.amin. It's the node for "what's the worst case here" - lowest score, smallest activation, bottom of the range - and combined with Pt Max it gives you the full span of any tensor.

How it works

Identical input layout to its reduction siblings:

  • tens - the TENSOR.
  • dim - a STRING (multiline) taking 0, [0], or (1, 2). Multi-axis reduction supported; empty means the global min.
  • keepdim - boolean, default off.

Implementation is torch.amin(tens, dim=dim, keepdim=keepdim), and like Pt Max it's values only - no argmin indices. If you need to know which element was the minimum, this node won't tell you.

keepdim, in short

With keepdim=True, a (b, c, h, w) tensor reduced over (2, 3) becomes (b, c, 1, 1), still broadcastable against the original. That matters when the min feeds back into a computation with the source tensor - say, range-normalizing or offsetting - because the shapes still line up. Off gives you a tighter (b, c) but you lose that property. If in doubt and the min is going to be combined with the original tensor, keep it on.

Where it fits

Min-pooling is the obvious use, though it's rarer than max-pooling in practice - max picks the strongest signal, min picks the weakest, and most architectures want the former. Where min earns its keep is diagnostics and range math: with Pt Max you can compute a tensor's full range, or normalize a tensor to [0, 1] by subtracting min and dividing by (max − min). That's a two-step normalization and this node is half of it.

Gotchas

Values only, no indices. dim parses as Python, so keep it clean. Output preserves the input dtype.

Installing

Pt Min ships in the HowToSD/ComfyUI-Pt-Wrapper pack under "Data Analysis." ComfyUI Manager: search ComfyUI-Pt-Wrapper, install, restart. Manual:

cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper

The heavy requirements (transformers, peft, accelerate…) are for training; min needs only PyTorch, already present. Skip the pip line for math-only work. No models to download.

Pack-wide: the TENSOR type isn't ComfyUI's IMAGE/LATENT - convert with Pt From Image (Pt From Image Transpose for (b, c, h, w)) and Pt To Image.

CategoryData Analysis

Inputs (3)

NameTypeDefaultDescription
tensTENSOR
dimSTRING
keepdimBOOLEANfalse

Outputs (1)

NameTypeDescription
TENSORTENSOR