One function

_from_legacy_config in gepa-ai/gepa

The author described this change as fix(optimize_anything): honor legacy EngineConfig parallelism in the eval server (#423). It counts as a record because the checks below fail on the code as it stood at 8a2bed963 and pass on 81dbae904, with nothing else changed between the two runs.

Fix saved2026-08-11
Sharing licenceMIT · LICENSE
Change size+11 0

What the code was meant to do, written into the code itself as a docstring

Convert a legacy launcher :class:`GEPAConfig` into the OA-shaped config. The whole config rides through `engine_config` field-for-field (so nested configs and callbacks survive as objects); the launcher's eval budget becomes `max_evals` — `None` stays unbounded, as in the launcher.

The change

44 The whole config rides through ``engine_config`` field-for-field (so nested
55 configs and callbacks survive as objects); the launcher's eval budget
66 becomes ``max_evals`` — ``None`` stays unbounded, as in the launcher.
7+
8+ The launcher's parallelism settings size the eval server, which gates all
9+ evaluation: ``parallel=False`` maps to ``max_concurrency=1``, an explicit
10+ ``max_workers`` maps to itself, and ``max_workers=None`` falls back to
11+ ``os.cpu_count() or 32`` (the same fallback as ``EngineConfig.max_workers``'s
12+ default factory).
713 """
814 from gepa.gepa_launcher import GEPAConfig
915
1016 if not isinstance(config, GEPAConfig):
1117 raise TypeError(f"config must be an OptimizeAnythingConfig or GEPAConfig, got {type(config).__name__}")
18+ if not config.engine.parallel:
19+ max_concurrency = 1
20+ else:
21+ max_concurrency = config.engine.max_workers or (os.cpu_count() or 32)
1222 return OptimizeAnythingConfig(
1323 engine="gepa",
1424 max_evals=config.engine.max_metric_calls,
25+ max_concurrency=max_concurrency,
1526 engine_config={f.name: getattr(config, f.name) for f in dataclasses.fields(config)},
1627 )

The check that tells the two apart

failpass·tests/test_optimize_anything_gepa_config.py::test_legacy_max_workers_none_falls_back_to_cpu_count
failpass·tests/test_optimize_anything_gepa_config.py::test_legacy_max_workers_sizes_the_eval_server
failpass·tests/test_optimize_anything_gepa_config.py::test_legacy_parallel_false_maps_to_sequential_eval_server

Check file tests/test_optimize_anything_gepa_config.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it8a2bed96385202f69caaeb5327a843ed2f5ea225
Broken version dated2026-08-05
Modulegepa.optimize_anything
Units changed_from_legacy_config
Fingerprintfa76c2e9a894089b
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in gepa-ai/gepa