Overview
EngineConfig controls the core optimization loop behavior in GEPA. It manages evaluation budget, parallelization, caching, and basic stopping conditions.
Most users only need to set max_metric_calls (evaluation budget) and optionally parallel/max_workers for concurrent evaluation.
Class Definition
Parameters
Basic Settings
Directory for storing experiment outputs, logs, and cache files.When set, GEPA will:
- Save optimization state and results
- Enable file-based stop condition (
gepa.stopfile) - Store evaluation cache on disk (if
cache_evaluation=True)
Random seed for reproducibility. Affects:
- Random sampling in batch samplers
- Stochastic candidate selection strategies
Show a progress bar during optimization.
Whether to raise exceptions from evaluator failures.If
False, failed evaluations return score 0.0 with error details in side_info.Use cloudpickle for serialization in subprocess evaluation.Enables serialization of lambda functions and closures.
Track and store the best outputs for each example.Useful for debugging and analyzing optimization progress.
Stopping Conditions
Maximum number of evaluator calls (evaluation budget).This is the most common stopping condition.The optimization stops when the total number of evaluations reaches this limit.
Maximum number of candidate proposals.Stops after generating this many new candidates, regardless of evaluation count.
Strategy Selection
Policy for validating candidates on the validation set.Options:
"full_eval": Evaluate on all validation examples- Custom
EvaluationPolicyinstance for incremental validation
candidate_selection_strategy
CandidateSelector | Literal['pareto', 'current_best', 'epsilon_greedy']
default:"'pareto'"
Strategy for selecting candidates for reflection.Options:
"pareto": Select from Pareto frontier (preserves diverse strengths)"current_best": Always select the best candidate"epsilon_greedy": Epsilon-greedy exploration- Custom
CandidateSelectorinstance
Type of Pareto frontier to maintain.Options:
"hybrid": Hybrid frontier combining per-task and global scores"per_task": Track best per task"global": Track global best only
Parallelization
Enable parallel evaluation of candidates.When
True, multiple evaluations run concurrently using a process pool.Maximum number of worker processes for parallel evaluation.If
None, defaults to the number of CPU cores.Only used when parallel=True.Evaluation Caching
Enable caching of evaluation results.Prevents re-evaluating identical candidates, saving computation.
Where to store the evaluation cache.Options:
"memory": In-memory cache (lost after process exits)"disk": Persistent cache inrun_dir(requiresrun_dirto be set)"auto": Use disk ifrun_diris set, otherwise memory
OptimizationState Tracking
Number of top evaluations to track per example.These are passed to evaluators that declare an
opt_state: OptimizationState parameter, enabling warm-starting from previous best solutions.Standard I/O Capture
Automatically capture stdout/stderr during evaluation.When
True, any print() output inside your evaluator is captured and included in side_info under "stdout" and "stderr" keys.Useful for:- Quick prototyping without modifying existing code
- Wrapping evaluation scripts that already have print statements
- Debugging evaluator behavior
- All Python-level output:
print(),sys.stdout.write() - Third-party library output through
sys.stdout
- C extensions writing directly to file descriptors
- Output from subprocesses spawned by libraries
oa.log() instead.Usage Examples
Basic Configuration
Parallel Evaluation
With Caching
Capture Print Statements
Multiple Stopping Conditions
Full Production Setup
File-Based Stop Condition
Whenrun_dir is set, GEPA automatically enables a file-based stop condition. Create a file named gepa.stop in the run directory to gracefully stop the optimization:
- Manual intervention during long-running optimizations
- Integration with monitoring systems
- Scheduled stops via cron jobs
Related
- GEPAConfig - Top-level configuration
- Stop Conditions - Advanced stopping conditions
- optimize_anything() - Main optimization function