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
Clone and initialize submodules
git clone https://github.com/your-org/safe_dllm.git cd safe_dllm git submodule update --init --recursive
Create virtual environment
uv venv .venv --python 3.10 source .venv/bin/activate # Windows: .venv\Scripts\activate
Install dependencies
uv pip install -e .
Install AISafetyLab
cd AISafetyLab pip install -e . cd ..
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
Prepare data
python data/split_wildguardmix.py python data/build_mixed_arrow_dataset.py --config configs/sft_llada.yaml
Edit config (
configs/sft_llada.yaml)model: pretrained_model: "/path/to/llada_base" dataset: arrow_dirs: - "/path/to/your/mixed_arrow_dataset"
Run training (Slurm)
sbatch scripts/submit_1_node_4_gpus_dpspd2_sft_llada.slurmOr 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) |
|
Full HarmBench |
|
WildGuardMix D |
|
With custom rollout |
|
Multi-GPU (LLaDA on 0, Scorer on 1) |
|
Save raw responses |
|
Dry run (no inference) |
|
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.