ComfyUI Node

Pt Int Create

Type some integers, get a tensor back

By HowToSD·Created about a year ago·Updated about a year ago· 7
Pt Int Create
    • TENSOR
    data

    The name is the whole job: you type integers into a text box, and out comes an int32 PyTorch tensor. If that sounds almost too basic to be worth a node, remember where you are - this pack builds entire models without Python, which means every literal value in your workflow has to arrive as a tensor somehow. Pt Int Create is the faucet for integer data.

    How it works

    The single input, data, is a multiline text field. The node runs the string through Python's ast.literal_eval to turn it into a list, then torch.tensor(list_data, dtype=torch.int32). Because it's literal-eval, you're writing actual Python list syntax: [1, 2, 3] for a 1D tensor, or [[1, 2], [3, 4]] for 2D. Multiline just means you can lay out a bigger matrix comfortably instead of cramming it on one line.

    What you'll actually do with it

    The obvious use is feeding class labels or token IDs into the pack's training pipelines - the Transformer text-classification example, for instance, wants integer tensors for its inputs and targets. But it's also just the general "make me a tensor of constants" node. Want a vector of weights? A grid of coordinates? An index list for Pt Index Select? Type them in.

    The things that bite

    Two, mostly small. First, the parse is strict Python: 1, 2, 3 without brackets fails, and so does anything that isn't a valid literal. Second, it's int32, so values past about 2.1 billion overflow. For a tensor node, that's basically a non-issue - but if you're ever tempted to paste in huge IDs, know the ceiling is there.

    Installing

    Pt Int Create is one node inside the HowToSD/ComfyUI-Pt-Wrapper pack, which puts everything under the "Data Analysis" menu. Install the pack once and you get this plus ~200 siblings. ComfyUI Manager is the easy path: search ComfyUI-Pt-Wrapper, install, restart.

    Manual, same as always:

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

    The pack's requirements.txt is heavy (transformers, datasets, peft, accelerate…), but that's for the training/model side - this node just needs PyTorch, which ComfyUI already has. If you're only doing tensor math, you can skip the pip install and just restart. No model files to fetch.

    One reminder that applies to every node in this pack: its tensors use a custom TENSOR type, distinct from ComfyUI's IMAGE and LATENT. Convert images with Pt From Image (or Pt From Image Transpose for (b, c, h, w)), and back with Pt To Image. Until you do, the wires won't connect.

    CategoryData Analysis

    Inputs (1)

    NameTypeDefaultDescription
    dataSTRING

    Outputs (1)

    NameTypeDescription
    TENSORTENSOR