Test SFT.
(self)
| 506 | |
| 507 | class TestTrainerSFT(BaseTrainerCase): |
| 508 | def test_trainer(self): |
| 509 | """Test SFT.""" |
| 510 | # test both mode |
| 511 | self.config.mode = "train" |
| 512 | self.config.algorithm.algorithm_type = "sft" |
| 513 | self.config.algorithm.policy_loss_fn = "sft" |
| 514 | self.config.algorithm.policy_loss_fn_args = {} |
| 515 | self.config.algorithm.kl_loss_fn = "none" |
| 516 | self.config.algorithm.entropy_loss_fn = "none" |
| 517 | self.config.synchronizer.sync_interval = 4 |
| 518 | self.config.buffer.train_batch_size = 4 |
| 519 | self.config.buffer.total_epochs = 2 |
| 520 | self.config.buffer.trainer_input.experience_buffer = get_unittest_dataset_config( |
| 521 | "sft_for_gsm8k" |
| 522 | ) |
| 523 | self.config.check_and_update() |
| 524 | train(self.config) |
| 525 | parser = TensorBoardParser(os.path.join(self.config.monitor.cache_dir, "tensorboard")) |
| 526 | actor_metrics = parser.metric_list("actor") |
| 527 | self.assertGreater(len(actor_metrics), 0) |
| 528 | self.assertEqual(parser.metric_max_step(actor_metrics[0]), 4) |
| 529 | |
| 530 | def tearDown(self): |
| 531 | # remove dir only when the test passed |
nothing calls this directly
no test coverage detected