ComfyUI Node

Pt Ne

The not-equal comparison node

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Ne
  • tens_a
  • tens_b
  • TENSOR

Pt Ne is the "not equal" comparison in the HowToSD/ComfyUI-Pt-Wrapper pack, wrapping torch.ne. Two tensors in, a boolean tensor out, True wherever the elements differ. The name comes straight from PyTorch's ne function, so don't go looking for a nicer word; the display name is just "Pt Ne". It's the odd one out in the comparison family (Pt Ge, Pt Gt, Pt Le, Pt Lt, Pt Eq) because "different" is often more useful than you'd think.

When it earns its keep

Spotting change is the classic job. Compare two tensors to find where they diverge - the output of a model before and after a tweak, or two runs of the same pipeline - and you get a mask of exactly which elements moved. In a training workflow you can compare predicted labels against ground truth to build a misclassification mask, then count the True values to get an error count without writing a single line of Python. Pair it with Pt Where to replace the differing elements with something else, or with Pt Logical Not to flip it into an "equal" mask. For a debugging session, "did anything change at all?" is a great early check, and sum() on the result tells you how much.

How it works

Element-wise != with standard broadcasting, done on the same device as the input tensors. Note that NaN never equals anything, not even itself, so NaN-heavy tensors will report everything as "not equal" - a real footgun if you're comparing intermediate results that contain NaNs. The output is a boolean tensor, which behaves as 1/0 in arithmetic, so it counts neatly.

The inputs

  • tens_a - first tensor.
  • tens_b - second tensor.

Single output: TENSOR of booleans. No other settings; this is one of the pack's simplest nodes.

Installing the pack

Pt Ne is part of the pack's "Data Analysis" category - the tensor-math half (the Ptn-* model/training nodes are under "Training"). Install via ComfyUI Manager by searching "ComfyUI-Pt-Wrapper", or:

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

Restart ComfyUI. The pack's requirements.txt pulls in transformers, datasets, peft, scikit-learn, gensim and more, so the first install is heavier than a comparison node deserves. No model files are needed for tensor ops.

Common issues

  • NaN surprise - NaN != NaN is True in PyTorch. If your tensor has NaNs, every one of them shows up as a mismatch even when both sides are identical. Clean the tensor first.
  • Dtype and shape - tensors must be broadcast-compatible; otherwise torch throws. When comparing across dtypes (float vs int), cast first so the comparison means what you think it means.
  • Boolean output - the result is bool, so route it through Pt To Float32 if a downstream node demands floats.
  • Small pack, small support - Pt-Wrapper is a single-author educational pack with almost no discussion on r/comfyui or r/StableDiffusion. The node reference docs and example workflows on the repo are your real support; there's no bustling community to lean on.
CategoryData Analysis

Inputs (2)

NameTypeDefaultDescription
tens_aTENSOR
tens_bTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR