File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -472,6 +472,31 @@ def test_init_multimodal_model(self):
472472 student_vocab_size = trainer .model .config .get_text_config ().vocab_size
473473 assert student_vocab_size == trainer .teacher_model .config .get_text_config ().vocab_size
474474
475+ def test_on_policy_with_multimodal_model (self ):
476+ """On-policy generation must work when the chunked-CE patch has replaced the model's forward."""
477+ model_id = "trl-internal-testing/tiny-Gemma3ForConditionalGeneration"
478+ tokenizer = AutoTokenizer .from_pretrained (model_id , padding_side = "left" )
479+ training_args = GKDConfig (
480+ output_dir = self .tmp_dir ,
481+ lmbda = 1.0 ,
482+ max_steps = 1 ,
483+ per_device_train_batch_size = 2 ,
484+ max_new_tokens = 8 ,
485+ report_to = "none" ,
486+ )
487+ dataset = load_dataset ("trl-internal-testing/zen" , "conversational_language_modeling" )
488+
489+ trainer = GKDTrainer (
490+ model = model_id ,
491+ teacher_model = model_id ,
492+ args = training_args ,
493+ train_dataset = dataset ["train" ],
494+ processing_class = tokenizer ,
495+ )
496+ trainer .train ()
497+
498+ assert trainer .state .log_history [- 1 ]["train_loss" ] is not None
499+
475500 @require_liger_kernel
476501 def test_compute_loss_return_outputs_with_liger (self ):
477502 """Test that return_outputs=True works correctly with Liger kernel path."""
You can’t perform that action at this time.
0 commit comments