4949)
5050from maxtext .configs import pyconfig
5151from maxtext .configs .types import MaxTextConfig
52+ from maxtext .input_pipeline import tokenizer
5253from maxtext .optimizers import optimizers
5354from maxtext .trainers .post_train .dpo import hooks
5455from maxtext .utils import max_logging
@@ -90,7 +91,7 @@ def get_tunix_config(mt_config: MaxTextConfig) -> DPOTrainingConfig:
9091 set_profile_options = set_profile_options ,
9192 )
9293
93- max_prompt_length = mt_config .max_target_length // 2
94+ max_prompt_length = mt_config .dpo . max_prompt_length or ( mt_config . max_target_length // 2 )
9495 return DPOTrainingConfig (
9596 eval_every_n_steps = mt_config .eval_interval ,
9697 max_steps = mt_config .steps ,
@@ -113,7 +114,18 @@ def setup_trainer_state(mt_config, goodput_recorder=None):
113114 tunix_config = get_tunix_config (mt_config )
114115
115116 with maybe_record_goodput (goodput_recorder , GoodputEvent .TPU_INIT ):
116- model , mesh = model_creation_utils .from_pretrained (mt_config , wrap_with_tunix_adapter = True )
117+ tok = tokenizer .build_tokenizer (
118+ mt_config .tokenizer_path ,
119+ mt_config .tokenizer_type ,
120+ False ,
121+ False ,
122+ mt_config .hf_access_token ,
123+ )
124+ model , mesh = model_creation_utils .from_pretrained (
125+ mt_config ,
126+ wrap_with_tunix_adapter = True ,
127+ tokenizer_pad_id = tok .pad_id ,
128+ )
117129
118130 learning_rate_schedule = maxtext_utils .create_learning_rate_schedule (mt_config )
119131 # pass in model for muon
0 commit comments