From 459215b7d84d01e64cfd352a971cf62d8e2a17fd Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 13 Jul 2026 03:25:55 +0200 Subject: [PATCH] malkhut(fix): wire workers into CMA training loop CMAESTrainer.train() now accepts workers parameter and passes it to evaluate_candidate(), enabling parallel episode evaluation during actual training (not just in tests/benchmarks). Benchmark result: ProcessPoolExecutor is optimal (4.76x speedup). Ray is slower (0.36x) due to head init + plasma overhead for 90 scenarios. --- MALKHUT/malkhut/training/cma_trainer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MALKHUT/malkhut/training/cma_trainer.py b/MALKHUT/malkhut/training/cma_trainer.py index 8f695c8..e176cc0 100644 --- a/MALKHUT/malkhut/training/cma_trainer.py +++ b/MALKHUT/malkhut/training/cma_trainer.py @@ -1237,11 +1237,13 @@ class CMAESTrainer: evaluator: PolicyEvaluator, pool: SelfPlayPool, store: Optional[MalkhutCHStore] = None, + workers: int = 0, ) -> None: self.codec = codec self.evaluator = evaluator self.pool = pool self.store = store + self._workers = workers def train( self, @@ -1283,7 +1285,7 @@ class CMAESTrainer: candidate = self.codec.decode(x, version=f"cma_{time.time_ns()}_{evals}") score, results = self.evaluator.evaluate_candidate( params=candidate, scenarios=scenarios, rng_seed=seed + evals, - planner_type=planner_type, + planner_type=planner_type, workers=self._workers, ) perf_vec = PolicyEvaluator.performance_vector(results) snap = PolicySnapshot(