Pt Linspace
Evenly spaced numbers without typing them all
- TENSOR
torch.linspace is one of those functions you never think about until you need a smooth ramp of values, and then it's the only tool that fits. Pt Linspace brings it into the graph: you give it a start, an end, and how many points you want between them, and it builds the evenly spaced sequence as a tensor. No Python, no loops - that's the whole point of this pack.
How it works
The implementation is exactly torch.linspace(start, end, steps, dtype=...). The one wrinkle is that all three numbers arrive as text - start, end, and steps are STRING inputs, parsed to float/float/int inside the node. The data_type dropdown picks the output dtype from the full menu: float32, float16, bfloat16, float64, then the integer types (uint8, int8, int16, int32, int64).
Two things to internalize about linspace semantics:
stepsis a count, not a step size.start=0, end=10, steps=5gives you[0, 2.5, 5, 7.5, 10]- five points. If you're used torange(0, 10, 2), that's a different habit, and mixing them up is the most common source of confusion.- Endpoints are inclusive. Both
startandendappear in the output. That's unlike a lot of sequence functions and it catches people out.
Where it fits
Sweeps are the natural use - evenly spaced CFG values, temperature values, scale factors for a parameter study, all as a tensor you can iterate or slice. It's also handy for building coordinate grids and positional sequences, which is exactly the kind of thing you'd feed into the pack's model-building examples. If you want a ramp or a grid, this is the node.
Gotchas
The defaults are empty strings - all three numeric fields start blank, so the node errors until you type something in. Pick a float dtype unless you truly need integers: the even spacing gets truncated when you choose int8/int32, turning your smooth ramp into a staircase. And keep steps sane; a huge count is a huge tensor for no benefit.
Installing
Pt Linspace lives in the HowToSD/ComfyUI-Pt-Wrapper pack under the "Data Analysis" menu - one pack, ~200 nodes. 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 list is heavy (transformers, peft, accelerate, datasets…), but those exist for the training side. Sequence generation needs only PyTorch, which ComfyUI already ships - skip the pip install for math-only use and restart. No models to download.
Shared pack note: everything speaks the custom TENSOR type, not ComfyUI's IMAGE/LATENT. Convert with Pt From Image (Pt From Image Transpose for (b, c, h, w)), and back with Pt To Image.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| start | STRING | — | |
| end | STRING | — | |
| steps | STRING | — | |
| data_type | COMBO | 9 options: float32, float16, bfloat16, float64, uint8, int8, +3 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |