arXiv:2610.21642cs.CVOct 2026

Manuscript Offprint

arXiv:2610.21642

SCMerge: Spatial-Consistency-Aware Token Pair Merging for Efficient Semantic Segmentation

Junfeng Ren, Yi Gong, Yuan Zeng

Abstract

Vision Transformer architectures have showcased impressive performance on semantic segmentation, yet their quadratic attention complexity hinders practical applications. Recent works have focused on merging tokens to reduce sequence length and thus improve transformer efficiency. However, existing token merging methods primarily rely on feature similarity to identify similar tokens, overlooking spatial consistency, which may introduce segmentation errors in semantic segmentation. In this work, we propose SCMerge, a training-free token merging method that jointly considers feature similarity and spatial consistency in pairing similar tokens. The pairwise tokens are then merged within the encoder, and the resulting token sequences are reconstructed onto the original patch grid after decoding. The proposed method is flexible and can be plugged into existing vision Transformer-based semantic segmentation pipelines. Extensive experiments on the benchmark datasets ADE20K, Pascal Context, and Cityscapes show that SCMerge consistently achieves a better trade-off between segmentation accuracy and efficiency than baseline methods.

1. Introduction

Semantic segmentation has made significant progress with the recent introduction of Vision Transformers (ViTs) [8, 24, 29, 37]. However, ViTs with self-attention suffer from quadratic computational complexity and long latency, limiting their application to high-resolution images. A primary avenue for addressing this issue is to reduce token sequence length in self-attention and streamline computation [1, 17, 23, 25, 28, 30, 36]. Although most existing token reduction methods work well for image classification, they often struggle in dense prediction tasks, such as semantic segmentation. The main challenge is to reduce the token sequence length while preserving the spatial and semantic details required by the segmentation decoder.

This work focuses on ViT-based semantic segmentation and aims to present a training-free token merging method to improve the efficiency of existing pipelines. Existing training-free token reduction methods have shown that merging similar tokens can effectively reduce the token sequence length and computational complexity. ToMe performs bipartite matching in feature space and merges similar tokens via averaging [1]. Mutual Pair Merging (MPM) employs mutual nearest-neighbor matching and combines the matched tokens, yielding computation and latency improvements without modifying segmentation decoders [26]. In addition, ALGM employs a segmentation-specific local-to-global merging schedule that combines local and global token matching [22]. Despite their potential, existing methods mainly match tokens based on feature similarity, which can cause segmentation errors when local feature content is similar but the tokens are spatially or globally different. Tokens near semantic boundaries may be incorrectly paired with interior tokens from neighboring regions, leading to boundary blurring. In addition, interior tokens from different objects can have similar features and be mistakenly identified as redundant. More recently, several works [13, 19] have proposed to address this issue by introducing spatial information or learned policies, but at the cost of additional inputs or training.

In this paper, we propose SCMerge, a training-free token merging method to reduce the token length in ViT-based semantic segmentation pipelines, aiming to achieve a better trade-off between segmentation accuracy and computational cost. To guide the merging process, We introduce a token-pairing criterion that jointly considers local feature similarity and spatial consistency. By merging only tokens that are similar in both feature and spatial consistency, this mechanism improves the efficiency–accuracy trade-off. Specifically, we first compute the cosine similarity between all token pairs. A local variance measure is then used to identify tokens that are near semantic boundaries or lie in a smooth interior region. For each candidate pair, we compute a spatial-consistency penalty that discourages merging of locally similar but boundary-sensitive tokens, as well as tokens belonging to different objects. Finally, paired tokens are merged via feature averaging, and the reduced token sequence is passed through the segmentation decoder before being mapped back to the original token grid. This design refines the token pairing process to preserve semantic boundaries and neighborhood spatial consistency, improving segmentation efficiency.

Our SCMerge does not require additional supervision, extra input modalities, or modifications to the segmentation head, allowing it to be plugged into ViT-based semantic segmentation pipelines. We evaluate the effectiveness of the proposed token merging module using ViT-based segmentation models [29] on three semantic segmentation datasets, including ADE20K [38], Pascal Context [21], and Cityscapes [5]. Experimental results demonstrate that plugging our SCMerge module into ViT-based semantic segmentation models improves the trade-off between computational complexity and segmentation accuracy. Our contributions can be summarized as follows:

• We propose a novel training-free token-pair merging method that incorporates a spatial-consistency penalty into feature-similarity-based matching. This method prevents the merging of locally similar but spatially incompatible tokens and improving the accuracy–efficiency trade-off.

• We design a local feature variation metric to identify boundary-sensitive tokens and introduce a spatial-consistency penalty, comprising a boundary-sensitive term and a neighborhood consistency term, to reduce incorrect merging near semantic boundaries and preserve fine spatial detail.

• Extensive experiments demonstrate that our method can be integrated into ViT-based semantic segmentation models to achieve a better accuracy-efficiency trade-off than baseline methods relying only on feature similarity.

References (38)