Skip to content

Refactor: extract shared post-training hooks and update SFT implementation#3862

Merged
copybara-service[bot] merged 1 commit into
mainfrom
igorts/post-train-hooks-refactor
May 12, 2026
Merged

Refactor: extract shared post-training hooks and update SFT implementation#3862
copybara-service[bot] merged 1 commit into
mainfrom
igorts/post-train-hooks-refactor

Conversation

@igorts-git
Copy link
Copy Markdown
Collaborator

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

Description

Generalize the SFT hooks such that they can be used in DPO as well.

We move the shared code into src/maxtext/trainers/post_train/hooks.py while the SFT-specific overrides reside in the SFT sub-directory.

This PR is a pre-requisite for #3668 (DPO implementation)

Tests

Test run of a local SFT training.
Ran the unit tests, including logits comparison test.

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 10, 2026

Codecov Report

❌ Patch coverage is 73.38710% with 33 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/maxtext/trainers/post_train/hooks.py 72.03% 29 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@igorts-git igorts-git force-pushed the igorts/post-train-hooks-refactor branch 2 times, most recently from 86e8ff4 to 784f4e5 Compare May 10, 2026 19:07
@igorts-git igorts-git force-pushed the igorts/post-train-hooks-refactor branch 2 times, most recently from 950adfd to f62df0f Compare May 10, 2026 20:28
Comment thread tests/post_training/unit/hooks_test.py Outdated
@igorts-git igorts-git force-pushed the igorts/post-train-hooks-refactor branch from f62df0f to 99e947e Compare May 11, 2026 16:52
@igorts-git igorts-git closed this May 11, 2026
@igorts-git igorts-git reopened this May 11, 2026
@copybara-service copybara-service Bot merged commit e222db8 into main May 12, 2026
74 of 82 checks passed
@copybara-service copybara-service Bot deleted the igorts/post-train-hooks-refactor branch May 12, 2026 04:10
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.

4 participants