betaFeedback

WorksComputer Science

How Fragile Is On-Device Language Model Safety? Localizing Safety-Critical Parameters for Sparse Fault Analysis

Abstract

As small language models (SLMs) are increasingly deployed on resource-constrained and on-device platforms, including as components of agentic systems, the integrity of locally stored model parameters becomes an important safety concern. We investigate whether safety-sensitive behavior in LLaMA-2-7B-Chat is concentrated within a sparse subset of parameters, creating a reduced fault surface for targeted analysis. We study two complementary localization methods: low-rank safety-associated subspace analysis and parameter-level safety–utility importance filtering. Both approaches reveal highly non-uniform safety sensitivity across the network, with the MLP down_proj consistently emerging as a prominent safety-sensitive component and o_proj providing a smaller contribution. Using parameter-level localization, modifying only 0.19% of model weights in down_proj yields 53% Basic ASR and 56% GCG ASR, while tinyBenchmarks accuracy remains at 51.6% compared with a 52.2% unmodified baseline. These results motivate targeted fault analysis and selective integrity protection for language models deployed in resource-constrained, on-device, and agentic settings.

Introduction

Language models are increasingly being deployed on edge and on-device platforms, including as components of resource-constrained agentic systems, offering benefits such as lower latency, improved privacy, and reduced dependence on cloud connectivity. However, local deployment also exposes model parameters to hardware-level reliability and integrity threats. Unlike prompt-based jailbreaks, faults in stored model weights can directly alter mechanisms responsible for aligned behavior and may persist across subsequent model interactions. This motivates a central question: can model safety be selectively degraded through sparse parameter modifications without broadly disrupting model functionality?

A practical bit-level attack on a billion-parameter model faces a large search problem: only a small fraction of model parameters may be directly relevant to safety behavior. We therefore adopt a localization-first perspective. If safety-sensitive behavior depends disproportionately on a structured subset of the parameter space, these regions may provide a substantially reduced candidate space for hardware fault analysis. Crucially, such localization should distinguish safety-associated parameters from those that are also important for general model utility, since indiscriminate corruption may simply degrade overall model quality.

We study this question in LLaMA-2-7B-Chat using two complementary approaches. First, we identify low-rank safety-associated subspaces by contrasting representations derived from safety and utility calibration data. Second, we perform parameter-level localization by identifying weights that are highly important for safety but comparatively less important for utility. Across both approaches, the MLP down_proj consistently emerges as a prominent safety-sensitive component, with a smaller contribution from the attention o_proj. Using parameter-level localization, modifying only 0.19% of model weights in down_proj yields 53% Basic ASR and 56% GCG ASR, while tinyBenchmarks accuracy remains at 51.6% compared with a 52.2% unmodified baseline.

Our contributions are threefold: (1) we analyze safety localization at both subspace and parameter levels; (2) we show that safety-sensitive parameter support is strongly concentrated in specific architectural components, particularly down_proj; and (3) we demonstrate that substantial safety degradation can be induced by modifying less than 0.2% of model weights while largely preserving measured general utility, motivating a reduced search space for future bit-level fault analysis and selective integrity protection in on-device language models, including those used as components of resource-constrained agentic systems.

Threat Model

We consider a white-box adversary targeting a safety-aligned language model deployed locally on an edge or on-device platform, including models that may serve as components of resource-constrained agentic systems. The adversary has access to the model parameters and may perform offline analysis to identify safety-sensitive regions, but does not retrain or fine-tune the model. The objective is to induce sparse parameter perturbations that degrade safety-aligned behavior while minimizing degradation of benign model utility.

This threat is particularly acute for SLMs deployed as components of agentic systems. Unlike a single-turn chat interaction, an agent’s safety behavior is invoked repeatedly and autonomously across a session, at each planning step, tool call, and intermediate action, often without a human in the loop to catch an unsafe output. A parameter-level fault therefore does not need to be re-triggered per turn, as a prompt-based jailbreak would: once induced, it persists silently across every subsequent invocation of the model within the agent loop, including invocations the user never directly observes (for example, internal planning or tool-selection steps). This makes the integrity of locally stored weights a distinct concern from prompt-level robustness in agentic deployments.

Our fault model does not require the adversary to modify inference-time prompts. We nevertheless evaluate the perturbed model under both standard harmful prompts and GCG adversarial suffixes, with the latter serving as a stress test of whether the induced safety degradation persists under a stronger adversarial prompting setting. The current experiments simulate parameter-level interventions rather than physical hardware faults. We therefore study localization of a reduced safety-sensitive parameter space as a precursor to fault analysis; mapping these parameters to a small number of physically realizable bit flips under specific numerical formats, memory architectures, and fault mechanisms is left to future work.

Related Work

Small and on-device language models for agentic systems. Recent work has highlighted small language models (SLMs) as efficient building blocks for agentic systems. Belcak et al. [2025] argue that SLMs are particularly well suited to specialized and repetitive tasks within agentic workflows, where reduced computational cost can enable more efficient deployment. Complementary work on MobileLLM [5] develops sub-billion-parameter models specifically for mobile deployment and demonstrates their capability on common on-device tasks, including API calling. Although there is no universally agreed-upon parameter threshold for SLMs, recent literature commonly includes models with up to approximately 7B parameters, with LLaMA-2-7B and Mistral-7B serving as representative examples [4]. Recent systems work further demonstrates that models at this scale can be executed locally on resource-constrained devices, including smartphones [11]. These trends motivate examining the integrity of safety mechanisms when language models are deployed locally as components of resource-constrained and agentic systems.

Safety localization in language models. Recent work has identified localized internal mechanisms associated with refusal and safety alignment. Arditi et al. [2024] showed that refusal behavior in instruction-tuned language models can be mediated by a low-dimensional direction in the residual stream. Wei et al. [2024] further identified sparse safety-relevant regions in parameter space at both parameter and rank levels while disentangling them from regions important for general utility. Building on this safety–utility perspective, we investigate whether localized safety-sensitive regions can provide a reduced candidate space for hardware-level fault analysis in on-device language models.

Bit-flip and fault attacks on neural networks. Bit-flip attacks modify the binary representation of model parameters stored in memory. Rakin et al. [ [7] introduced Progressive Bit Search, showing that a small number of targeted bit flips can severely degrade quantized neural networks. More recently, Coalson et al. [ [3] introduced PrisonBreak, demonstrating targeted bit-flip attacks against safety-aligned language models while largely preserving benign functionality. Zahran et al. [ [12] further studied fault-induced jailbreaking across FP16, FP8, INT8, and INT4 representations, showing that numerical format affects both attack effectiveness and vulnerable components. Unlike approaches that directly search for attack-effective bits, our work first localizes parameters that are disproportionately important for safety relative to utility, with the goal of exposing a compact fault surface for subsequent bit-level analysis.

Methodology

Our goal is to identify a small subset of model parameters that contribute disproportionately to safety-aligned behavior while remaining comparatively less important for general model utility. We study this using two complementary approaches: (1) low-rank safety subspace localization, which identifies safety-associated directions in representation space, and (2) parameter-level safety–utility localization, which identifies individual safety-sensitive weights.

We build on the safety–utility localization framework of Wei et al. [ [10] and investigate whether the resulting localized regions can provide a reduced candidate space for hardware fault analysis in on-device language models.

Calibration Datasets

We use two calibration datasets representing safety-aligned and general-purpose behavior. The safety set DsD_s consists of harmful instructions from AdvBench [13], paired with the model’s safety-aligned refusal responses. The utility set DuD_u uses Alpaca-Cleaned, a cleaned version of Stanford Alpaca [8], containing benign instruction–response pairs with safety-related examples removed. For both localization approaches, prompt tokens are masked and only response-token activations are used to characterize safety- and utility-associated behavior.

Low-Rank Safety Subspace Localization

We first characterize safety- and utility-associated representation subspaces within individual transformer projection modules. For a linear module with weight matrix W∈Rdout×dinW \in\mathbb{R}^{d_{\mathrm{out}} \times d_{\mathrm{in}}}, we collect response-token input activations XsX_s and XuX_u independently from DsD_s and DuD_u. We form the corresponding module outputs

As=XsWT,Au=XuWT,(1)A_s = X_s W^{\mathsf{T}}, \qquad A_u = X_u W^{\mathsf{T}}, \tag*{(1)}

and compute truncated singular value decompositions

As≈UsΣsVsT,Au≈UuΣuVuT.(2)A_s \approx U_s \Sigma_s V_s^{\mathsf{T}}, \qquad A_u \approx U_u \Sigma_u V_u^{\mathsf{T}}. \tag*{(2)}

Using the right singular vectors, we construct output-space projectors

Ps=VsVsT,Pu=VuVuT,Pu⊥=I−Pu.(3)P_s = V_s V_s^{\mathsf{T}}, \qquad P_u = V_u V_u^{\mathsf{T}}, \qquad P_u^{\perp} = I - P_u. \tag*{(3)}

We define a utility-orthogonalized safety-associated weight component as

ΔW=Pu⊥PsW(4)\Delta W = P_u^{\perp} P_s W \tag*{(4)}

and modify the module according to

W′=W−ΔW.(5)W' = W - \Delta W. \tag*{(5)}

This construction suppresses a weight component associated with safety-aligned behavior while reducing overlap with directions identified from benign utility data.

To examine whether this intervention can be localized to a smaller parameter set, we sparsify ΔW\Delta W by globally ranking its entries by absolute magnitude. For a retained fraction ρ\rho, we define

ΔWij(ρ)=ΔWijI[∣ΔWij∣≥τρ].(6)\Delta W_{ij}^{(\rho)} = \Delta W_{ij}\mathbb{I}[|\Delta W_{ij}| \ge\tau_\rho]. \tag*{(6)}

where τρ\tau_\rho is the global threshold corresponding to the desired fraction. The sparse intervention is then W′=W−ΔW(ρ)W' = W - \Delta W^{(\rho)}. We evaluate this procedure across all projection modules and under restrictions to specific architectural components.

Parameter-Level Safety–Utility Localization

Our second approach directly identifies individual weights that are important for safety-aligned behavior but comparatively less important for benign utility. For a projection module with weight matrix W∈Rdout×dinW \in\mathbb{R}^{d_{\mathrm{out}} \times d_{\mathrm{in}}}, let Xin∈Rdin×nX_{\mathrm{in}} \in\mathbb{R}^{d_{\mathrm{in}} \times n} denote its response-token input activations over a calibration dataset. Following an activation-aware importance criterion, we assign each weight WijW_{ij} an importance score

I(Wij)=∣Wij∣∥Xin,j,:∥2,(7)I(W_{ij}) = |W_{ij}| \lVert X_{\mathrm{in},j,:} \rVert_2, \tag*{(7)}

where Xin,j,:∈RnX_{\mathrm{in},j,:} \in\mathbb{R}^{n} denotes the activations of input feature jj across the calibration tokens, and ∥Xin,j,:∥2\lVert X_{\mathrm{in},j,:} \rVert_2 is its ℓ2\ell_2 norm. Thus, the importance score combines the magnitude of each weight with the activation magnitude of its corresponding input feature.

We compute Eq. (7) independently on DsD_s and DuD_u, producing safety scores IsI_s and utility scores IuI_u, respectively. Let SsS_s denote the set of highest-ranked weights under IsI_s, and let SuS_u denote the corresponding utility-important set. We define the safety-specific parameter set as

Sspec=Ss∖Su.(8)S_{\mathrm{spec}} = S_s \setminus S_u. \tag*{(8)}

This set difference removes weights that are important for both safety and general instruction-following behavior, leaving candidates that are comparatively more specific to safety.

We evaluate the functional effect of these parameters through sparse pruning:

wij′={0,(i,j)∈Sspec,wij,otherwise.(9)w'_{ij} = \begin{cases} 0, & (i,j) \in S_{\mathrm{spec}}, \\ w_{ij}, & \text{otherwise}. \end{cases} \tag*{(9)}

The resulting sparse masks identify individual candidate parameters whose removal disproportionately affects safety-associated behavior relative to the utility calibration set.

Architectural Localization and Sparse Intervention

Beyond parameter sparsity, we examine whether safety-sensitive structure is concentrated within particular transformer components. We consider the attention projections (q_proj, k_proj, v_proj, and o_proj) and MLP projections (gate_proj, up_proj, and down_proj) across transformer layers.

For the low-rank approach, we restrict the projected weight intervention ΔW(ρ)\Delta W^{(\rho)} to different groups of projection modules. For parameter-level localization, we similarly restrict pruning of SspecS_{\mathrm{spec}} to selected projection types and combinations of components. This analysis tests whether safety-sensitive interventions require broad modification of the network or can be localized to specific architectural regions, thereby reducing the candidate space for subsequent fault analysis.

Experimental Setup

Model and data. We conduct all experiments on LLaMA-2-7B-Chat [9], which falls within the commonly used parameter range for SLMs (§ 2) and provides a well-characterized, safety-aligned testbed with established attack and evaluation tooling. AdvBench [13] is split into 420 harmful instructions for attribution, AdvBenchattr_{\mathrm{attr}}, and 100 for evaluation, AdvBencheval_{\mathrm{eval}}. For safety attribution, we collect refusal responses from the aligned model on AdvBenchattr_{\mathrm{attr}}. Utility attribution uses Alpaca-Cleaned, a cleaned version of Stanford Alpaca [8], with safety-related examples removed.

Safety evaluation. We evaluate attack success rate (ASR) on AdvBencheval. Following Zou et al. [ [13], an attack is considered successful when the generated response lacks key refusal patterns. We report Basic ASR on harmful prompts without an adversarial suffix and GCG ASR using GCG adversarial suffixes [13].

Utility evaluation. General utility is measured using tinyBenchmarks [6]. The unmodified model achieves 52.2% accuracy, and we report post-intervention accuracy to measure broader capability degradation.

Interventions. For low-rank localization, we vary the retained fraction of the safety-associated weight intervention and its architectural scope. For parameter-level localization, safety- and utility-important weights are combined using the set-difference criterion in Eq. (8). We evaluate interventions across all projection modules, MLP projections, and selected individual projection types. Reported weight fractions are measured relative to the full model.

Results

Low-Rank Intervention Sparsity and Localization

Table 1 shows that retaining only the top 10% of the low-rank intervention preserves substantial safety degradation, while effectiveness drops sharply at 1%, indicating concentration among higher-magnitude modifications. Restricting the intervention to MLP projections retains much of the effect, and down_proj alone remains sufficient to induce notable safety degradation. Utility remains close to the 52.2% baseline across the more localized settings.

ModulesTop fractionBasic ASRGCG ASRUtility
All modules1.087%98%49.3%
All modules0.171%85%50.1%
All modules0.0136%25%50.7%
All modules0.00120%18%51.8%
MLP only1.077%89%49.8%
MLP only0.154%64%51.1%
down_proj1.051%43%51.2%
down_proj0.132%26%51.4%

Table 1. Low-rank intervention results across sparsity levels and architectural components. Utility denotes tinyBenchmarks accuracy; the unmodified model achieves 52.2%.

Parameter-Level Safety–Utility Localization

Table 2 shows strong architectural concentration in the parameter-level localization results. Restricting the intervention from all modules to MLP projections retains most of the safety effect, while further localization to down_proj and o_proj reduces the intervention to 0.23% of model weights while still achieving 58% Basic ASR and 60% GCG ASR. In particular, down_proj alone modifies only 0.19% of the model while yielding 53% Basic ASR and 56% GCG ASR, whereas o_proj alone is substantially weaker. Across both localization approaches, down_proj consistently emerges as the most prominent safety-sensitive component, with utility remaining near the unmodified baseline for these highly localized interventions.

Target componentWeights (%)Basic ASRGCG ASRUtility
All modules2.9591%97%47.1%
MLP only1.8786%94%49.7%
down_proj + o_proj0.2358%60%51.3%
down_proj0.1953%56%51.6%
o_proj0.0420%14%52.0%

Table 2. Sparse interventions using parameter-level safety–utility localization. Weight fraction is measured relative to the full model. Utility denotes tinyBenchmarks accuracy; the unmodified model achieves 52.2%.

Discussion

Our results indicate that safety-sensitive parameters are highly non-uniform across LLaMA-2-7B-Chat. Both localization approaches consistently identify the MLP down_proj as the most prominent component, with o_proj providing a smaller complementary contribution. The parameter-level intervention targeting only down_proj modifies 0.19% of model weights while still producing substantial safety degradation, with tinyBenchmarks accuracy remaining close to the unmodified baseline. This suggests that the safety-relevant parameter space is substantially smaller than the full model.

Parameter sparsity, however, should not be interpreted directly as bit-level vulnerability. Even 0.19% of a 7B-parameter model corresponds to millions of weights, whereas a practical hardware fault attack would ideally require only a small number of physically realizable bit modifications. Bit-level effects will also depend on numerical representation, memory architecture, and fault mechanism. Our current experiments therefore localize a reduced safety-sensitive parameter space, but do not yet demonstrate an end-to-end hardware attack.

The utility results provide initial evidence that localized interventions can degrade safety without proportionally degrading general capability, although tinyBenchmarks provides only a compact estimate of utility. These findings are particularly relevant to on-device and resource-constrained deployments, including language models used as components of agentic systems, where locally stored parameters may remain exposed throughout repeated model interactions. Future work will study whether these localized regions are enriched for high-impact bit-level faults, compare against random and magnitude-based baselines, and examine selective integrity protection for safety-sensitive regions in such deployments.

Conclusion

We show that safety-sensitive parameters in LLaMA-2-7B-Chat are structurally concentrated, with down_proj consistently emerging as the most prominent component across both low-rank and parameter-level localization. Parameter-level localization reduces the intervention to only 0.19% of model weights while achieving 53% Basic ASR and 56% GCG ASR, with utility remaining close to the unmodified baseline. These results suggest that safety-relevant behavior depends disproportionately on a small and structured portion of the parameter space, creating a reduced candidate surface for subsequent fault analysis. This concentration is particularly relevant for on-device and resource-constrained language models, including models used as components of agentic systems, where locally stored parameters may be exposed to hardware reliability and integrity faults. Future work will investigate whether these localized regions contain a similarly sparse set of high-impact, physically realizable bit-level vulnerabilities and whether selective integrity protection can efficiently harden such safety-sensitive regions.

References

  1. [3]Zachary Coalson, Jeonghyun Woo, Shiyang Chen, Yu Sun, Lishan Yang, Prashant Nair, Bo Fang, and Sanghyun Hong. Prisonbreak: Jailbreaking large language models with fewer than twenty-five targeted bit-flips. arXiv preprint arXiv:2412.07192, 2024.arxiv.org/abs/2412.07192
  2. [4]Flavio Corradini, Matteo Leonesi, and Marco Piangerelli. State of the art and future directions of small language models: A systematic review. Big Data and Cognitive Computing, 9(7):189, 2025. doi: 10.3390/bdcc9070189.DOI
  3. [5]Zechun Liu, Changsheng Zhao, Forrest Landola, Chen Lai, Yuandong Tian, Igor Fedorov, Yuny​​ang Xiong, Ernie Chang, Yangyang Shi, Raghuraman Krishnamoorthi, Liangzhen Lai, and Vikas Chandra. Mobilellm: Optimizing sub-billion parameter language models for on-device use cases. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 32431–32454. PMLR, 2024.arxiv.org/abs/2402.14905
  4. [6]Felipe Maia Polo, Lucas Weber, Leshem Choshen, Yuekai Sun, Gongjun Xu, and Mikhail Yurochkin. tinybenchmarks: Evaluating llms with fewer examples. In Proceedings of the 41st International Conference on Machine Learning, volume 235, pages 34303–34326. PMLR, 2024.arxiv.org/abs/2402.14992
  5. [7]Adnan Siraj Rakin, Zhezhi He, and Deliang Fan. Bit-flip attack: Crushing neural network with progressive bit search. In Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019.arxiv.org/abs/1903.12269
  6. [8]Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li, Carlos Guestrin, Percy Liang, and Tatsunori B. Hashimoto. Stanford alpaca: An instruction-following llama model. https://github.com/tatsu-lab/stanford_alpaca, 2023.
  7. [9]Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023.arxiv.org/abs/2307.09288
  8. [10]Boyi Wei, Kaixuan Huang, Yangsibo Huang, Tinghao Xie, Xiangyu Qi, Mengzhou Xia, Prateek Mittal, Mengdi Wang, and Peter Henderson. Assessing the brittleness of safety alignment via pruning and low-rank modifications. In Proceedings of the 41st International Conference on Machine Learning, 2024.arxiv.org/abs/2402.05162
  9. [11]Zhenliang Xue, Yixin Song, Zeyu Mi, Xinrui Zheng, Yubin Xia, and Haibo Chen. Powerinfer-2: Fast large language model inference on a smartphone, 2024.arxiv.org/abs/2406.06282
  10. [12]Nou reldin Zahra​​n, Ahmad Tahmasivand, Ihsen Alouani, Khaled N. Khasawneh, and Mohammed Fouda. On jailbreaking quantized language models through fault injection attacks. In Proceedings of the Great Lakes Symposium on VLSI 2025, pages 554–561. ACM, 2025. doi: 10.1145/3716368.3735302.
  11. [13]Andy Zou, Zifan Wang, Nicholas Carlini, Milad Nasr, J. Zico Kolter, and Matt Fredrikson. Universal and transferable adversarial attacks on aligned language models. arXiv preprint arXiv:2307.15043, 2023.arxiv.org/abs/2307.15043

Paper details

vlnc:W_gqxrrqj4
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents