Renaissance LabsLearn

Recipes · Preference tuning

Full-weight DPO on 1.4 million preference pairs

Take a supervised fine-tuned 9B model and tune it on pairs of preferred and rejected answers. One epoch, every weight updated, 32 GPUs, under two days.

From OpenEuroLLMRecipe by Birger MoellRun once by its author. Not yet reproduced by anyone else.

CapabilityBehaving as intended

Preference tuningMultilingual

Makes19B checkpoint
Cook time43 h 21 mwall clock
Equipment32GPUs, 4 nodes
Ingredients1.44Mpreference pairs

1Ingredients

1,441,547 preference pairs from three sources, plus 15,824 held out for validation. 43,191 pairs (2.9%) were removed in cleaning.

  • Dolci, translatedopeneurollm/Dolci-Instruct-DPO-translated12 languages · Apache 2.0
    1,352,76393.8%
    Pinned
  • UltraFeedback, cleanedargilla/ultrafeedback-binarized-preferences-cleanedEnglish · MIT
    59,8894.2%
    Not pinned
  • HelpSteer3, preferencenvidia/HelpSteer3English; ties dropped (2,257) · CC BY 4.0
    28,8952.0%
    Not pinned
Languages in the largest source
  • en243k
  • es126k
  • sv121k
  • pl119k
  • ro116k
  • cs116k
  • uk115k
  • de115k
  • fi109k
  • el101k
  • it87k
  • fr14k

Training pairs per language in the translated source. The evaluation covers 36 languages, so most were not in the preference data.

Fingerprints of the six staged files (SHA-256)
dolci-train.jsonl.gz4b90b32da776…52025d
dolci-validation.jsonl.gze977ef3b7985…361093
helpsteer3-train.jsonl.gzadef5ff99bcc…3db14c
helpsteer3-validation.jsonl.gz2d62737ce26d…3b7a11
ultrafeedback-train.jsonl.gzdeec7153e13b…7c4788
ultrafeedback-validation.jsonl.gz6aaa875a7d42…bfdf4c

2Pinned inputs

Everything that must match for a faithful rerun.

Base model
Neonkraft/oellm-9b-256k-theta64m-prelude-anneal300b-instruct-sft85bf18fb4f0bee6ac6270f06b1d1c6b3be200f31
Training code
github.com/BirgerMoell/post-training64f3599 (from upstream db9d560011cb4502adaffe1ba3a94b87f9f404f4)
Container
laif-rocm-6.4.4-pytorch-2.9.1-te-2.4.0-fa-2.8.0-triton-3.2.0.sifplus a project overlay of Python libraries
Software
TRL 0.28.0 · Transformers 4.57.3 · PyTorch 2.9.1+rocm6.4Datasets 4.6.0 · Tokenizers 0.22.2
Seed
42data split and training

3Equipment

4 nodes with 8 GPUs each (AMD MI250 (LUMI, partition small-g)). 43 h 21 min of wall time, about 1,387 GCD-hours. The wall-clock time includes the final evaluation. The job requested 2 days.

Node 1
56 CPUs · 480 GB
Node 2
56 CPUs · 480 GB
Node 3
56 CPUs · 480 GB
Node 4
56 CPUs · 480 GB

4Method

Paths in angle brackets are yours to fill in. Account IDs and personal paths have been removed.

  1. 1

    Get the code

    Check out the exact training code.

    git clone https://github.com/BirgerMoell/post-training
    cd post-training
    git checkout 64f3599
  2. 2

    Prepare the base model

    Download the base model at the pinned revision. Then fix its tokenizer. The run used a repaired tokenizer configuration, and loading the original may not reproduce the training startup. Use the two files from the release.

    hf download Neonkraft/oellm-9b-256k-theta64m-prelude-anneal300b-instruct-sft \
      --revision 85bf18fb4f0bee6ac6270f06b1d1c6b3be200f31 --local-dir <SCRATCH>/artifacts/model
    hf download birgermoell/oellm-9b-threeway-dpo-full-v1 \
      base_tokenizer_config_used.json tokenizer.model --local-dir ./release-files

    Check this. Confirm exactly how the two release files replace the base model's tokenizer files.

  3. 3

    Stage the data

    The staging script builds the six training and validation files. It reads HelpSteer3 from files you must prepare first (preference-train.jsonl.gz and preference-validation.jsonl.gz), and it does not download them. Set the two path constants at the top of the script, then run it and check the fingerprints.

    python stage_threeway_dpo_full.py
    cd <WORK>/artifacts/data/threeway-full
    sha256sum -c data_checksums.sha256

    Check this. HelpSteer3 and UltraFeedback were not revision-pinned, so the checksums only match if the sources have not changed.

  4. 4

    Set the paths

    Copy the frozen config from the release. Change the model path and the six data paths to your own.

    cp training_config.yaml <WORK>/configs/oellm-9b-threeway-dpo-full-lumi.yaml
  5. 5

    Launch

    Submit from the checked-out training repository. The script uses its src folder, scripts/train.py and configs/accelerate/fsdp_lumi.yaml.

    sbatch training_slurm.sbatch
The launch script, with placeholders
#!/bin/bash
#SBATCH --job-name=oellm-3way-dpo-full
#SBATCH --account=<your-project>
#SBATCH --partition=small-g
#SBATCH --nodes=4
#SBATCH --gpus-per-node=8
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=56
#SBATCH --mem=480G
#SBATCH --time=2-00:00:00
#SBATCH --signal=B:USR1@300
#SBATCH --output=<WORK>/logs/%j.out
#SBATCH --error=<WORK>/logs/%j.err

set -euo pipefail
module purge

GPUS_PER_NODE=8
TRAIN_CONFIG=<WORK>/configs/oellm-9b-threeway-dpo-full-lumi.yaml
CONTAINER=<SCRATCH>/containers/laif-rocm-6.4.4-pytorch-2.9.1-te-2.4.0-fa-2.8.0-triton-3.2.0.sif
OVERLAY=<SCRATCH>/pylibs-overlay
BIND=/pfs,/scratch,/flash,/project,/projappl,/appl,/opt/cray,/var/spool/slurmd
HF_CACHE=<WORK>/artifacts/cache/huggingface

mkdir -p "$HF_CACHE" <WORK>/outputs
export MASTER_ADDR=$(scontrol show hostnames "$SLURM_JOB_NODELIST" | head -n 1)
export MASTER_PORT=$(python3 -c "import socket; s=socket.socket(); s.bind(('', 0)); print(s.getsockname()[1]); s.close()")
export NCCL_SOCKET_IFNAME=hsn0,hsn1,hsn2,hsn3 NCCL_NET_GDR_LEVEL=PHB FI_CXI_DEFAULT_CQ_SIZE=131072
export TORCH_NCCL_TRACE_BUFFER_SIZE=1048576 TORCH_NCCL_DUMP_ON_TIMEOUT=1 TORCH_NCCL_DESYNC_DEBUG=1
export OMP_NUM_THREADS=7 PYTORCH_HIP_ALLOC_CONF=expandable_segments:True PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
WORLD_SIZE=$(( GPUS_PER_NODE * SLURM_NNODES ))

echo "Full three-way DPO: config=$TRAIN_CONFIG nodes=$SLURM_NNODES world=$WORLD_SIZE"
srun --label --export=ALL --wait=60 --kill-on-bad-exit=1 singularity exec -B "$BIND" "$CONTAINER" bash -lc "
  set -euo pipefail
  export PYTHONPATH=$OVERLAY:$SLURM_SUBMIT_DIR/src:\${PYTHONPATH:-}
  export HF_HOME=$HF_CACHE HF_HUB_CACHE=$HF_CACHE/hub HUGGINGFACE_HUB_CACHE=$HF_CACHE/hub HF_DATASETS_CACHE=$HF_CACHE/datasets
  export HF_HUB_OFFLINE=1 HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 HF_HUB_DISABLE_TELEMETRY=1 WANDB_MODE=disabled
  export ACCELERATE_USE_FSDP=true FSDP_CPU_RAM_EFFICIENT_LOADING=1
  cd $SLURM_SUBMIT_DIR
  accelerate launch \
    --config_file configs/accelerate/fsdp_lumi.yaml \
    --num_machines $SLURM_NNODES \
    --num_processes $WORLD_SIZE \
    --machine_rank \$SLURM_PROCID \
    --main_process_ip '$MASTER_ADDR' \
    --main_process_port '$MASTER_PORT' \
    scripts/train.py --config $TRAIN_CONFIG accelerate.use_deepspeed=false deepspeed=null
"

5Settings

Objective
DPO, sigmoid loss, beta 0.1
Reference model
The frozen SFT starting model
Epochs
1 (11,263 optimizer steps)
Learning rate
5e-7, cosine schedule
Warmup
3%
Batch size
128 effective, 1 per device
Optimizer
Adam, betas 0.9 / 0.999, epsilon 1e-8, no weight decay
Sequence length
2,048 tokens, truncated pairs dropped
Chat template
Qwen3
Precision
bf16, FlashAttention 2
Memory
FSDP, activation checkpointing
Checkpoints
Every 1,000 steps, keep two, model only

6What you should see

Numbers from the original run, so you can tell early whether yours is on track.

  • Step 100Loss about 0.69. The model starts out with no preference.
  • Step 1,000Loss about 0.41, batch accuracy about 82%
  • Step 9,000Loss about 0.27, batch accuracy about 89%
  • EndHeld-out accuracy 0.878, margin 2.99, loss 0.280
Training loss
0.200.330.450.570.700k3k6k9kstep
Batch accuracy
50%60%70%80%90%0k3k6k9kstep
0.878Held-out accuracy
2.99Reward margin
0.280Held-out loss
15,824Held-out pairs

Curves are the mean of ten logged batches, so each point covers 100 steps. A rerun will not match to the digit. In the original run the loss had left 0.69 by step 500. If yours has not, check the data and the paths first.

7Known gaps

What stands between this card and an exact copy of the run.

  • The staged data files are not published. Only their SHA-256 fingerprints are, and they sit on the original cluster.
  • HelpSteer3 and UltraFeedback were not revision-pinned, so restaging can produce different bytes.
  • The staging script does not fetch HelpSteer3. It expects two files you prepare first.
  • The base model's tokenizer configuration was repaired before training. The fix is released, and the exact way to apply it needs confirming.
  • Only model weights were saved, so the original optimizer trajectory cannot be resumed.
  • The scripts are written for LUMI (AMD GPUs, Singularity, Cray network settings). Other clusters need changes to the container, the network variables and the paths.
  • Account IDs and personal paths were removed from this page. Replace the <placeholders>.

8Variants

No variants yet.

Reproduced it? Changed something? Fixed a problem or added a capability? Report it and it appears here, linked to this recipe.

Report a variant

9Original files

The frozen files from the run are the authority. They contain the original cluster paths.

Background: How models learned to prefer. Machine-readable: this recipe as JSON.