English

Accelerating Direct Preference Optimization with Prefix Sharing

Machine Learning 2024-11-01 v2 Computation and Language

Abstract

Offline paired preference optimization algorithms have become a popular approach for fine-tuning on preference data, outperforming traditional supervised fine-tuning in various tasks. However, traditional implementations often involve redundant computations, especially for tasks with long shared prompts. We introduce prefix sharing for preference tuning, a novel technique that processes chosen and rejected responses as one sequence with a shared prefix. To prevent cross-response contamination, we use a custom block-sparse attention mask. Our method achieves 1.11.1-1.5×1.5\times improvement in training throughput on popular DPO datasets, without any effect on convergence. When combined with sequence packing, we observe consistent 1.31.3-1.6×1.6\times speedups, benefiting even datasets with smaller sequence lengths. While we focus on Direct Preference Optimization (DPO), our approach is applicable to other paired preference tuning methods. By enhancing computational efficiency, our work contributes to making preference-based fine-tuning more accessible for a wider range of applications and model sizes. We open-source our code at https://github.com/frankxwang/dpo-prefix-sharing.

Keywords

Cite

@article{arxiv.2410.20305,
  title  = {Accelerating Direct Preference Optimization with Prefix Sharing},
  author = {Franklin Wang and Sumanth Hegde},
  journal= {arXiv preprint arXiv:2410.20305},
  year   = {2024}
}

Comments

To appear in NeurIPS 2024 in the Fine-Tuning in Machine Learning Workshop

R2 v1 2026-06-28T19:36:52.420Z