---
title: Self-Navigated Residual Mamba (SNARM)
url: https://www.emergentmind.com/topics/self-navigated-residual-mamba-snarm
type: topic
---

# Self-Navigated Residual Mamba (SNARM)

Searching arXiv for the specified paper to ground the response.
Self-Navigated Residual Mamba (SNARM) is a framework for universal industrial anomaly detection that combines two-stage residual learning, residual-guided sequence modeling, and multi-view ensemble decoding to operate across single-class AD, multi-class AD, cross-class AD, and few-shot AD. The method is introduced in “Self-Navigated Residual Mamba for Universal Industrial Anomaly Detection” [2508.01591]. Its defining mechanism is “self-referential learning” within test images: test patches are first contrasted with a compact bank of normal training features to form inter-residuals, and patches exhibiting small-norm residuals are then reused as self-generated references to form intra-residuals. These residuals are fused and processed by a self-navigated Mamba decoder whose token selection and directional scanning are guided by residual properties, with final anomaly maps obtained by ensemble averaging across multiple directions and receptive fields [2508.01591].

## 1. Problem setting and design rationale

SNARM is formulated for the universal setting of industrial anomaly detection, where a single scalable framework is intended to work across single-class AD, multi-class AD, cross-class AD, and few-shot AD [2508.01591]. The motivating diagnosis is that many prior methods depend primarily on pretrained normal features and a one-stage patch comparison against a memory bank of normal data. In that regime, a test patch is typically compared only with stored normal prototypes, and the resulting residual is used directly for anomaly scoring.

The central claim of SNARM is that a single residual against pretrained normal features is insufficient for robust discrimination in difficult scenes. The method therefore introduces three coupled components: inter-residuals obtained from comparison to the external normal feature bank; intra-residuals obtained by reusing the most normal-looking test patches as self-generated references; and a self-navigated Mamba decoder that dynamically scans informative regions according to residual properties [2508.01591]. This design is intended to improve discriminative power while also improving efficiency through reduced matching or search and a compact bank.

A plausible implication is that SNARM treats anomaly detection not as a single nearest-neighbor deviation test, but as a residual refinement process in which global deviation from training normality is supplemented by context-sensitive, image-internal comparison. The paper explicitly distinguishes this from PatchCore-like residual pipelines that stop after inter-image matching.

## 2. Architecture and processing pipeline

The overall SNARM pipeline begins with universal visual feature extraction from a pretrained encoder, with DINOv2-R ViT-Base/14 as the default encoder [2508.01591]. A compact feature bank is then constructed from normal training images using coreset sampling. For each test image patch, SNARM computes inter-residuals against the bank and derives a Waypoint Map (WM) from these residuals. The lowest-residual patches in the test image are selected as pseudo-normal references, and intra-residuals are computed by matching test patches against these self-generated references. Inter- and intra-residuals are concatenated into hybrid residuals, which are fed into a Self-Navigated Mamba Module (SNMM). The decoder then produces anomaly maps via a Multi-View Decoder (MVD), and branch outputs are aggregated through ensemble averaging [2508.01591].

The feature extractor is written as $\Psi_{\mathrm{EN}}(\cdot)$, with intermediate-layer outputs
$$
\{\mathbf{F}^1, \mathbf{F}^2, \cdots, \mathbf{F}^L \} = \Psi_{\mathrm{EN}}(\mathrm{I}).
$$
Early and late layers are fused as
$$
\mathbf{F} = \mathrm{Concat}\left(\frac{2}{L}\sum_{l=1}^{L/2}\mathbf{F}^l,\ \frac{2}{L}\sum_{l=L/2+1}^{L}\mathbf{F}^l\right),
$$
and after upsampling and flattening,
$$
[\mathbf{f}_1, \mathbf{f}_2, \cdots, \mathbf{f}_M] = \mathrm{Flatten}(\mathrm{Up}(\mathbf{F})),
$$
where each $\mathbf{f}_i \in \mathbb{R}^{d_f}$ is a local patch descriptor [2508.01591].

This organization places feature extraction, residual construction, navigation, and decoding into distinct stages. The paper’s framing suggests that the separation is deliberate: residuals are not merely scores but structural signals used to control subsequent computation.

## 3. Two-stage residual learning and self-referential comparison

SNARM’s first residual stage compares test patches with a training feature bank. Patch features from normal training images are collected into a raw bank and compressed by a coreset into a compact bank $\mathcal{B}$ with size $T \ll M \cdot N_{\text{trn}}$ [2508.01591]. For each test patch $\mathbf{f}^{\text{tst}}_i$, the nearest reference patch is
$$
t^\ast = \arg\min_{t=1,\cdots,T} \left\| \mathbf{f}^{\text{tst}}_i - \mathbf{f}^{\text{ref}}_t \right\|_2,
$$
and the inter-residual is defined as the powered absolute difference
$$
\mathbf{r}_i = \left(\mathrm{ABS}\left(\mathbf{f}^{\text{tst}}_i - \mathbf{f}^{\text{ref}}_{t^\ast}\right)\right)^\theta,
$$
with $\theta \in \{1,2\}$ tuning contrast [2508.01591].

From the inter-residual map $\mathbf{R}$, SNARM constructs a coarse anomaly confidence map called the Waypoint Map. The navigator has two branches:
$$
\mathbf{Q} = \sigma(\mathrm{Conv}_{1\times1}(\mathbf{R})), \qquad
\mathbf{Q}^\star = \mathbf{Q} + \frac{1}{d_f}\sum_{k=1}^{d_f}\mathbf{R}(i,j,k).
$$
Here, $\mathbf{Q}$ is a learned unary anomaly score from a $1 \times 1$ convolution followed by sigmoid, and the second term is the channel-averaged residual magnitude; $\mathbf{Q}^\star$ is the final Waypoint Map [2508.01591]. The map is used both to guide the second residual stage and to navigate token processing in Mamba.

The second residual stage is the self-referential component. SNARM assumes that patches with the lowest waypoint scores are likely normal and uses them as pseudo-reference patches:
$$
\mathcal{S} = \left\{ \mathbf{f}^{\text{tst}}_k \mid \mathbf{Q}^\star(k) < \mathrm{Percentile}(\mathbf{Q}^\star, p) \right\},
$$
where the paper uses $p=75$ [2508.01591]. Each test patch is then matched against $\mathcal{S}$,
$$
\tilde{t}^\ast = \arg\min_{\mathbf{f} \in \mathcal{S}} \left\| \mathbf{f}^{\text{tst}}_i - \mathbf{f} \right\|_2,
$$
and the intra-residual is
$$
\tilde{\mathbf{r}}_i = \left(\mathrm{ABS}\left(\mathbf{f}^{\text{tst}}_i - \mathbf{f}_{\tilde{t}^\ast}\right)\right)^\theta.
$$

The paper characterizes this as self-referential comparison: the test image generates its own “normal-ish” references, making matching more context-aware within the specific image and potentially making subtle deviations more visible when the external memory bank is not perfectly representative [2508.01591]. Inter- and intra-residuals are then concatenated:
$$
\hat{\mathbf{R}} = [\mathbf{R} \,\|\, \tilde{\mathbf{R}}],
$$
yielding a $2d_f$-dimensional residual representation per spatial location [2508.01591].

## 4. Self-navigated Mamba and multi-view decoding

SNARM’s decoder is built around a Self-Navigated Mamba Module. The paper motivates the use of Mamba by citing its strong long-range modeling capacity and lower complexity than Transformers, while noting that naive application to dense anomaly localization is expensive because of the large number of spatial tokens [2508.01591]. The proposed Self-Navigated Mamba Block (SMB) uses the Waypoint Map to select a compact informative subset of tokens, performs directional scanning, and inserts a $3 \times 3$ convolution before each scan to enrich local context.

The four scan directions are left-to-right, right-to-left, top-down, and bottom-up. The SNMM stacks a feature embedding layer and two SMBs, producing four direction-aware feature maps:
$$
\{\mathbf{o}^{(\rightarrow)}, \mathbf{o}^{(\leftarrow)}, \mathbf{o}^{(\downarrow)}, \mathbf{o}^{(\uparrow)}\}.
$$
The paper’s interpretation is that residual properties determine which patches are worth scanning and where the Mamba path should emphasize computation; the image is therefore not read uniformly but navigated by residual saliency [2508.01591].

To accommodate defects that vary in shape and scale, SNARM uses a Multi-View Decoder with multiple view-specific branches. Each directional feature $\mathbf{o}^{(d)}$ is processed by branch-specific atrous convolution,
$$
\tilde{\mathbf{o}}^{(r,d)} = \mathcal{A}_{r,d}(\mathbf{o}^{(d)}) = \mathrm{AtrousConv}(\mathbf{o}^{(d)}; r),
$$
with dilation rates $r \in \{3, 6, 12, 24\}$ [2508.01591]. A prediction head then outputs an anomaly map:
$$
\mathbf{m}^{(r,d)} = \mathcal{H}(\tilde{\mathbf{o}}^{(r,d)}) = \sigma\left(\mathrm{Up}\left(\mathrm{Conv}_{1\times1}(\tilde{\mathbf{o}}^{(r,d)})\right)\right).
$$
This yields $4 \times 4 = 16$ view-specific predictions, and inference averages all 16 outputs:
$$
\hat{\mathbf{m}} = \frac{1}{16}\sum_{i=1}^{4}\sum_{j=1}^{4}\mathbf{m}^{i,j}.
$$
The stated rationale is improved robustness across scan directions, receptive-field scales, and defect shapes [2508.01591].

## 5. Optimization, augmentation, and implementation

SNARM uses cyclic optimization to encourage diversity among view-specific branches. The procedure sequentially updates one branch at a time while freezing the others for $\mathcal{K}$ steps, with $\mathcal{K}=100$ in the reported setting [2508.01591]. Both the Residual Navigator and the MVD are supervised using Focal Loss. The total loss is given as
$$
\mathcal{L}_{\text{total}} = \mathcal{L}_{\text{focal}}(\mathrm{Up}(\mathbf{Q}), \mathbf{Y})
+ \frac{1}{4}\sum_{j=1}^{4}\mathcal{L}_{\text{focal}}(\mathbf{m}^{i,j}, \mathbf{Y}),
$$
and the focal loss is
$$
\mathcal{L}_{\text{focal}}(\hat{\mathbf{M}}, \mathbf{Y}) =
- \sum_{x,y} \left[
\alpha (1-\hat{\mathbf{M}}_{x,y})^\gamma \mathbf{Y}_{x,y}\log(\hat{\mathbf{M}}_{x,y})
+ (1-\alpha)\hat{\mathbf{M}}_{x,y}^\gamma (1-\mathbf{Y}_{x,y})\log(1-\hat{\mathbf{M}}_{x,y})
\right].
$$
The reported settings are $\alpha=0.5, \gamma=4$ for the navigator loss and $\alpha=0.25, \gamma=4$ for the view-specific branches [2508.01591].

Two feature augmentation strategies are also reported. First, top-$k$ feature averaging replaces the single nearest reference with the average of the top-$k$ nearest features,
$$
\mathbf{f}_i^{\text{ref}} = \frac{1}{k}\sum_{j=1}^{k}\mathbf{f}_{t_j},
$$
with $k=3$ [2508.01591]. Second, consistent feature jittering adds a shared Gaussian perturbation consistently to both the feature and residual:
$$
\tilde{\mathbf{f}}_i = \mathbf{f}_i + \lambda \frac{\|\mathbf{f}_i\|_2}{d_f}\boldsymbol{\epsilon}, \qquad
\tilde{\mathbf{r}}_i = \mathbf{r}_i + \lambda \frac{\|\mathbf{r}_i\|_2}{d_f}\boldsymbol{\epsilon},
$$
where $\boldsymbol{\epsilon} \sim \mathcal{N}(0,\mathbf{I})$ and $\lambda = 30$ [2508.01591].

The default implementation uses ViT-Base/14 with DINOv2-R weights, intermediate outputs from transformer blocks 1–8, input resize $448 \times 448$, center crop $392 \times 392$, coreset size $T=10^4$, percentile $p=75$, top-$k$ value $k=3$, training cycles $\mathcal{K}=100$, Adam, learning rate $0.001$, and weight decay $0.05$ [2508.01591]. The reported hardware is an Intel i5-13450 CPU, 64 GB RAM, and an NVIDIA RTX 4090 GPU.

## 6. Benchmarks, results, and ablations

SNARM is evaluated on MVTec AD, MVTec 3D AD, and VisA using Image-AUROC, Pixel-AUROC, PRO, and Average Precision [2508.01591]. The abstract states that the method achieves state-of-the-art performance with notable improvements in all metrics, including Image-AUROC, Pixel-AURC, PRO, and AP; the detailed experimental section in the provided summary specifies that the paper reports Pixel-AUROC rather than Pixel-AURC. This discrepancy is best read as a terminology inconsistency between the abstract summary and the benchmark description, not as a difference in the underlying evaluation protocol.

In the multi-class setting, the reported results for SNARM with $T=10^5$ are 79.0 P-AP / 96.6 PRO / 99.1 P-AUROC / 99.4 I-AUROC on MVTec AD, 63.6 / 97.4 / 99.2 / 93.9 on MVTec 3D, and 55.8 / 94.7 / 99.1 / 98.1 on VisA [2508.01591]. The paper reports improvements over prior best methods of +1.9 AP, +1.7 PRO, and +0.6 P-AUROC on MVTec AD; +7.7 / +0.4 / +0.0 / +1.3 on MVTec 3D; and +2.6 / +0.2 / +10.2 on the reported VisA metrics, together with strong competitiveness on image-level metrics [2508.01591].

In the cross-class setting, SNARM reports 78.4 / 96.1 / 99.0 / 99.3 on MVTec AD, 68.9 / 97.3 / 99.1 / 94.5 on MVTec 3D, and 56.0 / 93.8 / 99.1 / 98.0 on VisA, with improvements over previous best methods of 10.4 / 0.3 / 0.4 / 0.1, 31.2 / 2.5 / 0.7 / 11.1, and 16.5 / 4.7 / 1.3 / 7.6 respectively [2508.01591]. In the single-class setting, the reported values are 79.2 / 96.6 / 99.0 / 99.3 on MVTec AD, 65.5 / 97.2 / 99.2 / 94.0 on MVTec 3D, and 55.4 / 92.3 / 99.0 / 98.0 on VisA. In the 4-shot few-shot setting, SNARM reports 68.6 / 94.6 / 97.9 / 98.3 on MVTec AD, with gains of +2.7 / +1.7 / +0.9 / +0.7 over the prior best, and 49.5 / 92.9 / 98.1 / 94.5 for one key comparison on VisA [2508.01591].

A concise summary of the headline results is as follows.

| Setting | Benchmark | Reported SNARM results |
|---|---|---|
| Multi-class | MVTec AD | 79.0 / 96.6 / 99.1 / 99.4 |
| Multi-class | MVTec 3D | 63.6 / 97.4 / 99.2 / 93.9 |
| Multi-class | VisA | 55.8 / 94.7 / 99.1 / 98.1 |
| Cross-class | MVTec AD | 78.4 / 96.1 / 99.0 / 99.3 |
| Cross-class | MVTec 3D | 68.9 / 97.3 / 99.1 / 94.5 |
| Cross-class | VisA | 56.0 / 93.8 / 99.1 / 98.0 |
| Single-class | MVTec AD | 79.2 / 96.6 / 99.0 / 99.3 |
| Single-class | MVTec 3D | 65.5 / 97.2 / 99.2 / 94.0 |
| Single-class | VisA | 55.4 / 92.3 / 99.0 / 98.0 |
| 4-shot few-shot | MVTec AD | 68.6 / 94.6 / 97.9 / 98.3 |

The paper also reports an efficiency profile of 92.7 mAD, 69 GFLOPs, 68.3M parameters, and 48 FPS, and characterizes this as a favorable trade-off versus heavier alternatives such as INP-Former and Dinomaly [2508.01591]. It further emphasizes that performance remains strong even with a compact memory bank.

The ablation study is presented as a progressive accumulation of components: a base model with inter-residuals and vanilla Mamba; addition of Hybrid-Matching; addition of SMB; addition of MVD; addition of Top-$k$ averaging; addition of Jitter; addition of Cyclic Training; and finally all modules plus CT, which yields the best result [2508.01591]. The reported interpretation is that self-referential residual refinement and navigation-aware decoding are both essential.

## 7. Conceptual significance and scope

The paper summarizes SNARM’s contributions in four parts: Hybrid Matching through inter- and intra-residuals; Self-Navigated Mamba through residual-aware dynamic token navigation and efficient directional scanning; multi-view or multi-scale ensemble decoding via four directional branches and four dilation rates; and strong universal AD performance across MVTec AD, MVTec 3D, and VisA in single-class, multi-class, cross-class, and few-shot settings [2508.01591].

The conceptual significance of SNARM lies in the interaction among these parts. Residual refinement supplies complementary signals: global deviation from training normality and local self-referenced refinement. Residual-guided navigation then determines which spatial tokens are emphasized by sequence modeling. Multi-view ensemble decoding aggregates predictions across direction and scale. This suggests that SNARM is designed not merely to score anomalies, but to transform residual structure into a control signal for representation learning and localization.

A common simplification would be to describe SNARM as only a memory-bank nearest-neighbor method or only a Mamba-based decoder. The paper argues against both reductions. It does not stop at inter-image matching, because the second residual stage derives references from the test image itself. It is also not a uniform dense Mamba scan, because the Waypoint Map guides token selection and directional traversal [2508.01591]. Within the scope of the reported evidence, SNARM is therefore best understood as a universal industrial anomaly detection framework organized around self-referential residual learning and residual-aware state-space decoding.

Source: https://www.emergentmind.com/topics/self-navigated-residual-mamba-snarm