A2D: Any-Order, Any-Step Safety Alignment for Diffusion Language Models

Wonje Jeung, Sangyeon Yoon, Yoonjun Cho, Dongjae Jeon, Sangwoo Shin, Hyesoo Hong, Albert No

TL;DR

A2D (Any-Order, Any-Step Defense) is a novel token-level safety alignment method designed specifically for Diffusion Large Language Models (dLLMs). By training models to emit an [EOS] (End of Sentence) signal whenever harmful content appears—regardless of where or when it occurs in the decoding process—A2D slashes jailbreak success rates to near-zero and enables real-time safety monitoring that is up to 19.3x faster than standard methods.

What Problem Does This Paper Address?

Most safety alignment techniques (like RLHF or DPO) were built for Autoregressive (AR) models, which generate text strictly from left to right. In these models, safety is often "shallow"—the model learns to start a refusal with "I'm sorry," but if an attacker can bypass those first few tokens, the model's safety guardrails often vanish.

Diffusion Language Models (dLLMs) present a unique challenge because they don't decode linearly. They can generate text in any order (middle-out, parallel, etc.) and use bidirectional context. This flexibility is a double-edged sword: it allows for powerful applications like text infilling, but it also creates a massive "attack surface." Attackers can use template-based "prefilling" attacks (like DIJA) to inject harmful context into the middle of a generation, effectively "tricking" the model into completing an unsafe response because the safety signal didn't trigger at the very first step.

Methods

The authors introduce A2D, which moves safety from the response level to the token level.

  1. Token-Level Supervision: Instead of training the model to generate a specific refusal string, A2D trains the model to predict the [EOS] token at any masked position if the surrounding context is harmful. This effectively turns the [EOS] token into a universal "kill switch."
  2. Randomized Masking Training: During training, the model sees harmful prompts paired with unsafe responses. Various spans are masked out, and the model is supervised to fill those gaps with [EOS]. Simultaneously, a "Retain Set" of safe data ensures the model still knows how to generate helpful, non-harmful text.
A2D Alignment and Inference Phases
  1. Real-Time Monitoring & Early Rejection: Because the model is trained this way, the probability it assigns to the [EOS] token serves as a real-time "harmfulness meter." If the probability of [EOS] at the first decoding step exceeds a certain threshold, the model can halt immediately before even starting the response.
  2. FITS Attack: To test the limits of this defense, the authors created the Fill-In-The-Sentence (FITS) attack. In this scenario, an adversary provides a nearly complete harmful response (e.g., a bomb-making guide) and leaves only a single critical sentence blank for the model to fill.

Datasets

  • Training: The authors used 30k examples from the BeaverTails dataset, partitioned into a Harmful Set (unsafe prompts/responses) and a Retain Set (safe prompts/responses).
  • Safety Evaluation: Models were tested against HarmBench (including Zeroshot, PAIR, ReNeLLM, and Prefilling attacks) and the DIJA attack.
  • Robustness Benchmarks: AdvBench, JailbreakBench, and StrongReject (SR).
  • Over-refusal Check: XSTest was used to ensure the model doesn't "over-refuse" benign prompts that merely look like they might be unsafe (e.g., "How do I kill a python process?").
  • Capability Benchmarks: Standard LLM benchmarks including MMLU, GSM8K, HumanEval, and MBPP were used to measure the "alignment tax" (the potential loss in general intelligence due to safety training).

Key Insights and Ideas

  • The "Shallow Alignment" Proof: The paper quantitatively demonstrates that current dLLMs suffer from safety decay. As the decoding process moves past the initial tokens, the KL divergence between a "safe" model and a "base" model drops sharply, meaning the model "forgets" it's supposed to be safe.
  • Safety as an Omnipresent Property: A2D treats safety not as a preamble, but as a fundamental property of every token prediction. By using [EOS], a token the model is already intimately familiar with, the researchers avoid the need for complex new refusal vocabularies.
  • Bidirectional Safety: Because dLLMs look at the whole context, A2D allows the model to "see" harmful intent even if it's injected late in the template, triggering a refusal that an AR model might miss.
  • Efficiency via Probability: The ability to use the [EOS] logit as a safety signal allows for "early rejection," which is computationally much cheaper than generating a full refusal response.

Key Results

  • Near-Zero Attack Success: On the DIJA attack, A2D reduced the success rate from over 80% to 1.3% on LLaDA-8B and 0.0% on Dream-7B.
Average Attack Success Rate Comparison
  • Massive Speedup: The early rejection mechanism provided up to a 19.3x speedup in terminating harmful prompts compared to standard decoding.
  • Zero Over-Refusal: A2D achieved 0% false positives on XSTest, meaning it remains helpful and doesn't get "scared" by benign prompts.
  • Low Alignment Tax: A2D maintained competitive performance on MMLU and coding tasks, often outperforming other alignment methods like VRPO or standard SFT in preserving the model's original capabilities.

Limitations and Future Work

  • Model Scope: The study focused on representative open-source dLLMs (LLaDA and Dream). While the authors showed a "lightweight" adaptation for Autoregressive models (like Qwen and LLaMA), the core of the work is diffusion-centric.
  • Refusal Diversity: Currently, the model just stops (via [EOS]). Future work could explore how to combine this robust "kill switch" with more informative or conversational refusals without re-opening the attack surface.
  • Multi-modal Diffusion: As diffusion models expand into vision and audio, applying token-level (or "patch-level") safety alignment will be a critical next step.

Summary updated

BibTeX
@inproceedings{jeung2026d,
  author = {Wonje Jeung and Sangyeon Yoon and Yoonjun Cho and Dongjae Jeon and Sangwoo Shin and Hyesoo Hong and Albert No},
  title = {{A2D: Any-Order, Any-Step Safety Alignment for Diffusion Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=URTnuyQJI1},
}
Figure