ALGM: Adaptive Local-then-Global Token Merging for Efficient Semantic Segmentation with Plain Vision Transformers

Narges Norouzi, Svetlana Orlova, Daan de Geus, Gijs Dubbelman

Abstract

Vision Transformers (ViTs) have become a cornerstone of computer vision, yet their quadratic computational complexity poses a significant challenge for high-resolution tasks like semantic segmentation. This paper introduces ALGM (Adaptive Local-then-Global Merging), a novel, parameter-free token reduction strategy. ALGM strategically merges redundant tokens in two stages: locally in the initial layers to capture spatial redundancy and globally in the middle layers to address semantic redundancy. Experimental results across major benchmarks demonstrate that ALGM not only doubles throughput for large backbones but also enhances segmentation accuracy (mIoU) by up to 1.1 points, effectively breaking the traditional speed-accuracy trade-off.

Introduction

The computational cost of self-attention in Vision Transformers scales quadratically with the number of input tokens. For semantic segmentation, which requires high-resolution inputs to preserve fine spatial details, this "attention tax" creates a massive bottleneck. While existing methods attempt to mitigate this through pruning (discarding tokens) or merging (combining tokens), they often suffer from information loss or high computational overhead. Pruning is particularly detrimental to segmentation, as every pixel requires a final prediction. ALGM addresses these issues by providing an efficient, adaptive merging mechanism that preserves spatial information while significantly reducing the token count without requiring additional learnable parameters.

Methodology: Local-then-Global Merging

ALGM operates on the observation that token redundancy evolves through the network. Early layers exhibit high local redundancy (e.g., adjacent patches of sky), while deeper layers exhibit semantic redundancy (e.g., distant patches of the same object).

The ALGM architecture featuring two-stage token merging: Conditional Local Average Pooling (CLAP) and Global Bipartite Matching (GBM).

1. Conditional Local Average Pooling (CLAP)

In the first transformer layer, ALGM applies CLAP. It examines small $k \times k$ windows and merges tokens if their cosine similarity exceeds a calculated threshold. This effectively compresses uniform local regions like roads or clear skies into single representative tokens, capturing local redundancies early.

2. Global Bipartite Matching (GBM)

Halfway through the encoder, ALGM transitions to global merging. Using bipartite matching, it identifies and merges the most similar pairs of tokens across the entire image. This stage targets semantic redundancy, grouping disparate parts of large objects (e.g., different parts of a building) that have become similar in the feature space of the middle layers.

3. Adaptive Thresholding and Unmerging

Unlike fixed-rate reduction methods, ALGM is adaptive. It utilizes a similarity threshold $\tau$ derived from dataset statistics, allowing the model to compress simple scenes more aggressively while maintaining detail in complex ones. To ensure the decoder can produce a full-resolution segmentation map, a simple unmerging module duplicates merged tokens back to their original spatial indices.

Experimental Results

The authors evaluated ALGM on four major benchmarks: ADE20K, Cityscapes, Pascal Context, and COCO-Stuff-10K.

Performance comparison of ALGM against various baselines, showing simultaneous improvements in mIoU and throughput.

Efficiency and Accuracy Gains

On the ADE20K dataset, ALGM improved the throughput of standard baselines (Segmenter, SegViT, SETR) by an average of 39%. For the ViT-L backbone, throughput increased by up to 100%. Remarkably, ALGM often improved segmentation quality; for instance, it boosted the mIoU of Segmenter-S by +1.1 points while reducing GFLOPs by 32%. When applied to the massive EVA-02 backbone (1.0B parameters), ALGM improved throughput by 26% while maintaining state-of-the-art mIoU.

Denoising and Attention Balancing

The observed "accuracy bonus" is attributed to two factors: feature denoising and attention balancing. By merging redundant "easy" tokens (like background), the model's attention is no longer dominated by these frequent categories, allowing it to focus more effectively on rare or smaller objects.

Conclusion

ALGM presents a robust, parameter-free solution for accelerating Vision Transformers in semantic segmentation. By leveraging the evolving nature of token redundancy through a local-then-global approach, it achieves significant speedups without sacrificing—and often improving—model performance. While visual homogeneity in certain datasets like Cityscapes can limit efficiency gains, the method remains a powerful plug-and-play enhancement for plain ViT backbones.

Summary updated

BibTeX
@inproceedings{norouzi2024algm,
  author = {Narges Norouzi and Svetlana Orlova and Daan de Geus and Gijs Dubbelman},
  title = {{ALGM: Adaptive Local-then-Global Token Merging for Efficient Semantic Segmentation with Plain Vision Transformers}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
}
Figure