Pt Arange
Roll your own index and position tensors
- TENSOR
Every model built from scratch needs sequences of numbers at some point - positions for positional encodings, index ranges for gathering, evenly spaced values for sampling or schedules. Pt Arange is the node that makes them: it generates a tensor like [start, start+step, ...] up to (but not including) end, in whatever dtype you want.
It's the tensor-creation utility in ComfyUI-Pt-Wrapper (HowToSD's 200-node PyTorch pack, the spin-off of ComfyUI-Data-Analysis), and the README's from-scratch Transformer guide leans on it - positional encodings are typically built by arange-ing a position tensor and combining it with frequency terms. It's also how you produce the index vectors that feeding, gathering, and scatter operations consume.
How it works. Unusually for this pack, the three range values are strings, not numbers - you type them into text fields:
start- first value. Leave empty and it defaults to 0.end- the stopping point, exclusive. Required - an emptyendraises a "cannot be empty" error, which is the node's one sharp edge.step- the increment. Empty defaults to 1.
data_type is a dropdown with nine choices: float32, float16, bfloat16, float64, and the integer family uint8, int8, int16, int32, int64. So start=0, end=10, step=2, int32 gives [0, 2, 4, 6, 8], while start=0.0, end=1.0, step=0.25, float32 gives four evenly spaced floats. Output is a 1D TENSOR.
Why the string inputs, and why it matters. Because the values are parsed as text, you can type decimals without the node's INT widgets fighting you - that's the whole reason it exists as strings. The parse is smart about ints vs floats (a "." makes it a float). The price is that empty end errors hard, and a typo like 0..5 fails at runtime rather than in the UI.
Where you'll actually use it. Positional encoding construction is the flagship: arange a position sequence over your sequence length, then multiply/combine with frequency terms via the pack's math nodes. Also index building for gather/scatter, binning, and any "give me N evenly spaced values" need. One habit worth forming: since end is exclusive, arange(0, seq_len, 1) for a 512-length sequence uses end=512, not 511 - off-by-one errors here are silent and infuriating.
Install: ComfyUI Manager → "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
then restart. No model downloads; the pack's heavy requirements.txt is the only setup cost.
Troubleshooting: "Input string cannot be empty" - you left end blank; it's the one required field. Off-by-one output - end is exclusive; nudge it. Wrong dtype downstream - integer ops can't hold floats; pick the dtype that matches what's consuming the tensor. If output looks empty or absurd, check your step sign - a positive range with a negative step (or vice versa) returns an empty tensor.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| start | STRING | — | |
| end | STRING | — | |
| step | STRING | — | |
| data_type | COMBO | 9 options: float32, float16, bfloat16, float64, uint8, int8, +3 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |