Pt To Int16
The dtype cast for when float32 feels like overkill
- tens_a
- TENSOR
Pt To Int16 converts a tensor to signed 16-bit integers. It's a pure dtype cast: same shape, same layout, new type. In the ComfyUI-Pt-Wrapper graph this is part of the "Data Analysis" category, and it exists because when you're shuffling tensors between nodes you'll occasionally need a specific integer width and PyTorch won't just read your mind.
The honest use cases are narrower than the name suggests. int16 is common in audio and sensor data, and if you're doing signal-style math in the graph it's the natural landing zone. It also shrinks memory versus float32 - useful when you're about to push a big tensor through a bottleneck. But let's be clear about the beginner trap that trips up half the people who reach for this node: casting a float tensor that lives in the 0-to-1 range to any int type gives you mostly zeros. Truncation rounds toward zero, so 0.0–0.99 all become 0. If you're converting image data, you need to scale to 0–255 first, not cast raw normalized floats.
One input (tens_a, a TENSOR), one output (TENSOR). Internally it's a one-liner: tens_a.to(torch.int16). It sits alongside the pack's other casts - PtToInt32, PtToInt64, PtToUint8, and the float variants - and they all share the same pattern, so learning one teaches you the family.
Install
ComfyUI Manager, search "ComfyUI-Pt-Wrapper", install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Then restart ComfyUI. Dependencies are the full Hugging Face stack (transformers, datasets, peft, accelerate, plus scikit-learn, pandas, seaborn, matplotlib, gensim, sentencepiece), so the first start after install is slow. No checkpoints to download.
Common issues
Watch for silent data loss. int16 has a range of −32,768 to 32,767; anything outside wraps or saturates depending on the context, and PyTorch's float-to-int cast truncates toward zero. If your outputs look wrong after a cast, don't assume the cast is the villain - it did exactly what you asked. Check whether you meant to round first, or whether you actually wanted int32/int64 and grabbed int16 out of habit.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |