Manuscript Offprint
arXiv:2610.22065ABNAT: Attention-Based Noise-Aware Training for Robust Transformers on Analog Compute-in-Memory Systems
Abstract
Transformer-based models have become the backbone of a wide range of tasks, but their intensive computation and data movement incur substantial energy overhead. Analog compute-in-memory (CIM) offers an energy-efficient alternative, yet its inherent hardware non-idealities perturb stored weights and can significantly degrade model performance. Although existing noise-aware training (NAT) methods improve robustness by injecting noise during training, they largely overlook the critical role of attention mechanisms in Transformer inference. To bridge this gap, we analyze how CIM-induced noise reshapes attention in Transformers and identify two key observations: (1) the divergence between clean and noisy attention maps increases substantially in deeper layers, and (2) conventional NAT can remain overconfident even when its attention routes deviate markedly from the clean reference. Motivated by these findings, we propose ABNAT, an attention-based noise-aware training framework that teaches the noisy student to preserve the clean teacher's headwise attention routes rather than merely reproduce answers, without hardware changes or inference overhead; selective variants further reduce training cost. Extensive experiments across vision, language, and multimodal Transformers show that ABNAT consistently improves robustness over corresponding NAT baselines, improving noise-degraded accuracy by up to 11.28% and reducing attention deviation by up to 85.77%.
CCS Concepts
• Hardware → Robustness.
Keywords
Analog Compute-in-Memory, Noise-Aware Training, Attention Distillation, Transformer Deployment, Hardware Non-Idealities
ACM Reference Format:
Wenshuai Yao, Wenyong Zhou, Hanyong Shao, Zhiyuan Ning, Yizhe Chen, Yuannuo Feng, Kechao Tang, and Ru Huang. 2027. ABNAT: Attention-Based
Input
Clean
Noisy
NAT
ABNAT

Figure 1: Attention maps from clean inference and from the noisy model, NAT, and ABNAT under CIM noise.
Noise-Aware Training for Robust Transformers on Analog Compute-in-Memory Systems. In Proceedings of 32nd Asia and South Pacific Design Automation Conference (ASP-DAC '27). ACM, New York, NY, USA, 7 pages.
To mitigate such degradation, noise-aware training (NAT) methods incorporate hardware noise injection during training to improve model robustness [12, 19, 26]. While effective for conventional convolutional neural networks (CNNs), these approaches treat the model as a black box and optimize solely for correct output predictions, overlooking the distinctive role of attention mechanisms in Transformer inference. This output-centric paradigm leaves a critical gap: the internal semantic reasoning pathways of Transformers remain fragile under CIM noise, even when final predictions appear correct.
For clear spatial visualization of attention routes, we conduct a detailed analysis of Vision Transformers (ViTs) [9]. (L) Output-centric NAT misses semantic attention routes. Existing NAT methods supervise only final predictions, allowing models to produce correct answers via incorrect attention routes. Figure 1 shows severe attention distortion under NAT, motivating two structural observations. (O1) CIM noise accumulates attention drift across depth.
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org.
ASP-DAC '27, Tokyo, Japan
© 2027 Copyright held by the owner/author(s). Publication rights licensed to ACM.
Yao et al.
Weight perturbations disrupt attention concentration at each layer, and errors accumulate with depth. Figure 2 shows that this drift grows with noise severity and becomes concentrated in late blocks, motivating targeted route preservation. (O2) Head sensitivity is nonuniform within blocks. Figure 4 further reveals marked head-to-head sensitivity variation, so uniform alignment over all layers is unnecessarily costly without commensurate accuracy gains.
Motivated by these observations, we propose ABNAT (Attention-Based Noise-Aware Training), an attention-based knowledge distillation (KD) framework for preserving semantic routes under CIM noise. ABNAT uses a clean, frozen copy of the target deployment model as the teacher and its noise-perturbed counterpart as the student. Rather than relying only on answer-level supervision, ABNAT transfers the content understanding encoded in the teacher's attention routes by aligning teacher and student attention distributions. Figure 1 shows that ABNAT restores noise-distorted attention maps toward the clean reference across diverse inputs, indicating more faithful preservation of semantic attention routes. We further develop head- and block-selective variants that retain near-full robustness at lower training cost, and validate ABNAT across vision, language, and vision-language Transformers. The main contributions of this work are summarized as follows:
• We identify attention drift as a key robustness bottleneck in CIM-deployed ViTs and empirically establish its strong correlation with accuracy degradation under noise.
• We propose ABNAT, an attention-based KD framework that preserves semantic attention routes under CIM noise by aligning headwise attention maps between a clean teacher and a noisy student model.
• We introduce selective alignment variants at head and block granularity that reduce training cost while retaining accuracy close to full alignment.
- Extensive experiments spanning multiple noise levels, model scales, and datasets across vision, language, and multimodal tasks demonstrate that ABNAT consistently outperforms existing NAT baselines, achieving up to 11.28 percentage points higher noise-degraded accuracy and an 85.77% reduction in attention deviation.
2 Preliminaries
2.1 Transformers and Attention Mechanisms
Transformers represent vision, language, and multimodal inputs as token sequences processed by stacked blocks [24]. Each block combines multi-head self-attention (MHSA) and a feed-forward network with residual connections and layer normalization. Self-attention enables each token to aggregate relevant information from other permitted tokens, supporting content-dependent, long-range interactions. For head in block , the input is projected into queries , keys , and values . The attention map and head output are
Here, is the head dimension and is an optional structural or causal mask. Each row of defines how one query routes and aggregates information from the permitted tokens, while multiple heads capture complementary relations. Across blocks, these maps govern progressive information routing [1, 8], making them a natural internal target for ABNAT. The same mechanism is shared by vision, language, and vision-language Transformers [3, 9, 18].
2.2 Analog CIM Hardware
Analog CIM accelerators perform MVMs in situ by encoding weight matrices as analog device conductances and exploiting Ohm's law for multiplication and Kirchhoff's current law for summation [7, 23]. This in-memory computation eliminates costly data movement between memory and processing units, enabling orders-of-magnitude improvements in energy efficiency compared to conventional digital accelerators [6, 11, 22]. These properties make CIM an attractive substrate for energy-efficient Transformer deployment [13, 14, 16].
However, analog device non-idealities introduce unavoidable perturbations to the stored weights [2, 4]. These arise from multiple physical sources: conductance programming variation, thermal read noise, inter-cell interference, and long-term conductance drift. The detailed bit-level noise formulation used in our experiments is introduced in Sec. 4. For Transformers, noise corrupts the projection matrices , , and at every layer, perturbing attention computation throughout the network. Because Transformer representations are built compositionally across depth, these per-layer errors accumulate rather than cancel, causing severe attention drift in deeper layers where semantic concentration is most critical.
2.3 Noise-Aware Training
NAT improves CIM robustness by injecting hardware noise during training, optimizing:
where is the cross-entropy loss and denotes the noisy model. NAT has demonstrated effectiveness for CNNs [5, 15, 26], but remains output-centric: supervising only final predictions places no explicit constraint on intermediate attention routes. The model may therefore learn shortcut solutions that produce correct, highly confident predictions through severely distorted attention maps. Such confidence–route inconsistency can generalize poorly across deployment noise levels and degrade clean accuracy because the semantic attention routes central to Transformer inference remain unconstrained.
KD transfers knowledge from a pretrained teacher to a student by minimizing discrepancies in their outputs or intermediate representations, and has shown strong results in model compression and transfer learning [10, 21]. Prior studies have incorporated KD into NAT for CIM robustness: Charan et al. [5] distill the teacher's output predictions, whereas Zhou et al. [27] additionally align intermediate feature maps in RRAM-based ViTs. Despite using knowledge distillation, both approaches essentially teach the noisy student to reproduce answers while overlooking attention drift, without teaching it to understand the content under noise. In contrast, ABNAT transfers the clean teacher's attention distributions, teaching the noisy student to preserve content understanding under hardware noise. Section 4 demonstrates the resulting gains in robust performance and cross-noise generalization.
3 Methodology
3.1 Motivation
Let and denote the clean and noisy paths instantiated from the same pretrained ViT checkpoint. The clean path is frozen and serves as the teacher, while the noisy path injects CIM-induced weight noise and is optimized as the student; thus, ABNAT requires no separately trained teacher. Both paths contain encoder blocks and attention heads per block. Given an input , let , be the attention distributions over the patch tokens, excluding [CLS], at block and head for the teacher and student, respectively. Each distribution is computed by averaging the post-softmax attention weights over all query tokens.
The attention drift of head is defined as
A large implies that CIM noise significantly changes the student's attention behavior from the clean reference, which may impair critical information flow. We therefore ask whether such drift is uniform across the network or follows structured patterns that can guide targeted training.
As shown in Figure 2, remains consistently low and nearly uniform across blocks 1–8, but undergoes a sharp, accelerating increase in blocks 9–12. This depth-dependent pattern can be understood through the lens of error propagation: perturbations introduced by CIM noise at any given layer are not confined to that layer, but are carried forward and progressively amplified as they pass through the subsequent nonlinear transformations of the Transformer. Consequently, late blocks, which receive as input the accumulated representations of all preceding layers, are disproportionately exposed to compounded noise effects. This observation has an important practical implication: a uniform attention alignment strategy that treats all blocks equally may be mismatched with the underlying structure of the problem. Instead, a depth-aware approach that concentrates alignment effort on late blocks is more efficient.
The depth-dependent drift pattern indicates where CIM noise has the strongest impact, but does not directly quantify its effect on task performance. To bridge this gap, Fig. 3 correlates the full-network mean attention drift with the model-level accuracy drop across diverse noise conditions and seeds. The results show a strong correlation, with Pearson and Spearman . This observation has two implications. First, mean attention drift serves as a reliable network-level robustness diagnostic: noise settings with larger mean drift are typically associated with greater accuracy degradation, whereas those with smaller drift exhibit less performance loss. Second, it identifies attention drift as a key robustness bottleneck under CIM noise, motivating our training framework to explicitly suppress drift rather than relying only on coarse output logits.
3.2 ABNAT Framework
The analyses above motivate full alignment for the strongest robustness and selective variants for lower training cost. Unless otherwise stated, ABNAT denotes full alignment over all attention heads and is used for the main accuracy results; ABNAT-selective restricts the alignment set S defined below. Figure 5 summarizes the

Figure 2: Layerwise attention drift across CIM noise intensities; shaded bands denote std across seeds.

Figure 3: Accuracy degradation versus mean attention drift across CIM noise settings.

Figure 4: Sensitivity scores across all Transformer blocks and attention heads.
ABNAT pipeline. Although attention drift is concentrated in late blocks, both drift and clean attention concentration vary considerably across individual heads. To rank heads for sensitivity-guided selection, we therefore combine these two complementary factors. A concentrated head routes information through a small subset of tokens, whereas a diffuse head distributes attention broadly, making concentration a useful complement to drift when prioritizing routes for alignment.
We measure clean attention concentration as
where and is the maximum entropy. This normalization places in , with larger values indicating more concentrated attention. We compute it from the clean teacher so that it reflects the intended clean behavior independently of CIM noise.
The sensitivity score combines the two factors:
A head therefore receives a high score only when it exhibits both large noise-induced drift and concentrated clean attention. A strongly drifted but diffuse head, or a concentrated but stable head, receives a lower score. The product thus ranks heads by jointly considering route disruption and clean attention focus, without treating either
Yao et al.

Figure 5: ABNAT with sensitivity-guided late-block selection and task, logit-distillation, and attention-alignment objectives.
factor alone as sufficient. Figure 4 shows that high-sensitivity heads are concentrated primarily in blocks 9–12, with much lower scores in early blocks, reinforcing the depth-dependent pattern above.
3.2.1 Sensitivity-Guided Head Selection. We construct the selected alignment set S by retaining the k heads with the highest sensitivity scores across all blocks and heads:
Here, k is a fixed training-overhead budget. For head-selective alignment, S is computed once before training by globally ranking all block-head pairs and is held fixed thereafter. Early-block heads remain eligible, while the observed concentration in late blocks emerges from the sensitivity ranking. Setting S to all heads recovers the default ABNAT.
3.2.2 Attention Alignment over the Selected Set. For a given S, we define the attention alignment loss over its selected heads:
The distributions used for alignment are obtained by dividing the corresponding attention logits by an attention temperature before softmax; recovers the standard attention distribution. Minimizing this loss encourages the student to reproduce the teacher's clean attention patterns precisely at the heads identified as most critical, directly targeting the internal mechanisms through which CIM noise degrades performance.
No block is excluded a priori in sensitivity-guided head selection. In practice, high-sensitivity heads concentrate predominantly in late blocks, so S naturally focuses supervision on the most noise-vulnerable routes while retaining any high-scoring early heads. For the structured block-selective variants in Fig. 10, S instead contains all heads within the selected blocks.
3.2.3 Overall Training Objective. Bringing all components together, the complete training objective of ABNAT combines three complementary losses, each operating at a distinct level of abstraction:
where and are scalar hyperparameters that balance the three objectives; is kept at unit coefficient as the scale anchor. Unless otherwise stated, we use , , and .
At the coarsest level, the task loss is the standard cross-entropy loss computed against ground-truth labels, ensuring that the student retains discriminative performance on the target task regardless of noise conditions. Building on top of this, the logits distillation loss , where and are the pre-softmax logits and is the distillation temperature, aligns the student's output probability distribution with that of the clean teacher. Finally, at the finest level of granularity, the attention alignment loss reaches deeper into the network to preserve the selected internal attention pathways. Together, these three losses form a coherent, multi-level training strategy: anchors the student to correct predictions, aligns its output distribution with the teacher's, and safeguards attention routes vulnerable to CIM-induced degradation. This layered design allows ABNAT to simultaneously maintain high clean accuracy and achieve strong robustness under hardware noise.
4 Experiment
4.1 Experimental Setup
We evaluate ABNAT primarily on ViT-Tiny/16 with CIFAR-100, comparing NAT [19], NAT+KD [5], FeatureAlign [27], and our AttnAlign. Generalization is tested on ViT-Small on CIFAR-100, ViT-Tiny on ImageNet-100, Swin-Tiny on CIFAR-100, Pythia-160M and Pythia-2.8B on WikiText-103, and CLIP ViT-B/32 on Flickr30K.
Unless otherwise specified, models are trained with AdamW for 100 epochs, batch size 1024, learning rate , weight decay 0.05, cosine decay, and 5 warmup epochs. For task-specific runs, the Pythia models use 262,144 WikiText-103 training tokens for 5 epochs at sequence length 128 and are evaluated on 65,536 tokens at length 2,048; CLIP uses Flickr30K training images at for 10 epochs. We use matched train–deploy noise, , and report mean std over 30 inference seeds. Unless otherwise stated, ABNAT denotes full alignment; Fig. 10 studies structured block-selective variants for lower training cost. Since alignment is training-only, ABNAT preserves the NAT inference cost.
CIM inference is modeled under W8A8 quantization with bit-level hardware variations, where :
Table 1: Full component ablation for ViT-Tiny on CIFAR-100 under matched train–deploy noise. Accuracy under noisy inference is reported as mean±std over 30 seeds. Shaded rows denote the two KD-based ABNAT variants; ABNAT without retains logit KD and our attention-alignment loss.
| Variant | Task loss | Logit KD | Feature [27] | Attn. Align. (Ours) | σ = 0.05 | σ = 0.10 | σ = 0.15 | σ = 0.20 | Avg. |
|---|---|---|---|---|---|---|---|---|---|
| Original+Noise | - | - | - | - | 86.28±0.37 | 64.34±1.37 | 10.06±1.51 | 2.09±0.61 | 40.69 |
| NAT [19] | ✓ | - | - | - | 84.98±0.35 | 79.23±0.51 | 71.52±0.67 | 58.86±0.66 | 73.65 |
| KD | - | ✓ | - | - | 87.21±0.15 | 82.59±0.32 | 75.00±0.53 | 63.29±0.74 | 77.02 |
| FeatureAlign | - | - | ✓ | - | 86.46±0.28 | 80.36±0.50 | 43.27±1.33 | 14.72±1.59 | 56.20 |
| AttnAlign | - | - | - | ✓ | 86.22±0.29 | 78.68±0.49 | 54.76±1.14 | 12.91±1.21 | 58.14 |
| NAT+KD [5] | ✓ | ✓ | - | - | 87.20±0.17 | 82.69±0.29 | 74.99±0.54 | 62.45±0.76 | 76.83 |
| NAT+Feature | ✓ | - | ✓ | - | 86.49±0.20 | 81.67±0.43 | 71.87±0.95 | 58.35±0.72 | 74.60 |
| NAT+AttnAlign | ✓ | - | - | ✓ | 87.15±0.21 | 83.37±0.41 | 77.01±0.70 | 66.05±0.92 | 78.39 |
| KD+Feature | - | ✓ | ✓ | - | 87.64±0.20 | 83.22±0.36 | 75.53±0.62 | 63.15±0.80 | 77.39 |
| NAT+KD+Feature [27] | ✓ | ✓ | ✓ | - | 86.91±0.17 | 83.33±0.35 | 75.25±0.61 | 62.63±1.04 | 77.03 |
| ABNAT without | - | ✓ | - | ✓ | 87.74±0.18 | 84.28±0.33 | 78.62±0.56 | 70.04±0.82 | 80.17 |
| ABNAT | ✓ | ✓ | - | ✓ | 87.62±0.21 | 83.95±0.28 | 78.66±0.48 | 70.14±0.78 | 80.09 |
NAT NAT+KD NAT+AttnAlign ABNAT

Figure 6: Cross-setting results for ViT-Small on CIFAR-100, ViT-Tiny on ImageNet-100, Swin-Tiny on CIFAR-100, Pythia-160M and Pythia-2.8B on WikiText-103, and CLIP ViT-B/32 on Flickr30K.
Here, and denote the activation and weight quantizers, and are the -th activation and -th weight bit planes, denotes element-wise multiplication, and denotes the relative standard deviation of device-conductance variation. For combined bit-parallel and bit-serial execution, the reconstructed CIM output is
where is simulated by NeuroSim [17, 20], denotes the aggregate readout error from the TIA and ADC, ADC precision is tied to the activated-row count, and mapped matrix operations use full-row activation.
4.2 Experiment Results
Full Component Ablation Table 1 ablates noisy task supervision, logit KD, feature alignment, and attention alignment under matched train–deploy noise. Our AttnAlign becomes increasingly effective as noise intensifies: adding it to NAT improves accuracy by 2.17 percentage points at and by 7.19 points at . Together with logit KD, AttnAlign forms the complete ABNAT, which reaches at , outperforming NAT+KD and NAT by 7.69 and 11.28 points, respectively. In comparison, FeatureAlign provides negligible high-noise benefit: adding it to NAT changes accuracy from to , while adding it to NAT+KD changes to . ABNAT without also achieves a strong average accuracy of , while complete ABNAT performs best at . These results show that attention-route preservation becomes increasingly important as hardware noise intensifies.
Generalization Across Models and Datasets We evaluate ABNAT's effectiveness across model architectures and datasets to assess generalizability. Figure 6(a–c) presents results for ViT-Small on CIFAR-100, ViT-Tiny on ImageNet-100, and Swin-Tiny on CIFAR-100. At , ABNAT improves over NAT by 6.34, 8.15, and 4.15 percentage points, respectively. These consistent gains across model scales, datasets, and both flat and hierarchical Transformer architectures indicate that attention-route supervision is not tied to a single configuration.
Generalization to Language and Multimodal Transformers We further evaluate attention-route preservation using Pythia-160M and Pythia-2.8B for language modeling [3] and CLIP ViT-B/32 for image-text retrieval [18]. Figure 6(d–f) reports perplexity and Mean Recall, where lower and higher values are better, respectively. An attention-aligned variant performs best in all three settings. At , NAT+AttnAlign reduces Pythia-160M perplexity by , from 7682.16 to 1812.96, while NAT+KD+AttnAlign reduces Pythia-2.8B perplexity by , from 2329.72 to 941.04. On CLIP ViT-B/32 at , NAT+AttnAlign improves Mean Recall from 71.70 for NAT to 72.27. These results extend attention-route preservation to autoregressive language modeling and multimodal retrieval.
Robustness Under Train–Deploy Noise Mismatch Inference noise can deviate from training conditions because of device variation, lifetime drift, and operating changes [2, 4]. We therefore fix and sweep in Fig. 7. ABNAT outperforms NAT and NAT+KD throughout the sweep. For , its gain over NAT reaches 10.86 points at ; when trained at 0.20, it retains a 9.68-point gain even at . Under clean inference, the latter checkpoint maintains accuracy, compared with for NAT and for NAT+KD. These results indicate that attention-route supervision strengthens
Yao et al.

Figure 7: Train-deploy noise mismatch for ViT-Tiny on CIFAR-100 at .

Figure 8: Layerwise attention drift of NAT, NAT+KD, and ABNAT at .

Figure 9: Prediction confidence versus attention-route fidelity at on the common anchor subset.
the noisy model's content understanding, enabling robust generalization across deployment noise while better preserving clean accuracy.
4.3 Discussion
Analysis of Attention-Route Stabilization We analyze attention drift patterns to understand ABNAT's performance improvements. Figure 8 shows that at , the block-averaged attention drift is 1.272 for NAT and 1.096 for NAT+KD, but only 0.181 for ABNAT—an reduction relative to NAT. ABNAT suppresses drift most strongly in the late blocks, where CIM noise causes the largest deviations. Together with the observed correlation between mean attention drift and accuracy degradation in Fig. 3, these results support that ABNAT improves robustness by stabilizing clean attention routes rather than relying only on output-level supervision.
Prediction Confidence and Route Quality Analysis We analyze prediction confidence versus attention-route fidelity using the common anchor subset at , where NAT, ABNAT, and the clean teacher all predict correctly. Figure 9 shows that NAT is more confident than ABNAT on of these samples, with a mean confidence of 0.899 versus 0.678. However, its teacher-route fidelity is substantially worse than ABNAT's, with a KL divergence of 1.972 versus 0.338 and a top-10 token overlap of 0.178 versus 0.360. This confidence–route inconsistency shows that output-focused training can produce highly confident predictions from noise-corrupted attention routes, whereas ABNAT more faithfully preserves the teacher's internal routing.

Figure 10: Accuracy and training cost under selective block alignment.
Table 2: Hyperparameter sensitivity for ViT-Tiny on CIFAR-100. Bold marks the best setting in each sweep; shading marks defaults.
| Value | Avg. | Value | Avg. | Value | Avg. | Value | Avg. |
| 0.25 | 78.41 | 1 | 78.52 | 0.5 | 79.36 | 0.125 | 67.57 |
| 0.5 | 79.00 | 5 | 79.44 | 1 | 80.09 | 0.25 | 74.53 |
| 1 | 79.52 | 10 | 79.85 | 2 | 80.17 | 0.5 | 78.47 |
| 3 | 80.09 | 25 | 80.16 | 3 | 79.90 | 1 | 80.09 |
| 5 | 80.19 | 50 | 80.09 | 4 | 79.80 | 2 | 79.93 |
| 8 | 80.14 | 100 | 79.71 | 6 | 79.63 | 4 | 79.24 |
| 12 | 80.05 | 200 | 78.69 | 8 | 79.46 | 8 | 78.37 |
Accuracy-Training Cost Tradeoff Figure 10 evaluates structured block-selective variants against ABNAT with full alignment; here, S contains all heads in the selected blocks. Since attention alignment is training-only, all variants retain the same inference cost as NAT. Under the same four-block budget, Last4 outperforms First4 and Middle4, confirming that late blocks are more effective alignment targets. Accuracy improves and then saturates as the aligned late-block budget increases from Last1 to All. Last4 achieves 79.68% average accuracy, only 0.41 percentage points below full alignment at 80.09%, while reducing training-time overhead relative to NAT from 82.9% to 40.8% and peak-memory overhead from 54.4% to 23.3%. Thus, selective late-block alignment preserves nearly all robustness gains at substantially lower training cost.
Head-Budget Sensitivity Head-selective alignment improves smoothly with budget: average accuracy rises from 78.24% to 78.90% and 79.44% as top-k increases from 3 to 6 and 9 heads. At fixed k = 6, high-drift heads achieve 78.90% average accuracy, outperforming low-drift heads at 77.01% by 1.89 percentage points. These results show that ABNAT is not sensitive to one particular budget and validate the sensitivity-guided selection.
Hyperparameter Sensitivity Table 2 reports one-factor sweeps with all other settings fixed at their defaults. Around the defaults, , , and retain 79.71–80.19% average accuracy; yields 78.47–80.09%, while the overly sharp value 0.125 drops to 67.57%. Thus, ABNAT does not require delicate hyperparameter tuning.
5 Conclusion
In this paper, we show that CIM noise induces depth-accumulated, head-dependent attention drift, while output-centric NAT may reproduce answers through routes that deviate from the clean model. We propose ABNAT, which aligns headwise attention between clean and noisy paths from the same checkpoint to preserve task-relevant content processing rather than merely match answers. Across vision, language, and multimodal Transformers, ABNAT improves noisy accuracy by up to 11.28 percentage points, reduces attention drift by 85.77%, generalizes under train–deploy noise mismatch, and adds no inference cost; selective variants retain near-full robustness with lower training overhead.
Acknowledgments
This work was supported by National R&D Program of China (2022YFB4400300), NSFC (62534002, 62274003, 92564302) and 111 Project (B18001), in part by the STIC under Grant QYJS-2022-1501-B and the National Micro/Nano Fabrication Laboratory of Peking University.
References
[1] Samira Abnar and Willem Zuidema. 2020. Quantifying Attention Flow in Transformers. In Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics. 4190–4197. doi:10.18653/v1/2020.acl-main.385
[2] Stefano Ambrogio, British Narayanan, Hsinyu Tsai, Robert M. Shelby, Irem Boybat, Carmelo di Nolfo, Severin Sidler, Massimo Giordano, Martina Bodini, Nathan C. P. Farinha, Benjamin Killeen, Christina Cheng, Yassine Jaoudi, and Geoffrey W. Burr. 2018. Equivalent-Accuracy Accelerated Neural-Network Training Using Analogue Memory. Nature 558 (2018), 60–67. doi:10.1038/s41586-018-0180-5
[3] Stella Biderman, Hailey Schoelkopf, Quentin Gregory Anthony, Herbie Bradley, Kyle O'Brien, Eric Hallahan, Mohammad Aflah Khan, Shivanshu Purohit, USVSN Sai Prashanth, Edward Raff, Aviya Skowron, Lintang Sutawika, and Oskar Van Der Wal. 2023. Pythia: A Suite for Analyzing Large Language Models Across Training and Scaling. In Proceedings of the 40th International Conference on Machine Learning. 2397–2430.
[4] Geoffrey W. Burr, Robert M. Shelby, Stephan Sidler, Carlo di Nolfo, Jae Woo Jang, Irem Boybat, R. Shenoy, British Narayanan, Kumar Virwani, Eugenio Giacometti, B. Kurdi, and H.-S. Hwang. 2017. Neuromorphic Computing Using Non-Volatile Memory. Advances in Physics: X 2, 1 (2017), 89–124. doi:10.1080/23746149.2016.1259585
[5] Gouranga Charan, Jubin Hazra, Karsten Beckmann, Xiaocong Du, Gokul Krishnan, and Rajiv V. Joshi. 2020. Accurate Inference with Inaccurate RRAM Devices: Statistical Data, Model Transfer, and On-line Adaptation. In Proceedings of the 57th ACM/IEEE Design Automation Conference. 1–6. doi:10.1109/DAC18072.2020.9218605
[6] Wei-Hao Chen, Chunmeng Dou, Kai-Xiang Li, Wei-Yu Lin, Pin-Yi Li, Jian-Hao Huang, Jing-Hong Wang, Wei-Chen Wei, Cheng-Xin Xue, Yen-Cheng Chiu, Ya-Chin King, Chorng-Jung Lin, Ren-Shuo Liu, Chih-Cheng Hsieh, Kea-Tiong Tang, J. Joshua Yang, Mon-Shu Ho, and Meng-Fan Chang. 2019. CMOS-Integrated Memristive Non-Volatile Computing-in-Memory for AI Edge Processors. Nature Electronics 2 (2019), 420–428. doi:10.1038/s41928-019-0288-0
[7] Ping Chi, Shuangchen Li, Cong Xu, Tianhao Zhang, Jishen Zhao, Yongpan Liu, Yuan Wang, and Yuan Xie. 2016. PRIME: A Novel Processing-in-Memory Architecture for Neural Network Computation in ReRAM-Based Main Memory. In Proceedings of the 43rd International Symposium on Computer Architecture. 27–39.
[8] Kevin Clark, Urvashi Khandelwal, Omer Levy, and Christopher D. Manning. 2019. What Does BERT Look At? An Analysis of BERT's Attention. In Proceedings of the 2019 ACL Workshop BlackboxNLP: Analyzing and Interpreting Neural Networks for NLP. 276–286. doi:10.18653/v1/W19-4828
[9] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. 2021. An Image Is Worth 16x16 Words: Transformers for Image Recognition at Scale. In International Conference on Learning Representations.
[10] Geoffrey Hinton, Oriol Vinyals, and Jeff Dean. 2015. Distilling the Knowledge in a Neural Network. arXiv preprint arXiv:1503.02531 (2015). https://arxiv.org/abs/1503.02531
[11] Daniele Ielmini and H.-S. Philip Wong. 2018. In-Memory Computing with Resistive Switching Devices. Nature Electronics 1 (2018), 333–343. doi:10.1038/s41928-
018-0092-2
[12] Vinay Joshi, Manuel Le Gallo, Simon Haefeli, Irem Boybat, S. R. Nandakumar, Christophe Piveteau, Martino Dazzi, Bipin Rajendran, Abu Sebastian, and Evangelos Eleftheriou. 2020. Accurate Deep Neural Network Inference Using Computational Phase-Change Memory. Nature Communications 11 (2020), 2473. doi:10.1038/s41467-020-16108-9
[13] Wantong Li, Madison Manley, James Read, Ankit Kaul, Muhannad S. Bakir, and Shimeng Yu. 2023. H3DAtten: Heterogeneous 3-D Integrated Hybrid Analog and Digital Compute-in-Memory Accelerator for Vision Transformer Self-Attention. IEEE Transactions on Very Large Scale Integration (VLSI) Systems 31, 10 (2023), 1592–1602. doi:10.1109/TVLSI.2023.3299509
[14] Yi Li, Zijian Ye, Xiangqu Fu, Songqi Wang, Shucheng Du, Ning Lin, Dashan Shang, Jinshan Yue, Zhongrui Wang, Xiaojuan Qi, Feng Zhang, and Han Wang. 2025. Efficient Edge Vision Transformer Accelerator with Decoupled Chunk Attention and Hybrid Computing-In-Memory. In Proceedings of the 62nd ACM/IEEE Design Automation Conference. 1–7. doi:10.1109/DAC63849.2025.11132426
[15] Beiye Liu, Hai Li, Yiran Chen, Xin Li, Qing Wu, and Tingwen Huang. 2015. Vortex: Variation-Aware Training for Memristor X-Bar. In Proceedings of the 52nd Annual Design Automation Conference. 15:1–15:6. doi:10.1145/2744769.2744930
[16] Naoko Misawa, Tao Wang, Chihiro Matsui, and Ken Takeuchi. 2025. Transformer Hetero-CiM: Heterogeneous Integration of ReRAM CiM and SRAM CiM for Vision Transformer at Edge Devices. In Proceedings of the 30th Asia and South Pacific Design Automation Conference. 332–334. doi:10.1145/3658617.3698494
[17] Xiaochen Peng, Shanshi Huang, Hongwu Jiang, Anni Lu, and Shimeng Yu. 2021. DNN+NeuroSim V2.0: An End-to-End Benchmarking Framework for Computer-in-Memory Accelerators for On-Chip Training. IEEE Transactions on Computer-Aided Design of Integrated Circuits and Systems 40, 11 (2021), 2306–2319. doi:10.1109/TCAD.2020.3043731
[18] Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. 2021. Learning Transferable Visual Models From Natural Language Supervision. In Proceedings of the 38th International Conference on Machine Learning. 8748–8763.
[19] Malte J. Rasch, Charles Mackin, Manuel Le Gallo, An Chen, Andrea Fasoli, Frédéric Odermatt, Ning Li, S. R. Nandakumar, British Narayanan, Hsinyu Tsai, Geoffrey W. Burr, Abu Sebastian, and Vijay Narayanan. 2023. Hardware-Aware Training for Large-Scale and Diverse Deep Learning Inference Workloads Using In-Memory Computing-Based Accelerators. Nature Communications 14 (2023), 5282. doi:10.1038/s41467-023-40770-4
[20] James Read, Ming-Yen Lee, Wei-Hsing Huang, Yuan-Chun Luo, Anni Lu, and Shimeng Yu. 2025. NeuroSim V1.5: Improved Software Backbone for Benchmarking Compute-in-Memory Accelerators with Device and Circuit-Level Non-Idealities. arXiv preprint arXiv:2505.02314 (2025). doi:10.48550/arXiv.2505.02314
[21] Adriana Romero, Nicolas Ballas, Samira Ebrahimi Kahou, Antoine Chassang, Carlo Gatta, and Yoshua Bengio. 2015. FitNets: Hints for Thin Deep Nets. In International Conference on Learning Representations.
[22] Abu Sebastian, Manuel Le Gallo, Riduan Khaddam-Aljameh, and Evangelos Eleftheriou. 2020. Memory Devices and Applications for In-Memory Computing. Nature Nanotechnology 15 (2020), 529–544. doi:10.1038/s41565-020-0655-z
[23] Ali Shafiee, Abhronil Nag, Naveen Muralimanohar, Rajeev Balasubramonian, John Paul Strachan, Miao Hu, Robert Stanley Williams, and Vivek Srikumar. 2016. ISAAC: A Convolutional Neural Network Accelerator with In-Situ Analog Arithmetic in Crossbars. In Proceedings of the 43rd International Symposium on Computer Architecture. 14–26.
[24] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin. 2017. Attention Is All You Need. In Advances in Neural Information Processing Systems, Vol. 30. 5998–6008.
[25] Peng Yao, Huaqiang Wu, Bin Gao, Jianshi Tang, Qingtian Zhang, Wenqiang Zhang, J. Joshua Yang, and He Qian. 2020. Fully Hardware-Implemented Memristor Convolutional Neural Network. Nature 577 (2020), 641–646. doi:10.1038/s41586-020-1942-4
[26] Chuteng Zhou, Prad Kadambi, Matthew Mattina, and Paul N. Whatmough. 2020. Noisy Machines: Understanding Noisy Neural Networks and Enhancing Robustness to Analog Hardware Errors Using Distillation. arXiv preprint arXiv:2001.04974 (2020). https://arxiv.org/abs/2001.04974
[27] Wenyong Zhou, Zhengwu Liu, Taiqiang Wu, Chenchen Ding, Yuan Ren, and Ngai Wong. 2025. Towards Robust RRAM-Based Vision Transformer Models with Noise-Aware Knowledge Distillation. In 2025 Design, Automation & Test in Europe Conference (DATE). 1–2. doi:10.23919/DATE64628.2025.10993112