Pt Le
The ≤ comparison that turns numbers into masks
- tens_a
- tens_b
- TENSOR
"Le" is PyTorch's name for less-than-or-equal, and that's precisely what this node does: compare two tensors element-by-element and hand you a boolean tensor that's True wherever the first is ≤ the second. It's the least glamorous node in the pack and one of the more useful, because comparisons are how you turn raw numbers into decisions without writing a line of Python.
How it works
Mechanically there's nothing to it - torch.le(tens_a, tens_b), one line, both inputs are the pack's TENSOR type, output is a single TENSOR of booleans. Both inputs are required and there are no knobs to set. PyTorch's broadcasting rules apply, so tens_b can be a smaller tensor or even a 1-element scalar tensor and the comparison still works across the shape of tens_a.
Where you'll use it
Anywhere you need "is this under a threshold" as data. The classic chain in this pack: run a comparison like Pt Le, combine the result with a Pt Logical And/Or node, then feed the mask into Pt Masked Select to pull out just the elements that passed. That's your conditional logic - filtering high-loss samples, thresholding attention scores, slicing a dataset by a cutoff. It's also how you'd build the boolean gates that the pack's Transformer-from-scratch example relies on.
The one gotcha
The output is a torch.bool tensor, which is exactly right for masks and logical nodes but wrong for anything that wants to multiply or add. Trying to use booleans in a float math op will error or silently coerce. If you need the mask as numbers, cast it with a conversion node before wiring it into arithmetic - you can't throw it straight into Pt Mul. It's a two-second fix once you know to look for it.
Installing
Pt Le rides in the HowToSD/ComfyUI-Pt-Wrapper pack, showing up under the "Data Analysis" menu. Install the pack and you get all ~200 nodes, this one included. Easiest: ComfyUI Manager → search ComfyUI-Pt-Wrapper → Install → restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
The pack's requirements.txt pulls in heavy training dependencies (transformers, peft, accelerate…), but a comparison node needs only PyTorch, which you already have. Skip the pip line for math-only usage and just restart. No models to download.
Last thing, and it's true for every node here: the pack's TENSOR type isn't ComfyUI's IMAGE or LATENT. Bring images in via Pt From Image (Pt From Image Transpose for (b, c, h, w)), send them back with Pt To Image.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |