Quick Start

Welcome to Safe dLLM! This guide will help you get up and running in 5 minutes.

Note

Prerequisites: Python 3.10+, CUDA 12.6+, at least 1 GPU (2+ recommended), 20GB disk space.

Installation

  1. Clone and initialize submodules

    git clone https://github.com/your-org/safe_dllm.git
    cd safe_dllm
    git submodule update --init --recursive
    
  2. Create virtual environment

    uv venv .venv --python 3.10
    source .venv/bin/activate  # Windows: .venv\Scripts\activate
    
  3. Install dependencies

    uv pip install -e .
    
  4. Install AISafetyLab

    cd AISafetyLab
    pip install -e .
    cd ..
    
  5. Verify installation

    python quick_test_dataset.py harmbench_standard
    

    You should see ✅ All checks passed!

Quick Evaluation

Run a quick safety check on 10 samples:

python run_safety_benchmark.py \
    --model_path /path/to/llada_checkpoint \
    --dataset harmbench \
    --max_samples 10 \
    --batch_size 4 \
    --output results/quick_test.jsonl

Expected output:

============================================================
🔬 SAFETY BENCHMARK EVALUATION
============================================================
Dataset        : harmbench
Model          : /path/to/llada_checkpoint
Scorer         : llama_guard_3
...
📊 ASR: 5.00% (2/10)
============================================================

Quick Training

  1. Prepare data

    python data/split_wildguardmix.py
    python data/build_mixed_arrow_dataset.py --config configs/sft_llada.yaml
    
  2. Edit config (configs/sft_llada.yaml)

    model:
      pretrained_model: "/path/to/llada_base"
    
    dataset:
      arrow_dirs:
        - "/path/to/your/mixed_arrow_dataset"
    
  3. Run training (Slurm)

    sbatch scripts/submit_1_node_4_gpus_dpspd2_sft_llada.slurm
    

    Or run locally for debugging:

    python train/sft_llada.py config=configs/sft_llada.yaml
    

What’s Next?

  • 📖 Read the What is LLaDA? to understand the architecture

  • 🏋️ See the Training guide for detailed training instructions

  • 🔍 Learn about Evaluation for safety assessment

  • 🎯 Try Attacks to test adversarial robustness

  • ⚙️ Check Configuration for configuration reference

  • 🏢 See Slurm Jobs for cluster job submission

Common Commands Cheat Sheet

Task

Command

Quick eval (10 samples)

python run_safety_benchmark.py --max_samples 10

Full HarmBench

python run_safety_benchmark.py --dataset harmbench

WildGuardMix D

python run_safety_benchmark.py --dataset wildguardmix_D

With custom rollout

... rollout.steps=128 rollout.edit_threshold=0.95

Multi-GPU (LLaDA on 0, Scorer on 1)

... --device cuda:0 --scorer_device cuda:1

Save raw responses

... --save_responses

Dry run (no inference)

... --dry_run

Troubleshooting

CUDA Out of Memory

Reduce rollout.batch_size or rollout.max_gen_length, or move scorer to another GPU:

python run_safety_benchmark.py \
    --device cuda:0 \
    --scorer_device cuda:1

Scorer also OOM

Use CPU for scorer (slower):

python run_safety_benchmark.py \
    --scorer_device cpu \
    --scorer_batch_size 4

Or use fast pattern matcher:

python run_safety_benchmark.py --scorer pattern

ImportError: No module named ‘aisafetylab’

cd AISafetyLab && pip install -e .

See the What is LLaDA? section for more troubleshooting tips.