Token Merge with Attention (ToMA)
- The paper introduces two ToMA formulations: one for training-free semantic binding using unsupervised losses and one for efficiency via submodular token selection.
- The semantic-binding approach merges CLIP-tokenized prompt embeddings into composite tokens to ensure consistent cross-attention and correct attribute binding.
- The efficiency method leverages dense merge/unmerge operations and pattern reuse across diffusion layers to achieve a 20–25% speedup while preserving image quality.
Search arXiv for (Hu et al., 2024) and (Lu et al., 13 Sep 2025) and related ToMeSD/ToFu semantic binding/token merging diffusion papers. Token Merge with Attention (ToMA) denotes a token-aggregation paradigm for diffusion-based image generation that appears in two distinct but related formulations in the recent literature. In one formulation, ToMA is a reinterpretation of Token Merging (ToMe) for training-free semantic binding in text-to-image synthesis: subject, attribute, and sub-object tokens are merged into composite text tokens so that they share a single cross-attention map, with auxiliary unsupervised losses refining those composites during early denoising (Hu et al., 2024). In a second formulation, ToMA is an efficiency method for diffusion transformers: token reduction is recast as submodular selection plus attention-like merge/unmerge linear maps, with GPU-aligned matrix operations and pattern reuse across layers and timesteps to reduce generation latency while preserving image quality (Lu et al., 13 Sep 2025). The shared premise is that carefully structured token aggregation can alter the behavior of diffusion models without retraining, but the optimization target differs fundamentally between semantic correctness and computational efficiency.
1. Terminological scope and conceptual split
The term ToMA is not used for a single canonical algorithm across the supplied literature. One usage arises from a reinterpretation of ToMe as a “Token Merge with Attention” framework for semantic binding in text-to-image synthesis, while the later paper titled “ToMA: Token Merge with Attention for Image Generation with Diffusion Models” uses the same acronym for a latency-oriented token reduction method (Hu et al., 2024, Lu et al., 13 Sep 2025). This distinction is substantive rather than merely terminological.
| Usage | Primary objective | Core mechanism |
|---|---|---|
| ToMe reinterpreted as ToMA | Semantic binding in T2I | Merge subject+attribute text tokens into composite tokens; apply end-token substitution and two unsupervised losses |
| ToMA (2025) | Efficiency in diffusion models | Select diverse tokens by submodular optimization; merge/unmerge via dense matrix operations; reuse patterns across layers and timesteps |
In the semantic-binding setting, token merging acts on CLIP-tokenized text embeddings and modifies cross-attention conditioning. In the efficiency setting, token merging acts on transformer token features inside the diffusion model and reduces effective attention workload. A plausible implication is that both methods exploit redundancy in tokenized representations, but they do so for different failure modes: semantic misbinding in one case and quadratic attention complexity in the other.
2. Semantic-binding ToMA: prompt structure and composite token formation
In the semantic-binding formulation, the prompt after CLIP tokenization is written as
with embeddings
The prompt is assumed to describe main entities , each associated with a set of attribute or sub-object tokens
For each entity, the index set denotes the tokens corresponding to the -th noun and its attributes. The supplied example is “a cat wearing sunglasses and a dog with a hat,” with , , , and 0 (Hu et al., 2024).
To bind each subject 1 with its attributes 2, ToMA introduces a composite token 3 by merging the embeddings in 4:
5
In the simplest case,
6
All original tokens in 7 are then removed and replaced by the composite embedding sequence
8
The explicit motivation is semantic binding, defined as associating a given object with its attribute, termed attribute binding, or linking it to related sub-objects, termed object binding. The method is training-free and avoids full-model fine-tuning or externally specified layouts. Because the merged token stands in for an entire subject-attribute group, the method is designed to prevent the separate tokens from competing for inconsistent spatial assignments during generation.
3. Cross-attention integration and end-token substitution
In a standard diffusion U-Net at timestep 9, the flattened feature queries 0 attend to text keys
1
through
2
where 3. After merging, the textual key matrix becomes
4
Since
5
the new attention scores satisfy
6
After the softmax, the composite attention map 7 is therefore a weighted mixture of the original maps 8 for 9 (Hu et al., 2024).
The stated consequence is that the newly introduced token 0 “inherits” and consolidates the spatial focus of all constituent tokens, guaranteeing that the bound subject, attributes, and sub-objects now share a single cross-attention map. Within the paper’s framing, this is the mechanism by which semantic binding is enforced without retraining.
A complementary mechanism is End-Token Substitution (ETS). The motivation is that CLIP’s 1 tokens often accumulate global semantics and can re-introduce stray attributes. To remove this spurious coupling, the method replaces the original end-token embeddings with embeddings drawn from a “plain” prompt containing only the subjects 2:
3
The final textual condition is then
4
This isolates the subject set from residual prompt-wide semantics carried by repeated end tokens.
4. Training-free refinement, algorithmic workflow, and reported performance
During the first 5 timesteps of denoising, given as “e.g. 20% of 6 total,” the semantic-binding ToMA updates only the composite token embeddings via gradients on two unsupervised losses. The entropy regularization term encourages each composite token’s attention map to concentrate on a small region:
7
The semantic binding loss enforces that each 8 leads to the same denoising vector as the full prompt 9:
0
The combined objective is
1
A small number of gradient steps is taken on 2 before diffusion continues. No network weights are changed; only composite tokens are refined (Hu et al., 2024).
The pseudocode given in the summary is sequential. It tokenizes the prompt, parses it into 3 subject-plus-attribute groups 4, initializes each composite token by uniform averaging over its group, substitutes the original tokens with 5, replaces post-terminal 6 embeddings with 7 from a subjects-only prompt, forms the updated text matrix 8, initializes 9, and then denoises from 0 to 1. For 2, denoising proceeds normally; otherwise the method extracts 3 and 4, builds 5, computes 6 and 7, updates 8, re-assembles 9, and denoises with the updated condition.
The reported evaluation uses T2I-CompBench, specified as “300 prompts each for color, texture, shape attributes, measured by BLIP-VQA”; a GPT-4o object binding benchmark with “50 hard prompts of the form ‘an X with itemA and a Y with itemB,’ scored by GPT-4o”; and human-preference via ImageReward plus DetScore. The metrics listed are BLIP-VQA, GPT-4o binding accuracy, and human-preference. For base SDXL, the reported BLIP-VQA values are Baseline SDXL 0, Best prior (CoMat) 1, and ToMA (Ours) 2. The GPT-4o score is reported as 3 for ToMA versus 4 for SynGen, and human preference/ImageReward logits are reported to rise by 5 overall. Qualitative examples are described as showing perfect attribute placement, such as “cat wears glasses ○, dog wears hat ○,” with no cross-object leakage, including in multi-object, multi-attribute scenes. The summary concludes that the method achieves state-of-the-art semantic binding on both compositional benchmarks and open-ended GPT-4o object-binding tests.
5. Efficiency-oriented ToMA: submodular token selection and attention-like merge/unmerge
The 2025 ToMA paper addresses a different problem: scalability limits in diffusion models caused by transformers’ quadratic attention complexity. Its starting point is a set of token features 6 over a ground set
7
The goal is to select a smaller subset
8
or equivalently impose a budget 9 for reduction ratio 0. Selection is cast as maximizing a facility-location style submodular objective
1
with cosine similarity reported as giving the best empirical diversity, though an RBF or inner-product can also be used (Lu et al., 13 Sep 2025).
The paper adopts the classical greedy algorithm for monotone submodular maximization under a cardinality constraint: initialize 2, then repeatedly choose
3
where
4
The summary states the standard guarantee from Nemhauser et al. (1978): a 5 approximation to the optimal 6. Marginal-gain updates are accelerated by caching 7 for every 8, reducing each update to 9 time rather than recomputing from scratch.
After selection, each original token is assigned to its closest center,
0
which induces clusters
1
Merge is implemented by a dense matrix 2 with entries
3
For stacked token features 4, the merged representation is
5
Standard multihead attention is then applied on 6; for one head,
7
followed by
8
Unmerge is implemented via
9
with
0
Operationally, each original token copies the merged result of its cluster center.
The GPU-efficiency claim rests on representation rather than on token reduction alone. Merge and unmerge are both single dense GEMMs, 1 and 2, which the summary states can be fused into highly optimized kernels by cuBLAS and cuBLASLt. The paper explicitly contrasts this with ToMeSD and ToFu, which rely on sorting and scatter/gather-like operations.
6. Pattern reuse, complexity, empirical outcomes, and interpretive cautions
The efficiency-oriented ToMA further exploits latent locality and sequential redundancy. Within each transformer block, the assignment 3 is said to change little from layer to layer, so 4 and 5 can be reused across heads or entire blocks and recomputed only when the marginal gain of adding a new center exceeds a threshold 6. Across diffusion timesteps, the last timestep’s clustering is used as the initial seed for the next, providing a warm start and often avoiding any change. The summary describes this “pattern reuse” as making the expensive greedy selection, with cost roughly 7 per update, occur “very infrequently—typically once every 4–8 layers” (Lu et al., 13 Sep 2025).
The complexity accounting is explicit. Baseline full attention per layer is given as approximately 8 FLOPs. For ToMA, attention on merged tokens costs 9, while the two GEMMs contribute approximately 00 FLOPs, yielding
01
For the typical value 02, the summary computes
03
described as about a 04 baseline FLOPs. The paper’s central argument is that theoretical FLOPs alone are not decisive: the merged attention is on 05 rather than 06, the GEMMs are hardware-friendly, and submodular oracle calls are rare. The reported end-to-end GPU measurements with FlashAttention are that ToFu achieves only 07–08 latency reduction, whereas ToMA “consistently achieves 20–25% end-to-end speedup vs full FlashAttention.”
The headline empirical results are more specific. On Stable Diffusion XL (SDXL) 1.0, ToMA reduces single-image generation latency by 09; on Flux, it yields a 10 speedup. Across 11 ImageNet prompts, the reported DINO-CLIP similarity shift satisfies 12 relative to the full-token baseline, characterized as visually indistinguishable. Ablations over reduction ratio 13 report that quality is essentially flat up to 14, then degrades gracefully. Reclustering every layer versus every 15 layers versus every 16 layers is reported to show that 17–18 gives 19–20 speedup with no measurable quality loss. Visual examples are said to show that even at 21 token reduction, fine textures such as hair strands and foliage remain crisp, with only imperceptible blur in uniform backgrounds.
A recurrent source of confusion is to treat the two ToMA formulations as interchangeable. That would be inaccurate. The semantic-binding variant merges text tokens to enforce subject-attribute coherence and uses entropy plus semantic binding losses during early denoising. The efficiency variant merges internal transformer tokens to reduce latency and uses submodular selection, dense merge/unmerge maps, and reuse heuristics. This suggests a broader design space around token aggregation in diffusion models, but the supplied papers do not claim that the semantic-binding objective and the efficiency objective are the same problem, nor that one method subsumes the other.