Manuscript Offprint

arXiv:2610.22921

MaskMerge: Structure-aware Token Merging for Efficient Instance Segmentation

Bavesh Balaji, Letian Jiang, Alexander Wong, David Clausi, Sirisha Rambhatla

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Bavesh Balaji

University Of Waterloo

bbalaji@uwaterloo.ca

Letian Jiang

University Of Waterloo

1236jiang@uwaterloo.ca

Alexander Wong

University Of Waterloo

alexander.wong@uwaterloo.ca

David Clausi

University Of Waterloo

dclausi@uwaterloo.ca

Sirisha Rambhatla

University Of Waterloo

sirisha.rambhatla@uwaterloo.ca

Abstract

Token merging improves the efficiency of Vision Transformers by combining redundant tokens, but existing methods largely rely on feature similarity to determine which tokens to merge. This criterion is effective for semantic segmentation, yet can fail in instance segmentation, where adjacent objects of the same class often have highly similar features. We identify this failure mode as cross-instance token fusion. We introduce MaskMerge, an instance-aware token merging method that uses coarse intermediate mask predictions to constrain feature-based merging and preserve instance boundaries. We evaluate MaskMerge on two diverse instance segmentation domains characterized by high inter-instance visual similarity: PanNuke and iSAID. Against the SOTA token merging method ALGM, MaskMerge improves mAP from 30.1 to 32.1 on PanNuke while reducing computation from 229 to 153 GFLOPs and running 1.18×1.18\times faster, and from 33.1 to 36.2 on iSAID while reducing computation from 198 to 182 GFLOPs and running 1.23×1.23\times faster. Additionally, we also test it on Cityscapes and match ALGM's performance while using fewer FLOPs. The gains also transfer to an MAE-pretrained backbone, demonstrating that instance-aware merging enables more aggressive compression when appearance similarity alone cannot reliably preserve object identity.

1. Introduction

Vision Transformers (ViTs) have become powerful backbones for dense visual recognition, including semantic [49, 58, 63], instance [9, 21, 32], and panoptic segmentation [22]. Their ability to model long-range interactions enables strong spatial reasoning, but comes at a substantial computational cost: self-attention scales quadratically with the

Figure

Figure 1. Throughput–accuracy Pareto frontier on PanNuke [17] across ViT-S, ViT-B, and ViT-L backbones. MaskMerge consistently achieves a better accuracy–efficiency trade-off than ToMe [1] and ALGM [43] across model scales, indicating that instance-aware merging enables more aggressive token reduction while better preserving instance segmentation accuracy.

number of visual tokens [40, 60]. This cost is particularly pronounced in segmentation, where high-resolution inputs are required to preserve fine spatial detail [38, 43]. At the same time, dense ViT representations contain considerable redundancy, motivating a growing body of work on reducing the number of tokens processed by the network [10].

Existing token reduction methods broadly fall into pruning, halting, and merging approaches. Token pruning removes representations deemed uninformative, but permanently discarding spatial locations can be undesirable for dense prediction [14, 26, 48, 52, 61, 61]. Token halting reduces computation by terminating selected tokens at inter-mediate layers [13, 33, 50], but requires recovering their spatial information downstream. Token merging instead combines redundant tokens while maintaining a correspondence to the original spatial support, making it particularly attractive for segmentation [1, 24, 38, 43, 46]. Methods such as ToMe [1] and ALGM [43] have demonstrated that substantial computation can be removed with little or even no degradation on semantic segmentation.

A central assumption underlying most existing token merging methods is that feature similarity is a reliable proxy for merge compatibility [1, 42, 43]. Tokens with high cosine similarity are treated as redundant and are therefore natural candidates for aggregation. For semantic segmentation, this assumption is often well aligned with the task: neighboring regions representing the same semantic category should receive the same prediction, and merging similar features within such regions is generally benign.

The same assumption becomes considerably less reliable for instance segmentation specifically for homogeneous data. Here, the model must not only recognize what is present, but also preserve which object each spatial location belongs to [31]. Adjacent instances of the same category can have extremely similar visual representations despite requiring different output masks. Two neighboring nuclei in a histopathology image [17] or vehicles parked side-by-side in an aerial image [62] may therefore be highly similar in feature space while belonging to different instances. A similarity-only merge criterion may consequently aggregate tokens across instance boundaries, as shown in Fig. 2a, a failure mode we term cross-instance token fusion. Fig. 2b quantifies this effect: at the same merge budget, MaskMerge reduces cross-instance merges by 5.7×5.7 \times and 2.9×2.9 \times on PanNuke and iSAID respectively in comparison to ALGM [43]. This shows that feature similarity alone is insufficient to determine whether two tokens are safe to merge for an instance-level task, motivating the use of predicted instance structure to enable both safer and more aggressive token reduction.

