Skip to content

Tuner

chimera.training.tuner provides hyperparameter search for synthesis configurations. SynthesisTuner performs grid search over a SearchSpace, running synthesis for each configuration and selecting the best one.


Defines the hyperparameter search space with categorical choices. Calling configurations() produces the full Cartesian product (grid search).

space = SearchSpace()
space.choice("model", ["glm-5", "claude-sonnet-4-20250514"])
space.choice("max_steps", [10, 25])
# Produces 4 configurations

Grid search over synthesis configurations. Creates a fresh environment for each trial, runs synthesis, and picks the best result.

Constructor parameters:

ParamTypeDescription
specSpecThe synthesis specification
env_factoryCallable[[], Environment]Returns a fresh env for each trial
agent_factoryCallable[[dict], Agent] | NoneOptional custom agent builder

Key method: search(space, max_trials, metric, callbacks) -> TunerResult.

FieldTypeDescription
best_configdictConfiguration that achieved the highest score
best_scorefloatScore of the best configuration
trialslist[TrialResult]All trial results in execution order
total_costfloatSum of costs across all trials
from chimera.training.tuner import SynthesisTuner, SearchSpace
space = SearchSpace()
space.choice("model", ["glm-5", "claude-sonnet-4-20250514"])
space.choice("max_iterations", [5, 10, 20])
tuner = SynthesisTuner(
spec=spec,
env_factory=lambda: LocalEnvironment(workdir="/tmp/trial", test_cmd="pytest"),
)
result = tuner.search(space, max_trials=6, metric="pass_rate")
print(f"Best config: {result.best_config}")
print(f"Best score: {result.best_score:.0%}")
print(f"Total cost: ${result.total_cost:.2f}")