Skip to content

feat(compat): add scoped local AlphaEvolve evaluator imports - #535

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Yushu-Li:feat/alphaevolve-local-imports
Oct 23, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
Yushu-Li:feat/alphaevolve-local-imports

Conversation

@Yushu-Li

Copy link
Copy Markdown
Contributor

Unchanged local AlphaEvolve evaluators can still require alpha_evolve.models, even when execution uses OpenEvolve. Add five dependency-free evaluation envelopes, finite-score lookup, and explicit scoped import helpers under openevolve.compat.alpha_evolve. The walkthrough CLI gains --local-model-types; its default import behavior is unchanged.

load_evaluator(path, function_name) imports a trusted Python file using temporary local aliases, supports decorators during import, and removes the file-module registration afterwards so cloudpickle can transport the callable by value to fresh OE workers. It reads current source bytes rather than potentially stale timestamp/size-based bytecode. The raw candidate-based callable can use the existing evaluator adapter or local experiment facade.

local_imports() is an explicit process-global, main-thread-only context for single-threaded entrypoints. It refuses any already-loaded alpha_evolve namespace and removes only its own entries on exit, including on import failure or interruption. It does not install packages, modify import paths, look up credentials, or create clients. Unknown SDK submodules cannot fall back to a cloud installation inside the context.

The five models are dataclass envelopes with attribute access and no-argument model_dump(), not Pydantic replacements; metric validation stays in the existing adapter. get_score reads mapping/object envelopes, preserves finite zero/negative scores, and returns -inf for absent or invalid values. No base dependencies or default OE contracts change.

Validation:

  • 22 new tests cover envelope serialization/failure mapping, aliases and namespace collision protection, cleanup on errors/interruptions, current-source loading, fresh-process callable transport with cloud SDK imports blocked, and the CLI opt-in through real OE evolution.
  • Full offline suite: 858 tests passed. Black/isort and Frame scans of all seven changed Python files passed; Python 3.10 grammar parsed successfully.
  • Ran the unchanged circle-packing, TSP and signal-processing program.py/evaluate.py through the public CLI with --local-model-types, each seed-only and with one scripted proposal through OE's real controller/worker. The cloud SDK source was absent from the worker module path and imports were explicitly blocked. Source hashes stayed unchanged, temporary aliases were removed, and guarded socket/HTTP/credential lookup attempts were zero.
  • Separately checked three representative local envelopes against the real SDK at revision 34cd919193945c6dc81053f9af594031b54f41a8, and verified that local alias activation refuses to replace that imported SDK.

Continues #468 without closing it. This supplies local evaluator types/import routing, not the full SDK, original upstream entrypoint compatibility, complete archive queries, cloud controller methods, or a managed-service run. Trusted evaluator/import code still executes with the process's privileges; this adds no sandbox. Relative/sibling imports and external import-time side effects are not managed. The local experiment facade's existing budget/concurrency/best-only limitations remain unchanged. No real model or managed-service requests were made during validation.

@codelion
codelion merged commit 04a37f1 into algorithmicsuperintelligence:main Oct 23, 2026
4 checks passed
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