Repository navigation
fix(metrics): guard boolean flags and non-finite values across fitness, prompts, traces, and coevolution - #625
Open
peterzhang987723 wants to merge 1 commit into
Conversation
|
zhangshoufa seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…s, prompts, traces, and coevolution
peterzhang987723
force-pushed
the
fix/boolean-nonfinite-metric-integrity
branch
from
November 27, 2026 14:25
e5daeb0 to
12e4d6b
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In Python,
boolis a subclass ofint(isinstance(True, int) is True). Whileopenevolvealready guarded some formatting and average paths, several remaining runtime paths still treated boolean status flags (timeout=True,valid=False,combined_score=True) orNaN/Inf/Nonevalues as numeric fitness scores or improvements, causing silent reward/metric spoofing andTypeError/ZeroDivisionErroredge-case failures.Root Causes Fixed
openevolve/utils/metrics_utils.py:boolandNaNinsafe_numeric_sum,get_fitness_score(combined_scorefast-path), andformat_feature_coordinates.openevolve/evolution_trace.py:booland non-finite (NaN/Inf) deltas in bothEvolutionTrace.calculate_improvementandextract_full_lineage_traces.openevolve/evaluator.py:evaluate_program(use_llm_feedback=True), skip blendingcombined_scorewhenaccuracyis abool,NaN, or non-numeric._passes_threshold, rejectboolandNaNvalues oncombined_score(allowing numeric fallback instead of passingTrueas1.0) and ignoreNaNin the fallback average.openevolve/coevolution.py:_has_finite_score()checkingnot isinstance(score, bool) and isinstance(score, (int, float)) and math.isfinite(score)for both phase refresh re-evaluation and champion validation (socombined_score=TrueorNone/str raisesValueErrorinstead of passing or raisingTypeError).openevolve/process_parallel.py:format_metrics_safewhen logging child metrics (avoidingtimeout=1.0000).target_scoreandearly_stoppingchecks againstboolandNaN/Infscores.openevolve/prompt/sampler.py:boolfrom float formatting in_format_metrics,_format_evolution_history, andtop_programsfeature summaries.boolandNaNfrom parent-child comparisons (preventingtimeout: False -> Truefrom emitting"Improvement in all metrics") and inspiration highlights (preventingtimeout: Truefrom emitting"Excellent timeout (1.000)").openevolve/api.py,openevolve/cli.py,openevolve/database.py:api.run_evolutionbest_scorecalculation throughget_fitness_score(so timed-out programs with{"error": 0.0, "timeout": True}yield0.0instead of0.5).boolincli.pyfinal metric printing.NaNindatabase._safe_sum_metrics/_safe_avg_metrics, and guardProgramDatabase.__init__against emptyfeature_dimensions(ZeroDivisionError).Verification
tests/test_metric_integrity_guards.pycoveringPromptSampler,Evaluator,run_coevolution,ProcessParallelController,ProgramDatabase,EvolutionTrace/extract_full_lineage_traces, andapi.run_evolution.isort --profile black --line-length 100andblack --line-length 100.pytest tests -m "not slow and not integration"andtests/test_coevolution.py.