MCPcopy Create free account
hub / github.com/agentscope-ai/Trinity-RFT / test_trainer

Method test_trainer

tests/trainer/trainer_test.py:508–528  ·  view source on GitHub ↗

Test SFT.

(self)

Source from the content-addressed store, hash-verified

506
507class 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

Callers

nothing calls this directly

Calls 6

metric_listMethod · 0.95
metric_max_stepMethod · 0.95
trainFunction · 0.90
TensorBoardParserClass · 0.90
check_and_updateMethod · 0.80

Tested by

no test coverage detected