Nodes/ComfyUI-UtilsCollection/Load SAM 3.1 Checkpoint
ComfyUI Node

Load SAM 3.1 Checkpoint

The loader that stops SAM from silently breaking

By silveroxides·Created 3 months ago·Updated about 17 hours ago· 30
Load SAM 3.1 Checkpoint
    • model
    • clip
    • vae
    ckpt_name
    precisionfp32

    SAM is the model that turned "mask that object" into typing a phrase and getting a perfect cutout. SAM 3 folded text-prompted concept segmentation into the model itself - no more GroundingDINO-plus-SAM dance - and SAM 3.1 is the refinement of that line. But SAM has one notorious weakness: it's picky about precision. Downcast its weights to fp16 or bf16 and the masks come back subtly wrong - edges sag, regions merge, and nothing in the UI tells you why. This loader exists so that stops happening.

    It loads a SAM 3.1 checkpoint from your checkpoints folder and, by default, forces fp32 on both the model and its text encoder, preventing ComfyUI Core from downcasting them in the name of VRAM savings. It's a boring fix for a frustrating failure mode, and it's exactly the kind of thing you don't notice until you've spent an afternoon chasing bad masks.

    How it works

    ckpt_name is a dropdown of everything in models/checkpoints - drop your SAM 3.1 checkpoint there and it appears. The precision control is where the value lives:

    • fp32 (default) - forces full precision on the model and text-encoder weights. This is the "correct masks" setting, at the cost of more VRAM.
    • auto - lets Core decide, which means it may downcast. Lower VRAM, riskier masks.

    The node returns the standard checkpoint trio: model, clip, and vae. The clip is the text encoder that turns "her left hand" into a concept prompt; the vae handles encoding/decoding when you route SAM's output through image-space tools. Wire the model into your SAM 3.1 mask-generation node.

    The wider context

    SAM masks feed everything downstream that cares about region - inpainting, regional prompting, compositing, the detail loops from the KB's masking-and-detection playbook. That's why the loader matters beyond the load step: a mask generator is the front end of your whole targeted-edit pipeline, and precision problems there corrupt every step after it.

    Two real-world caveats worth carrying in. First, fp32 is heavier: on a tight card, auto may be the only thing that fits, and the trade is knowing your masks might degrade. Second, SAM 3-family nodes can carry a Triton dependency that's a genuine obstacle on Windows - if your mask-generation node itself won't start, that's often the culprit, not this loader.

    Install

    Install the pack, restart, put the SAM 3.1 checkpoint in models/checkpoints, and load it:

    cd ComfyUI/custom_nodes
    git clone https://github.com/silveroxides/ComfyUI-UtilsCollection
    

    Then just pick the checkpoint and leave precision on fp32. If your masks start looking wrong after a ComfyUI update, check whether something is silently forcing auto - that's the number one SAM debugging story, and this node is built to prevent it.

    Categoryadvanced/model

    Inputs (2)

    NameTypeDefaultDescription
    ckpt_nameCOMBOSAM 3.1 checkpoint from the checkpoints folder.
    precisionCOMBOfp32fp32 prevents Core from downcasting model and text-encoder weights.

    Outputs (3)

    NameTypeDescription
    modelMODEL
    clipCLIP
    vaeVAE