ComfyUI Node

Pt Tan

Tangent of a tensor? It's a node, and here's when you'd actually use it

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

Pt Tan applies the trig function you last touched in a math class - tangent - to every element of a PyTorch tensor. One tensor in, one tensor out, nothing else. If you're scratching your head about why that exists as a node, you're not wrong to. It's an odd little utility. But it earns its place once you start building your own ML pipelines node-by-node inside ComfyUI instead of just generating images.

This node ships in ComfyUI-Pt-Wrapper, a ~200-node pack that turns PyTorch into a node graph: tensor math, datasets, dataloaders, optimizers, and full model training loops with zero Python. Pt Tan is one of the dozens of Pt-prefixed math operators (PtAdd, PtSin, PtSqrt, PtExp…) that let you manipulate tensors between the bigger steps. You reach for it when you're doing feature engineering on a tensor mid-pipeline, building a custom activation for a model you're assembling from layers, or just experimenting with what a transformation does to your data before it hits a training node.

How it works

Under the hood it's one line: torch.tan(tens_a), applied element-wise. Your input tensor goes in the tens_a input, and a new tensor of the same shape and dtype comes out the TENSOR output - the input is never modified. One thing the math classes warned you about is actually relevant here: tangent has asymptotes at every π/2 + kπ. Near those points the output doesn't gently grow, it explodes toward infinity. Feed it values near the asymptote and you'll get enormous numbers or NaN/inf flowing into whatever node is next, and it can be genuinely confusing to debug because your pipeline just silently stops being useful.

Inputs and outputs

The whole interface is:

  • tens_a (TENSOR) - the tensor to take the tangent of. Angles are interpreted in radians, matching PyTorch's convention.
  • TENSOR output - the element-wise tangent, same shape and dtype as the input.

Wire the output straight into another Pt math node, a PtShowText/PtShowSize debug node to inspect it, or a model input that expects a tensor.

Installing the pack

Install the whole pack once, then all 200 nodes (Pt Tan included) show up:

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

Restart ComfyUI. Easier route: open ComfyUI Manager, search "ComfyUI-Pt-Wrapper", hit install. It's on the Comfy Registry, so Manager finds it and pulls the dependencies for you. Those dependencies are the pack's real cost of entry - pandas, scikit-learn, transformers, sentencepiece, and friends. For a lone tensor node that's a lot of machinery, but Manager handles it in the background and it's a one-time install.

Common issues

  • NaN/inf outputs near asymptotes. Grounded in the math, not a bug. Clamp or filter your input, or use a bounded activation like PtTanh instead.
  • Pack not appearing after install. Confirm you don't have a second clone of the pack in custom_nodes, and that the restart actually reloaded. ComfyUI logs will show a ComfyUI-Pt-Wrapper import line if it loaded.
  • Type mismatches downstream. If the next node wants float32 and your tensor got cast to half somewhere, drop a PtToFloat32 in between.

It's a niche tool - most workflows will never need it. But if you're the person who finds yourself building a custom model in the graph, it's exactly the kind of building block you'd want.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
tens_aTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR