ToMeSD applies token merging to Stable Diffusion, speeding up image generation by merging redundant tokens inside the model — using nothing but pure Python and PyTorch. It is the official implementation of the paper “Token Merging for Fast Stable Diffusion” (CVPR 2023 workshop) and has about 1,400 stars on GitHub.
Diffusion models spend much of their compute processing tokens that carry nearly identical information, especially at high resolutions. Token merging (ToMe) reduces that waste by combining similar tokens before the heavy attention and MLP blocks and unmerging afterwards, so the model does less work per step with minimal visible quality loss. ToMeSD brings the technique to Stable Diffusion pipelines: you apply a patch to your existing pipeline, choose how aggressively to merge, and generation gets faster — the effect grows at larger image sizes, where redundancy is highest. Because it is implemented in pure Python and PyTorch, it drops into the diffusers-based workflows most Stable Diffusion users already have, with no custom kernels to compile. The repository includes examples and the reference code behind the paper, and it was last updated in late 2023.
ToMeSD is free and open source under the MIT license. There is nothing to purchase; you add the library to your Stable Diffusion setup and it pays you back in saved GPU time on every image.
Stable Diffusion users and developers generating images at scale or at high resolutions on limited hardware, who want a simple, well-understood speedup without retraining models or changing their pipeline.