Nodes/comfyui-mask-util/Model Change Device &Repeaters
ComfyUI Node

Model Change Device &Repeaters

The Device-Switch Node You Can Actually Wire Into Your Graph

By longgui0318·Created 3 years ago·Updated about a year ago· 8
Model Change Device &Repeaters
  • sam_model
  • grounding_dino_model
  • model
  • clip
  • vae
  • pipeline
  • control_net
  • trigger_condition_image
  • trigger_condition_mask
  • trigger_condition_latent
  • image
  • mask
  • latent
  • text
  • seed
device
trigger_condition_text
trigger_condition_seed0

This is the same relocation logic as the plain Model Change Device node - move your model, CLIP, VAE, ControlNet, SAM model, GroundingDINO model, or generic pipeline object to a chosen device - but built to actually sit inline in your graph rather than dangle off to the side. The plain version has no outputs and is forced to run via an internal flag; this one has real outputs, which means you can wire it directly into your data flow the normal way, no special-casing required.

The required input is device, the pack's usual five-choice dropdown (default, cpu, cuda, cuda:0, cuda:1). The optional inputs mirror Model Change Device exactly: sam_model, grounding_dino_model, model, clip, vae, pipeline, control_net for the things you actually want relocated, plus five trigger_condition_* slots - trigger_condition_image, trigger_condition_mask, trigger_condition_latent, trigger_condition_text, trigger_condition_seed. Here's the difference that makes this the more useful node for most graphs: those trigger inputs have matching outputs - image, mask, latent, text, seed - that pass the values back out. Reading the shape of it, this looks built as an execution-order tool: feed a value your downstream nodes actually depend on through the matching trigger slot, get the same value back out the other side, and now anything consuming that output can only run after this node - and its device switch - has completed. It's the standard ComfyUI trick for forcing sequencing without a dedicated "wait for" primitive, just packaged here alongside the device-move logic instead of as a separate pass-through node. Worth flagging that this is an informed read of the schema rather than something the (essentially empty) README confirms outright.

If you don't need that sequencing guarantee - if your graph's natural data dependencies already ensure the device switch happens before it matters - the plain Model Change Device node is simpler and does the same relocation. Reach for the Repeaters version specifically when you need to guarantee ordering: a SAM model and GroundingDINO model pair (the standard text-prompted segmentation combo, the same detector family behind tools like Impact Pack's SAM detector provider) that must be on the right device before a detection step fires, for instance.

Installing it: comfyui-mask-util is a small utility pack by longgui0318, better known for comfyui-magic-clothing, a virtual-try-on node wrapper that had a brief spike of Reddit attention in 2024 and has gone quiet since. This pack reads as general device/dtype/crop glue split out of that project. The GitHub README is just the repo title, nothing further - everything above comes from the node's own definition.

Install via ComfyUI Manager (search "comfyui-mask-util") or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/longgui0318/comfyui-mask-util

Restart ComfyUI. No model downloads - it relocates models you already have, it doesn't fetch new ones.

Where it bites: if you don't actually wire a trigger input through and back out, you lose the ordering guarantee that's this node's whole reason for existing over the plain version - an unconnected trigger slot doesn't force anything. Relocating a full diffusion model repeatedly (rather than once, up front) costs real time over PCIe, so don't drop this into a loop expecting the device move to be free on every iteration. And as with the plain version, requesting a GPU index you don't actually have will error rather than fall back quietly.

Categorymodel

Inputs (13)

NameTypeDefaultDescription
deviceCOMBO5 options: default, cpu, cuda, cuda:0, cuda:1
sam_modeloptSAM_MODEL
grounding_dino_modeloptGROUNDING_DINO_MODEL
modeloptMODEL
clipoptCLIP
vaeoptVAE
pipelineoptPIPELINE
control_netoptCONTROL_NET
trigger_condition_imageoptIMAGE
trigger_condition_maskoptMASK
trigger_condition_latentoptLATENT
trigger_condition_textoptSTRING
trigger_condition_seedoptINT0

Outputs (5)

NameTypeDescription
imageIMAGE
maskMASK
latentLATENT
textSTRING
seedINT