Back to paper library
arXiv 2025CVPR 2025SegmentationPaper notes

EdgeTAM

Remember the Gist

Original paper

EdgeTAM: On-Device Track Anything Model

Paper authors

Chong Zhou · Chenchen Zhu · Yunyang Xiong …

Show all 11 authors

Chong Zhou · Chenchen Zhu · Yunyang Xiong · Saksham Suri · Fanyi Xiao · Lemeng Wu · Raghuraman Krishnamoorthi · Bo Dai · Chen Change Loy · Vikas Chandra · Bilge Soran

Publication
CVPR 2025Conference
First submitted to arXiv
arXiv:2501.07256
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{segmentationedgetam2025,
  title = {{EdgeTAM: On-Device Track Anything Model}},
  author = {Chong Zhou and Chenchen Zhu and Yunyang Xiong and Saksham Suri and Fanyi Xiao and Lemeng Wu and Raghuraman Krishnamoorthi and Bo Dai and Chen Change Loy and Vikas Chandra and Bilge Soran},
  year = {2025},
  eprint = {2501.07256},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2501.07256}
}
On this page

SAM 2 brought SAM from images into video. Click once on any frame and the model follows that object all the way through, picking it back up after occlusions or when it disappears and reappears. It relies on a memory bank that stores features from the past few frames and consults them when processing each new frame.

The mechanism works well, but it's expensive. The authors converted the smallest SAM 2 to CoreML and ran it on an iPhone 15 Pro Max, where it could process only about 1 frame per second.

The acceleration methods of the SAM generation, such as MobileSAM, EfficientSAM and EdgeSAM, all worked in roughly the same way, replacing the heavy image encoder with a small model, since SAM's decoder was light to begin with. This time Chong Zhou, the author of EdgeSAM, was interning at Meta Reality Labs and looked at SAM 2 together with Yunyang Xiong of EfficientSAM and others, and they found that the same trick no longer works so well on video.

Defining the Problem

Original Figure 2: two bar charts of per-frame latency on an iPhone (ms). The left chart (a) compares image encoders, each bar split into backbone (dark) and decoder (light): HieraB+ takes about 1,500 ms, half of it backbone; switching to HieraT, ViT-S, ViT-T and RepViT-M1 makes the backbone shorter and shorter until RepViT-M1's is almost invisible, but the light decoder part stays at about 750 ms throughout. The right chart (b) breaks down SAM 2's components: 4 layers of memory attention take about 750 ms, 2 layers about 400 and 1 layer about 200; removing self-attention or the FFN still leaves about 200 ms, while removing cross-attention leaves only about 20 ms.
Original Figure 2, Zhou et al., from PDF page 2, arXiv license, scholarly quotation.

This figure shows why swapping the encoder alone isn't enough. On the left, SAM 2's Hiera-B+ encoder is replaced with ever smaller backbones. By RepViT-M1 the backbone takes only a dozen or so milliseconds, yet a whole frame still takes nearly 800 ms, because the light "decoder" part stays at around 750 ms.

The decoder here includes the memory attention that SAM 2 added. Recall how SAM 2 processes a frame:

  1. The image encoder outputs features at three scales, F4F_4, F8F_8 and F16F_{16}, where the subscript is the downsampling factor relative to the original image.
  2. Memory attention is a few Transformer layers that use the current frame's F16F_{16} as the query and the concatenated memory features of the past TT frames as keys and values, producing features FMF_M that incorporate the history.
  3. The mask decoder outputs a mask from FMF_M, F4F_4, F8F_8 and the user's prompts.
  4. The memory encoder encodes F16F_{16} and the current mask into a new memory, which goes into the memory bank first-in, first-out.

The right chart takes memory attention apart and measures the pieces. Going from 4 layers to 2 and then 1 cuts latency almost proportionally. Within a single layer, removing self-attention or the feed-forward layer saves only a little, while removing cross-attention takes it from 200 ms down to 20 ms. The real bottleneck is the current frame's cross-attention to memory.

A quick calculation shows why. A 1024×1024 input is 64×64 at the F16F_{16} level, which is 4,096 tokens; each frame's memory is also 64×64, with 64 channels. The memory bank holds 7 frames, so every token of the current frame attends to 7 × 4,096 = 28,672 memory tokens, with complexity O(TCH2W2)O(TCH^2W^2). A phone NPU has limited parallelism, and matrix multiplications this large hit it especially hard.

The authors first tried the most direct combination, using RepViT-M1 as the encoder as EdgeSAM did and cutting memory attention from 4 layers to 2. On the iPhone it still managed only 2.5 frames per second. Reducing the number of memory frames is another option, but with fewer frames, occlusion handling and long-term consistency get worse.

So the authors came at it from another direction. Video is highly redundant in both space and time, and there's no need to store 4,096 tokens of memory for every frame.

Solving the Problem

Original Figure 3. On the left is EdgeTAM's overall pipeline, the same as SAM 2's: video frames enter the Image Encoder and pass through Memory Attention and the Mask Decoder (which takes masks, points or boxes from the Prompt Encoder) to produce masks, which then go through the Mask Encoder and the newly added Spatial Perceiver, outlined by an orange dashed box, into the Memory Bank, whose contents feed back into memory attention for later frames. On the right is a close-up of the Spatial Perceiver: a blue row of global latents uses the whole memory feature map as key/value, while each latent in the green 2D latent grid corresponds to just one cell of the memory features after they are cut into a grid; both go through cross-attention and self-attention, and this block is stacked twice.
Original Figure 3, Zhou et al., from PDF page 4, arXiv license, scholarly quotation.

EdgeTAM's architecture is exactly the same as SAM 2's, except for one new module inserted between the memory encoder and the memory bank, which compresses each frame's memory into a small number of tokens before it is stored.

Trying Pooling First

The simplest compression is average pooling. The authors tried 4×4 average pooling, which takes each frame's memory from 4,096 tokens to 256 and speed from 2.5 to 15.7 frames per second, but J&F on the SA-V validation set falls from 63.5 to 61.8, and on the test set from 62.1 to 59.8. The smaller the encoder, the more noticeable this loss.

Global Perceiver

The second idea comes from the Perceiver. A fixed number of learnable vectors (latents) cross-attend to the whole memory feature map, summarizing its content into themselves, and then do one round of self-attention among themselves:

M~t=Mt+p,Zg′=CA(Q(Zg), K(M~t), V(M~t)),Gt=SA(Zg′)\begin{aligned} \tilde{M}_t &= M_t + p, \\ Z_g' &= \mathrm{CA}\big(Q(Z_g),\ K(\tilde{M}_t),\ V(\tilde{M}_t)\big), \\ G_t &= \mathrm{SA}(Z_g') \end{aligned}

MtM_t is the memory of frame tt, pp is the positional encoding, and ZgZ_g is the NgN_g latents. Every latent can see the whole map and decides for itself what to summarize. The complexity of memory attention drops from O(TCH2W2)O(TCH^2W^2) to O(TCHWNg)O(TCHWN_g).

The problem is that the NgN_g output vectors have no spatial arrangement. Although positional encoding is added to the input, position information can only be implicit in the vectors. Video object segmentation is dense per-pixel prediction and needs more explicit position information and local features; the Global Perceiver alone does only slightly better than pooling and is still worse than no compression.

2D Spatial Perceiver

EdgeTAM's solution is to add a second set of latents that have spatial positions. The memory features are first cut into NlN_l non-overlapping squares, and each latent is responsible for just one of them:

Mt′=partition(Mt),Zl′=CA(Q(Zl),K(Mt′),V(Mt′)),Lt=unpartition(SA(Zl′))+p′\begin{aligned} M_t' &= \mathrm{partition}(M_t), \\ Z_l' &= \mathrm{CA}\big(Q(Z_l), K(M_t'), V(M_t')\big), \\ L_t &= \mathrm{unpartition}\big(\mathrm{SA}(Z_l')\big) + p' \end{aligned}

These latents share the same network parameters as the Global Perceiver; the only difference is how much each latent can see. The positional encoding p′p' also moves from the input to the output, added to the compressed grid, so the output is still a small feature map with a spatial layout.

In practice there are two sets of 256 latents each. The 2D latents are arranged 16×16, each covering one 4×4 patch of the original 64×64 memory. The global latents can range freely over the whole map, and the authors observed some redundancy among them, with several attending to the same place. The two sets of outputs are concatenated, taking each frame's memory from 4,096 tokens to 512, 8 times fewer; cross-attention and self-attention are each stacked twice.

The factor of 8 is deliberate. The authors make HW/(Ng+Nl)HW/(N_g + N_l) roughly equal to the number of memory frames, T=7T = 7, so that in memory attention the current frame's self-attention over itself and its cross-attention over memory cost about the same.

Distilling the Memory Modules Too

Original Figure 4. On the left, (a) is the image pretraining stage: the same image goes into the image encoders of the teacher (gray background) and the student (white background), with a loss L_img between their features, and the student's features then go into the mask decoder and receive the task loss L_task. On the right, (b) is the video training stage: besides L_img between the image encoders, there is also a loss L_mem between the memory attention outputs of teacher and student; the student's output from the mask decoder receives L_task, and the result is stored in the memory bank.
Original Figure 4, Zhou et al., from PDF page 5, arXiv license, scholarly quotation.

SAM 2 is trained in two stages, first image segmentation on SA-1B without the memory modules, then all modules together on images and video. EdgeTAM keeps the original task loss in both stages and adds feature distillation from a teacher, the publicly released SAM 2 Hiera-B+.

The image stage aligns only the image encoder's output F16F_{16}. The video stage aligns the memory attention output FMF_M as well as F16F_{16}, so that the student's memory modules also learn directly from the teacher:

L=Ltask+α⋅MSE(F16t,F16s)+β⋅MSE(FMt,FMs)\begin{aligned} \mathcal{L} = \mathcal{L}_{\text{task}} &+ \alpha \cdot \mathrm{MSE}(F_{16}^{t}, F_{16}^{s}) \\ &+ \beta \cdot \mathrm{MSE}(F_M^{t}, F_M^{s}) \end{aligned}

The superscripts tt and ss denote teacher and student. Methods like MobileSAM distill only the encoder, on images; EdgeTAM extends the same idea to the memory modules.

Training largely follows SAM 2's recipe. The image stage trains for 2 epochs on SA-1B; the video stage uses SA-V, 10% of SA-1B, plus DAVIS, MOSE and YouTube-VOS, for 130K iterations with 8 frames per clip. EdgeTAM doesn't have SAM 2's internal dataset, so the iterations drop from SAM 2's 300K to 130K. Finally, following SAM 2.1, the encoder is frozen and the model is fine-tuned on longer clips of 16 and then 32 frames; EdgeTAM is light on GPU memory, so where SAM 2 stopped at 16 frames, it can go further. The memory bank size is unchanged, and so is the inference cost.

Discussion

Ablations

The ablations all use one third of the training schedule and report J&F on the SA-V validation and test sets, with speed as FPS on the iPhone.

SettingSA-V valSA-V testFPS
RepViT-M1 + 2-layer memory attention63.562.12.5
+ 4×4 average pooling61.859.815.7
+ 256 global latents only62.060.615.7
+ 256 2D latents only63.162.415.7
+ both sets (2D Spatial Perceiver)64.462.515.7
+ distillation65.765.815.7

Compression makes it more than 6 times faster. At that speed, only the version using both sets of latents beats the uncompressed model on both metrics. Distillation costs nothing at inference and adds 3.3 on the test set.

Whether the Perceiver needs its self-attention layer was ablated too. The authors' reasoning is that each 2D latent covers its own cell with no overlap, so self-attention lets them exchange information. Adding it raises the validation set from 62.6 to 64.4, while the test set drops from 62.7 to 62.5, and the paper concludes that "our results verify this hypothesis."

Encoders and numbers of memory-attention layers were compared as well. ViT-Tiny with 2 layers of memory attention is the most accurate (67.9 / 66.0) but runs at only 7.4 frames per second; RepViT-M1 with 1 layer is the fastest, at 22.2 frames, but drops to 61.6 on the test set. The final choice is RepViT-M1 with 2 layers, at 65.7 / 65.8 and 15.7 frames.

Video Object Segmentation

MethodMOSEDAVIS 2017SA-V valSA-V testA100 FPSiPhone FPS
Cutie-base+71.788.161.362.857.2—
SAM 2-B+75.890.973.674.164.80.7
SAM 2.1-B+76.690.276.877.064.10.7
EdgeTAM70.087.772.371.7150.915.7

On the iPhone, EdgeTAM goes from SAM 2's 0.7 frames per second to 15.7, 22 times faster. On SA-V it's 1 to 2.5 points below SAM 2 and about 5 below SAM 2.1, but about 10 points above earlier dedicated video segmentation models. On MOSE and DAVIS it's roughly level with the Cutie generation of models.

When reading the MOSE and DAVIS columns, keep in mind that EdgeTAM's video-stage training data includes the training sets of DAVIS, MOSE and YouTube-VOS. These are scores from a model that has seen in-distribution data, not the zero-shot results Section 4.5 calls them.

On the A100 it's only 2.3 times faster. The authors looked with a profiler and found that on an A100, EdgeTAM fills less than half of the compute units, and the time goes mostly to the CPU launching CUDA kernels and to IO; the model is so small that a big GPU can't make full use of it. That's why the paper keeps stressing on-phone latency, which is what it was designed for.

Image and Click Prompts

Without the memory modules, EdgeTAM also works as an image segmentation model. On SAM's 23 datasets, its average mIoU with 5 clicks is 81.7, higher than the original SAM ViT-H's 81.3, a point the paper goes out of its way to highlight; but with just 1 click it's 55.5, 2.6 below SAM and 6.4 below SAM 2.1.

Video shows something similar. On 17 video datasets with prompts on the first frame only, EdgeTAM's J&F with 1 click is 54.4 against SAM 2.1's 64.7, lower even than the combination of SAM generating the mask and Cutie tracking it. Only with 3 or more clicks, or the ground-truth mask on the first frame, does the gap shrink to 2 to 3 points. The vaguer the prompt, the more the small model loses out.

The authors also acknowledge a typical failure, in which EdgeTAM's tracking granularity keeps following the first few frames. Their example is a fast-moving bird whose feet aren't visible in the early frames; when the feet appear later, EdgeTAM never includes them in the mask.

What Was Open-Sourced

The official repo released inference code and weights, but no training code. Since June 2025, people have asked in the issues for the training code, the sampling ratio of each dataset, and how many GPUs were used for how long; as of November 2026, none of them has had a reply.

The repo later gained a community-contributed CoreML export containing only three models, the image encoder, the prompt encoder and the mask decoder, with neither memory attention nor the Perceiver; its bundled benchmark script also encodes the image first and times only the prompt and decoding. In issue #24, someone inferred from this script that the 16 FPS leaves out image encoding, but the script isn't how the paper measured. The paper measured the converted CoreML models with Xcode's performance report, and that conversion and measurement setup hasn't been released, so the 16 FPS can't currently be reproduced directly from the official code. That issue hasn't been answered either.

Conclusion

The most valuable part of the EdgeTAM paper is that it first broke down SAM 2's latency on a phone and showed that the bottleneck had moved from the encoder to the cross-attention over memory. The remedy is to compress memory before it's stored, keeping half of the tokens spatially arranged for dense prediction, plus feature distillation that covers the memory modules too. The result is 22 times faster on an iPhone and only a point or two below SAM 2 on SA-V.

In practice, its gap to SAM 2 widens noticeably when there are few clicks, so it suits settings where you can give several prompts or already have a mask on the first frame. The paper's speeds were measured on the NPU of an iPhone 15 Pro Max; on a server GPU such as the A100 it's only a little more than twice as fast as SAM 2. On other phones or inference frameworks, you'd do well to measure it again yourself.