Further, cross-instance token fusion affects not only accuracy, but also the attainable efficiency. Increasing the merge rate of a similarity-based method eventually introduces more erroneous cross-instance merges, forcing it to retain additional tokens to preserve segmentation quality. A safer merge criterion can instead support more aggressive compression without destroying instance boundaries. Thus, instance awareness offers a dual benefit: it preserves object identity while enabling greater inference throughput.

These insights motivate MaskMerge, an instance-aware token merging framework that incorporates predicted mask structure directly into the merge decision. Modern query-based segmentation models [8, 9, 21] progressively form object-specific representations throughout the network. MaskMerge exploits this intermediate structure rather than introducing an independent grouping mechanism. At an early stage of the encoder, a lightweight mask prediction operation combines the current object queries with the visual tokens to obtain coarse instance masks. These masks provide an inexpensive estimate of the instance assignment of each token. During subsequent token merging, MaskMerge restricts candidate matches to tokens assigned to the same predicted mask before selecting merges according to feature similarity. The resulting operation retains the efficiency and simplicity of similarity-based token merging while substantially reducing opportunities for cross-instance fusion.

We evaluate this distinction in two complementary domains where visually homogeneous instances make appearance-only merging particularly challenging: PanNuke [17] for nuclei instance segmentation and iSAID [62] for aerial instance segmentation. Across these domains, the instance constraint enables MaskMerge to operate at substantially more aggressive compression levels without incurring the degradation observed with similarity-only merging. On PanNuke, MaskMerge reaches 32.1 mAP, compared with 30.1 mAP for ALGM [43], while reducing computation from 229 to 153 GFLOPs and increasing throughput from 121.5 to 142.8 images/s. On iSAID, it improves mAP from 33.1 to 36.2, while reducing computation from 198 to 182 GFLOPs and increasing throughput from 168.8 to 206.9 tiles/s. Additionally, to test MaskMerge on real-world data, we ran ALGM and Maskmerge on Cityscapes, both methods achieve 19.8 AP, but MaskMerge requires only 298 GFLOPs compared with 347 GFLOPs. MaskMerge outperforms ALGM [1] and ToMe [1] across different backbone scales on PanNuke as shown in Fig. 1, demonstrating a better accuracy-throughput tradeoff than cosine methods. Moreover, the benefit is not tied to a single initialization: replacing the standard backbone with an MAE-pretrained variant on PanNuke preserves the advantage, with MaskMerge obtaining 34.0 mAP compared with 32.0 mAP for Compact ALGM.

Together, these results suggest a broader principle for efficient instance-level recognition: visual redundancy and task-level redundancy are not equivalent. Two tokens may be nearly indistinguishable in appearance yet encode different information for an instance segmentation objective. Efficient token reduction should therefore consider not only how similar two representations are, but also whether the task permits them to share a representation. MaskMerge provides a lightweight realization of this principle by using the model's emerging instance structure to guide token aggregation.

Our contributions are threefold:

• We identify and characterize cross-instance token fusion, a failure mode of similarity-based token merging in instance segmentation. Through per-instance analysis, we show that its impact is concentrated in crowded re-

Cross-instance token fusion: cosine merges across nuclei; MaskMerge stays within

ALGM (cosine similarity)

MaskMerge (ours)

Figure

GT nucleus (instance)

cross-instance merge — wrong

within-instance merge — safe

Figure

(a) Qualitative viz. of cross-instance token fusion in ALGM.

MaskMerge makes far fewer cross-instance merges, at the same token budget → better performance

Figure

(b) Cross-instance merge rate at a matched token budget.

Figure 2. Cross-instance token fusion in similarity-based token merging. (a) ALGM frequently merges tokens across different nuclei instances, whereas MaskMerge constrains merges within predicted instances. (b) At the same merge budget, ALGM produces 5.7×5.7\times and 2.9×2.9\times more cross-instance merges than MaskMerge on PanNuke [17] and iSAID [62], respectively, demonstrating that instance-aware constraints enable safer token reduction.

gions containing adjacent, visually similar instances.

• We introduce MaskMerge, an instance-aware token merging method that uses intermediate coarse masks to constrain feature-based aggregation. MaskMerge exploits structural information already present in the segmentation model and requires neither additional supervision nor an auxiliary training objective.

• We demonstrate a consistently improved accuracy–efficiency trade-off across three distinct instance segmentation domains. MaskMerge outperforms similarity-based ALGM on PanNuke and iSAID and matches its accuracy on Cityscapes at substantially lower computation. The improvement also transfers to a backbone with a different pre-training strategy, supporting the robustness of the proposed merge criterion.

References (66)