Skip to content

Delete legacy DPO implementation#3997

Open
igorts-git wants to merge 1 commit into
mainfrom
igorts/delete-legacy-dpo
Open

Delete legacy DPO implementation#3997
igorts-git wants to merge 1 commit into
mainfrom
igorts/delete-legacy-dpo

Conversation

@igorts-git
Copy link
Copy Markdown
Collaborator

@igorts-git igorts-git commented May 27, 2026

Description

This pull request deletes the legacy "native" Direct Preference Optimization (DPO) implementation from the pre-training code paths, leaving only the recently added, Tunix-based post-training DPO and ORPO pipelines in place.

Along the way also renamed the metric eval/dpo_reward_accuracy to eval/avg_dpo_reward_accuracy to reflect the fact that Tunix aggregates the eval metrics and provides us with the average value. The legacy metric aggregation code was removed.

As follow up to this PR I plan to send out PRs with the following:

  • Add a notebook that runs DPO and ORPO.
  • Add support of Grain and TFDS in the new DPO implementation
  • (Still haven't started) Enable LoRA in the new DPO.

BUGS: b/485626968

Tests

CI tests
Manual runs of DPO, ORPO, and SFT on a local VM.

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

@github-actions
Copy link
Copy Markdown

🤖 Hi @igorts-git, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

## 📋 Review Summary

This Pull Request successfully deletes the legacy "native" Direct Preference Optimization (DPO) implementation from the pre-training code paths. This significant cleanup simplifies the codebase by removing redundant training logic, specialized state handling for reference models, and legacy input pipelines, directing users toward the newer Tunix-based post-training DPO pipeline.

🔍 General Feedback

  • Comprehensive Cleanup: The removal is thorough across training (train.py), state management (train_state_nnx.py), input pipelines (tfds_data_processing.py, grain_data_processing.py), and logging (metric_logger.py).
  • Excellent UX: The addition of a ValueError in validate_train_config to explicitly guide users to train_dpo.py is a high-quality detail that improves discoverability and prevents confusion during the transition.
  • Maintainable Metrics: Transitioning metric_logger.py to use key-based checks for DPO reward accuracy instead of the use_dpo flag is a more robust approach that supports both current and future post-training workflows.

@igorts-git igorts-git force-pushed the igorts/delete-legacy-dpo branch 2 times, most recently from a5a4c57 to da7e9f9 Compare May 28, 2026 18:18
@ecnal-cienet
Copy link
Copy Markdown
Collaborator

Generally lgtm.
on maxtext_utils.py:
two config.use_dpo branches left here that are now unreachable since validate_train_config raises early:

  • line 169 in get_shaped_batch (adds chosen/rejected ShapeDtypeStructs)
  • line 1163 in the TFLOPS calc (adds reference-model TFLOPS)

I think both can dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants