Skip to content

Cancel pending futures on target-score or early-stop termination#419

Open
jink-ucla wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
jink-ucla:fix/process-parallel-fast-exit-cancel
Open

Cancel pending futures on target-score or early-stop termination#419
jink-ucla wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
jink-ucla:fix/process-parallel-fast-exit-cancel

Conversation

@jink-ucla
Copy link

Summary

This PR makes ProcessParallelController.run_evolution() stop work faster when termination conditions are already met.

Problem

When a run reaches target_score or triggers early stopping, pending futures may continue running unnecessarily until natural completion. This
wastes compute and delays clean shutdown.

Changes

  • Add explicit termination_reason tracking in run_evolution.
  • Set termination reason when:
    • target score is reached
    • early stopping triggers
    • shutdown is requested
  • Cancel all remaining pending futures immediately for early-termination paths.
  • Improve completion logging so it reports the actual stop reason:
    • target_score
    • early_stopping
    • shutdown
    • no_pending_futures
    • max_iterations
  • Add focused unit test:
    • test_target_score_fast_exit_cancels_pending_futures

Why this is safe

  • No change to scoring, sampling, or island logic.
  • Behavior only changes after a termination condition is already satisfied.
  • Cancellation is best-effort and only affects remaining pending work.

Validation

python -m py_compile openevolve/process_parallel.py tests/test_process_parallel.py
python -m unittest tests.test_process_parallel.TestProcessParallel.test_target_score_fast_exit_cancels_pending_futures -v

@CLAassistant
Copy link

CLAassistant commented Feb 27, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants