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

Method test_trainer

tests/trainer/trainer_test.py:481–500  ·  view source on GitHub ↗

Test CPT.

(self)

Source from the content-addressed store, hash-verified

479
480class TestTrainerCPT(BaseTrainerCase):
481 def test_trainer(self):
482 """Test CPT."""
483 # test both mode
484 self.config.mode = "train"
485 self.config.algorithm.algorithm_type = "cpt"
486 self.config.algorithm.policy_loss_fn = "sft"
487 self.config.algorithm.policy_loss_fn_args = {}
488 self.config.algorithm.kl_loss_fn = "none"
489 self.config.algorithm.entropy_loss_fn = "none"
490 self.config.buffer.train_batch_size = 8
491 self.config.buffer.total_epochs = 2
492 self.config.buffer.trainer_input.experience_buffer = get_unittest_dataset_config(
493 "cpt_for_countdown"
494 )
495 self.config.check_and_update()
496 train(self.config)
497 parser = TensorBoardParser(os.path.join(self.config.monitor.cache_dir, "tensorboard"))
498 actor_metrics = parser.metric_list("actor")
499 self.assertGreater(len(actor_metrics), 0)
500 self.assertEqual(parser.metric_max_step(actor_metrics[0]), 4)
501
502 def tearDown(self):
503 # 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