ComfyUI Node

Pt Exp

Raise any tensor to e^x, one node at a time

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

Pt Exp is the ComfyUI-Pt-Wrapper node that applies the exponential function - e to the power of every element - across an entire tensor. It takes one tensor in, gives you one tensor out of the exact same shape, and doesn't ask any questions. If you've ever wanted to do real math on tensors inside a ComfyUI graph instead of fighting the sampler, this is one of the building blocks you'll grab.

The pack it ships in, ComfyUI-Pt-Wrapper, is Hide Inada's (HowToSD.com) attempt to bring actual PyTorch into the node graph - a spin-off of his earlier ComfyUI-Data-Analysis, with roughly 200 nodes covering tensor math, model building (ResNet, LSTM, GRU, Transformer), and full training loops, all no-code. Every tensor node here speaks a custom TENSOR wire type, which is just a raw torch.Tensor flowing between nodes. Pt Exp is squarely in the "tensor math" bucket.

What it actually does

Under the hood it's a one-liner: torch.exp(tens_a). Element-wise, fully differentiable, no configuration. You reach for it when you're hand-rolling math that PyTorch's higher-level nodes don't give you directly - decay curves, attention-style weighting, or undoing a log() you applied earlier. It's also the raw ingredient if you ever build softmax by hand: exp(x) / sum(exp(x)).

Honest take: for the softmax/attention patterns, you should usually reach for the pack's Ptf Softmax or Ptf Log Softmax nodes instead of hand-rolling with Pt Exp - they do the numerically stable version for you. Pt Exp earns its keep when you want the exponential itself: scaling activations, building schedules, or checking what a distribution looks like after exponentiation.

Inputs and outputs

The info_schema is refreshingly small:

  • tens_a - the input tensor. That's it.
  • Output: TENSOR, same shape as the input.

There's no dtype selector, no scale knob. What you put in is what you get out, just exponentiated.

Installing it

This is a Data Analysis category node from ComfyUI-Pt-Wrapper. Install the pack once via ComfyUI Manager (search "ComfyUI-Pt-Wrapper") or manually:

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

The README's requirements.txt lists a serious ML stack - pandas, seaborn, scikit-learn, transformers, datasets, gensim, peft, accelerate - but that's for the pack's training and text side. A node as simple as Pt Exp only needs torch, which ComfyUI already ships, so the heavy install cost is paid once at pack level, not per node.

Where people get burned

The classic mistake: feeding an integer tensor into it. torch.exp only works on floating-point tensors, and ComfyUI-Pt-Wrapper lets you build int tensors easily (say with Pt Full and data_type = int32). Feed an int in and you'll get a RuntimeError: "exp" not implemented for 'Long' - a genuinely unhelpful error message. If that happens, route the tensor through Pt To Float32 first.

The other edge case is overflow: exp(1000) is inf, no matter how patient you are. If your values are large and unsigned, subtract the max first - again, that's exactly what the stable softmax nodes do for you. Small, well-scaled tensors are this node's happy place.

CategoryData Analysis

Inputs (1)

NameTypeDefaultDescription
tens_aTENSOR

Outputs (1)

NameTypeDescription
TENSORTENSOR