Nodes/ComfyUI_agilly1989_motorway/TomePatchModel_motorway_edition
ComfyUI Node

TomePatchModel_motorway_edition

Free VRAM and speed by merging tokens

By agilly1989·Created 2 years ago·Updated about a year ago· 7
TomePatchModel_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_model_keymodel
ratio0.30
OUTPUT_MODEL_keyMODEL

ToMe - Token Merging - is a free-ish lunch in diffusion. It works by noticing that in an image, huge numbers of nearby patches look alike, and merging those redundant tokens before they go through the transformer blocks. Fewer tokens, less compute, same-looking picture. TomePatchModel is the ComfyUI node that patches a model with ToMe, and this is the Motorway edition: it pulls the model from the pipe by key and writes the patched model back.

The honest framing: this is the one motorway-ed node here I'd actually reach for outside the pack's own world. A ratio of 0.3 means roughly 30% of tokens get merged each block - real speedup and real VRAM relief on big models, at the cost of a little fine detail. It's not magic and it's not free at high ratios, but as a "my image won't fit on this card" lever it's far more practical than dropping your whole workflow to a smaller checkpoint.

What to set

  • INPUT_model_key (default model) - the Motorway key holding the MODEL to patch.
  • ratio (default 0.3, 0–1) - the fraction of tokens merged. 0.2–0.3 is the sweet spot; above 0.5 you're trading visible detail for speed.
  • OUTPUT_MODEL_key (default MODEL) - where the patched model is written.

Output is the MOTORWAY with the patched MODEL stored. Use it anywhere you'd use the original model - it's a drop-in replacement for the sampler.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart; it's under agilly1989 Nodes → Motorway-ed → model_patches → unet. ComfyUI Manager installs the pack too. No pip dependencies - the wrapper calls ComfyUI's own ToMe patch logic.

Where people get burned

Ratio creep. It's tempting to push ratio to 0.6 and watch the timer drop, but past a point you're not merging redundant tokens anymore - you're merging genuinely different ones, and the image gets soft and smeary in high-detail areas. Start at 0.3 and only bump it if the speedup matters more than the detail.

Also, ToMe patches some models better than others; on heavily compressed or already-fast models the win is small, so don't expect the same speedup everywhere. The Motorway side is the standard trap: keys are case-sensitive and exact, and 'MotorwayClass' object has no attribute 'hash_' means the model key isn't in the pipe. Beta pack, motorway-ed nodes come and go across releases - a vanishing node after an update is upstream churn, not a broken install.

Categoryagilly1989 Nodes/Motorway-ed/model_patches/unet

Inputs (4)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_model_keySTRINGmodel
ratioFLOAT0.300–1
OUTPUT_MODEL_keySTRINGMODEL

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