Compressing an aligned language model to 3–4 bits per weight can quietly break its safety training. The compressed model may write nearly the same fluent text as the original, yet answer harmful requests the original refused. Today the only way to check a compressed model is to attack it again, with humans or with automated jailbreak search. That costs tens to hundreds of thousands of queries per model and only shows that some attacks fail.
We propose a different check: a small, worst-case mathematical proof attached to the compression step. The proof says that, for every internal state in a specified region around harmful prompts, quantizing the model's deep layers cannot move its internal "refuse" signal across the decision threshold. The proof's slack also decides how many bits each layer gets. Automated red-teaming plays two roles. It defines the region the proof must cover, and afterwards it searches for prompts that escape that region. This replaces open-ended jailbreak search with a narrower target whose success can be checked.
Core Claim
Three facts make this tractable now.
First, the damage is localized. Toward Safe Quantization-Aware Fine-tuning shows with linear probes that quantization degrades safety mainly in deep layers. Shallow layers stay stable. This supplies both the target and the "refusal direction" probe we reuse.
Second, safety and utility come apart under compression. Alignment-Aware Quantization for LLM Safety reports that standard GPTQ on LLaMA3.1-8B falls to a SafetyBench safety score of 36.6 while utility is largely retained. Mixed-precision allocators that optimize perplexity therefore have no reason to protect refusal. This includes APTQ, which uses attention-aware Hessian sensitivity, and QUIK, which keeps outlier-heavy down-projections at 8 bits.
Third, there is a structural observation the quantized-network verification literature has not used. Bit-exact verification of quantized networks is PSPACE-hard (Scalable Verification of Quantized Neural Networks) and stalls at about 52,000 parameters or 894 neurons (QVIP). That hardness comes from quantized activations, which turn smooth functions into staircases.
Weight-only quantization (low-bit weights, 16-bit activations, the regime QUIK identifies as the one that matters for memory-bound decoding) has no staircases. The compressed and original blocks apply the same smooth nonlinearities. Inside each linear map, the difference between them is the exactly linear term $(W-\hat W)x$, where $W$ is the original weight matrix and $\hat W$ its quantized version. So the differential reachability idea of QEBVerif becomes tractable at LLM scale, provided we verify block by block rather than monolithically. QEBVerif propagates error intervals between a full-precision network and its quantized twin, falling back to an exact integer solver when needed; we keep the interval propagation and drop the fallback.
The claim is this. A compositional certificate over a red-team-derived region of deep-layer states can serve two purposes for weight-only mixed precision on 7–8B models. It is a sound guarantee on the refusal signal, and it is a better bit-allocation signal than curvature. It is better because it bounds worst-case deviation over the attack region rather than average loss sensitivity on generic text.
Research Program
We borrow the decomposition from software "unit proofing" (Enabling Unit Proofing for Software Implementation Verification). That work verifies each module under its own precondition and postcondition instead of verifying the whole system. Here each module is one transformer block among the last $M-L$ blocks, the deep layers where safety erodes.
The precondition is a set $S_L$ of residual-stream states at layer $L$ for the final token position. It is built as a union of axis-aligned boxes, with a fixed margin, around the states produced by three sources: HarmBench behaviors, prompts from automated attackers run against the full-precision model, and paraphrase or transfer variants. We keep only prompts the full-precision model refuses.
For each block $l$, a sound bound-propagation pass computes two quantities over the propagated region $S_{l-1}$:
- a certified gain $\alpha_l$, meaning how much an incoming deviation can be amplified by the block;
- a certified fresh deviation $\beta_l(b_l)$, meaning the extra output error introduced by quantizing that block's weights to bitwidth $b_l$.
This pass uses interval and linear relaxations through LayerNorm, attention and the MLP, with outward rounding so it stays sound under 16-bit floating point. The pieces compose:
$$\epsilon_l = \alpha_l\,\epsilon_{l-1} + \beta_l(b_l), \qquad \epsilon_L = 0,$$
where $\epsilon_l$ bounds how far the quantized model's residual state can be from the original at layer $l$. The postcondition is that the refusal probe $r$ at layer $M$ keeps its sign: $\lVert r\rVert\,\epsilon_M < m(S_L)$, where $m$ is the smallest probe margin the original model attains over the propagated region.
Bit allocation is then a small integer program. We minimize total weight memory over per-block choices of 2, 3, 4 or 8 bits, subject to this inequality. The quantity being solved is the allocation, not the network, so the integer program is tiny. Shallow blocks before $L$ are quantized by a standard allocator, since the certificate's precondition only depends on states at layer $L$ landing in $S_L$.
The verifier also yields counterexamples: deep-layer states inside $S_L$ where the bound fails to close. We hand these to an automated red-teamer, an AgenticRed-style evolved attacker (AgenticRed). Its objective is to find a real prompt whose layer-$L$ state lands near the counterexample, or anywhere outside $S_L$. Prompts it finds either enlarge $S_L$ for the next round or show that the certified region misses a real attack.
This is where red-teaming changes character. The open question "is there any jailbreak?" becomes the checkable question "is there a prompt whose deep state escapes a known set?" That gives a coverage number in place of an unbounded search.
We state the guarantee's limits plainly. It certifies an internal refusal signal over a region, not generated text over all prompts. Whether the signal predicts behavior is an empirical question, and the experiments below test it directly. Interval bounds can also blow up with depth, the failure QEBVerif reports for naive propagation. If the bounds are too loose beyond a few blocks, we will shrink $M-L$ or tighten regions per cluster, and we will report the verifiable depth as a primary result.
Baselines
Uniform round-to-nearest and GPTQ-style 4-bit weight-only quantization. This is the do-nothing reference. It shows how much refusal erodes when no one protects it.
APTQ-style Hessian mixed precision (APTQ) and QUIK-style outlier retention (QUIK). These are the strongest utility-driven allocators. APTQ reports C4 perplexity 5.22 at an average 4 bits and zero-shot accuracy 68.24% on LLaMa-7B at 3.8 bits. We run them at matched average bitwidth on the same models and calibration budget.
Safety-calibrated Fisher allocation. This is the strongest simple competitor we can construct, and the one we take most seriously. It is the APTQ machinery with its sensitivity computed from the refusal-probe loss on the same harmful prompts and red-team states that define $S_L$. It sees exactly our data and differs only in using average second-order sensitivity instead of worst-case certified slack.
Deep-layers-at-8-bit heuristic. This rule follows directly from the deep-layer finding in Toward Safe Quantization-Aware Fine-tuning, at matched memory.
Alignment-Aware Quantization. AAQ (Alignment-Aware Quantization for LLM Safety) changes weights with a pull-toward-aligned, push-away-from-base loss. Its paper reports a SafetyBench safety score of 60.1 on LLaMA3.1-8B, against 36.6 for GPTQ and 57.5 for OSTQuant, in the W4A4 setting. We rerun AAQ in weight-only mode, and also stack it with our allocation, since the two are complementary. We found no reported result on Lacuna for HarmBench attack success rate on mixed-precision post-training-quantized models, so those numbers will be produced here for every baseline under identical attacks.
Ablations. Two ablations isolate the proposal's ingredients:
- Allocation-only ablation: keep the certified allocator but build $S_L$ from static AdvBench/HarmBench prompts only, with no red-team states. This isolates what the red-team-derived region contributes.
- Certificate-only ablation: take the safety-Fisher allocation and merely run our verifier on it. This separates "certificate as auditor" from "certificate as allocator."
What counts as beating the baselines. Beating safety-Fisher means lower quantization-induced attack success at equal average bitwidth with perplexity within 0.5 of FP16, the tolerance QUIK reports. Alternatively, it means equal attack success at fewer bits, together with a certificate that safety-Fisher cannot supply.
Why not just…?
Why not just allocate bits with a Hessian computed on harmful prompts? This is the real threat. It may match us on empirical attack success, because the deep-layer finding suggests the "right" layers are easy to identify. If it does, the allocator half of the claim fails. What remains is the auditor half: a worst-case certificate and a region-escape objective for red-teaming. Curvature methods have no notion of a covered region, so they cannot produce either. The certificate-only ablation measures exactly this, and we will report it as the outcome if allocation gains vanish.
Why not just use AAQ or ExSQF, which already restore safety without formal machinery? Both calibrate on fixed prompt sets; ExSQF uses only 128 AdvBench prompts. Static sets fail against adaptive attackers. Better Attacks for Better Monitors shows a monitor's catch rate falling from 94.9% to 60.3% once attacks are refined, for exactly this kind of reason. Neither method can say which inputs are protected. Since AAQ modifies weights and we choose bitwidths, we test AAQ alone, ours alone, and the two combined against adaptive attacks run on the compressed model.
Why not just re-run automated red-teaming on every compressed model? It works but gives only a lower bound on vulnerability. It is also expensive: AgenticRed needs over 100,000 discovery queries, and Boundary Point Jailbreaking reports up to 800,000 queries against production classifiers. We measure the query cost of the escape-$S_L$ objective against unconstrained jailbreak search for reaching the same quantization-induced failures.
Proposed Experiments
We use Llama-2-7B-chat and Llama-3.1-8B-Instruct with weight-only mixed precision at average budgets of 3 and 4 bits. Utility is measured with WikiText-2 and C4 perplexity, LM-Eval-Harness zero-shot accuracy and GSM8K. Safety is measured with SafetyBench for comparability with AAQ and with HarmBench, whose classifier reports 93.19% agreement with humans. All HarmBench runs use a fixed 512-token generation limit, because HarmBench reports that the limit alone can shift attack success by up to 30%.
For each attack (direct requests, gradient-based suffixes, tree-search attacks and an AgenticRed-style evolved attacker), we report two numbers. The first is overall attack success. The second, more important one is quantization-induced attack success: prompts the original model refuses and the compressed model answers. AgenticRed reports 96% overall success on Llama-2-7B, which shows overall success saturates and why the induced rate is the meaningful metric.
The decisive check tests the whole chain from certificate to behavior. Take every quantization-induced jailbreak found by fresh attacks on our compressed model, attackers not used to build $S_L$, and test whether its layer-$L$ state lies inside the certified region. Soundness of the bound plus a faithful refusal probe predicts zero such cases.
Each outcome tells us something specific:
- Zero cases inside the region: the guarantee transfers from signal to behavior.
- Cases inside the region but with the probe certified to keep its sign: the probe is the weak link, not the verifier.
- Most induced jailbreaks escaping the region: we report coverage, the fraction of induced jailbreaks inside the region, as the honest measure of what the certificate buys. We also check whether counterexample-guided rounds raise coverage faster than adding the same number of random red-team prompts.
Finally, we report the deepest stretch of blocks for which bounds close at practical bitwidths. This tells the verification community where block-wise differential analysis stops scaling on real transformers.
References
- Toward Safe Quantization-Aware Fine-tuning: Understanding and Mitigating Safety Alignment Degradation
- Alignment-Aware Quantization for LLM Safety
- APTQ: Attention-aware Post-Training Mixed-Precision Quantization for Large Language Models
- QUIK: Towards End-to-end 4-Bit Inference on Generative Large Language Models
- Scalable Verification of Quantized Neural Networks
- QVIP: An ILP-based Formal Verification Approach for Quantized Neural Networks
- QEBVerif: Quantization Error Bound Verification of Neural Networks
- A Unit Proofing Framework for Code-level Verification: A Research Agenda
- AgenticRed: Optimizing Agentic Systems for Automated Red-teaming
- Better Attacks for Better Monitors: Semi-Automated Red-Teaming for Agent Monitoring
- Boundary Point Jailbreaking of Black-Box LLMs
- HarmBench: A Standardized Evaluation Framework for Automated Red Teaming and Robust Refusal