Repository navigation
Conversation
HannanJaved
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds the option to precompute the DPO reference log-probs. It also fixes two problems found while running DPO with FSDP2 on MN5.
1. Precomputed reference log-probs (
dpo.precompute_ref_log_probs,dpo.precompute_ref_batch_size)Two new
DPOMethodConfigfields are passed through to TRL'sDPOConfig:precompute_ref_log_probs: truescores the dataset with the reference model once, before training, and frees the reference model afterwards. During training, only the policy model is in GPU memory.precompute_ref_batch_sizesets the batch size of that pass.null=per_device_train_batch_size.Both default to the previous behavior (
false/null).configs/trl/dpo.yamland the README document the new fields.2. Reference model on the wrong device under FSDP (
device_map: None)TRL defaults
device_mapto"auto"and forces it toNoneonly forMULTI_GPUandDEEPSPEED. Under FSDP, the DPO reference model kept"auto": FSDP2 moved its weights to the local GPU, but the accelerate hooks still sent the inputs tocuda:0. The result wasExpected all tensors to be on the same device.build_model_init_kwargsnow setsdevice_map: None, so the model loads on CPU and FSDP places the weights.3. wandb start-up timeout (
WANDB__SERVICE_WAIT)wandb waits 30 s for its
wandb-coreservice to start. On a busy compute node, this is sometimes not enough, and rank 0 crashes inon_train_beginwith:scripts/train.pynow setsWANDB__SERVICE_WAIT=300withos.environ.setdefault, so a value set in the environment (for example, inenv/*.env) still takes priority.4. MN5 config
configs/trl/olmo3-dpo-mn5.yaml: DPO on OLMo 3 7B Instruct SFT on MN5 with FSDP2, FA3, and precomputed reference log-probs. Paths, account, and partition are placeholders.Type of change
Validation
wandb-corestart locally (wandb 0.25.0). A wrapper script sleeps 40 s and then starts the real binary. Without the change,wandb.initfails with the sameServicePollForTokenErrorafter 30 s. With the change,wandb.initsucceeds.uv run pre-commit run --from-ref main --to-ref HEADpasses (ruff, ruff-format, black).