Skip to content

Commit 8fadaf5

Browse files
committed
Merge branch 'main' into feat/MLX-kernel-optimization
2 parents ee8f175 + 970d079 commit 8fadaf5

27 files changed

+3555
-234
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
applyTo: 'scripts/**/*.js'
3+
---
4+
- In this program, a dataset with nodes and edges is visualized in different graphs and lists. These view modes are selectable in tabs.
5+
- Nodes are parametrized with meta data including program ID, island number, generation nunmber, parent ID (which is used to determine the edge connections), a metric dataset with flexible keys, a code string, a dict with prompts and more. All data except program ID are optional.
6+
- A sidebar shows detailed node information. Its format is the same across all view modes.
7+
- The sidebar in this program is designed to show up dynamically when a node is selected in one of the graphs or lists. It appears on hover of the node and hides when the node is not hovered anymore.
8+
- A single node can be selected to turn it "sticky". When a node is sticky, its information remains visible in the sidebar and the sidebar remains open until the user clicks in the background. Hovering another node will not change the sidebar content if a node is already sticky.
9+
- The selected node is highlighted with a red border and synchronized across all graphs and lists. I.e., clicking a node in a list will also highlight it in the graphs.
10+
11+
- A select box #highlight-select configures a filter logic that allows to highlight multiple nodes. Nodes are highlighted with a blue shadow in the graphs and lists.
12+
- A select box #metric-select shows the available metrics (determined dynamically from the dataset), and the selected metric may be used in the graph creation, filter and sorting logic.

.github/workflows/python-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ jobs:
1313
- uses: psf/black@stable
1414
with:
1515
options: "--check --verbose"
16-
src: "./openevolve ./tests ./examples"
16+
src: "./openevolve ./tests ./examples ./scripts"
1717
use_pyproject: true

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ install: venv
3333
# Run Black code formatting
3434
.PHONY: lint
3535
lint: venv
36-
$(PYTHON) -m black openevolve examples tests
36+
$(PYTHON) -m black openevolve examples tests scripts
3737

3838
# Run tests using the virtual environment
3939
.PHONY: test
@@ -50,7 +50,7 @@ docker-build:
5050
docker-run:
5151
docker run --rm -v $(PROJECT_DIR):/app --network="host" $(DOCKER_IMAGE) examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 1000
5252

53-
# Run the lm-eval benchmark
54-
.PHONY: lm-eval
55-
lm-eval:
56-
$(PYTHON) scripts/lm_eval/lm-eval.py
53+
# Run the visualization script
54+
.PHONY: visualizer
55+
visualizer:
56+
$(PYTHON) scripts/visualizer.py --path examples/

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,32 @@ diff -u checkpoints/checkpoint_10/best_program.py checkpoints/checkpoint_20/best
128128
# Compare metrics
129129
cat checkpoints/checkpoint_*/best_program_info.json | grep -A 10 metrics
130130
```
131+
132+
### Visualizing the evolution tree
133+
134+
The script in `scripts/visualize.py` allows you to visualize the evolution tree and display it in your webbrowser. The script watches live for the newest checkpoint directory in the examples/ folder structure and updates the graph. Alternatively, you can also provide a specific checkpoint folder with the `--path` parameter.
135+
136+
```bash
137+
# Install requirements
138+
pip install -r scripts/requirements.txt
139+
140+
# Start the visualization web server and have it watch the examples/ folder
141+
python scripts/visualizer.py
142+
143+
# Start the visualization web server with a specific checkpoint
144+
python scripts/visualizer.py --path examples/function_minimization/openevolve_output/checkpoints/checkpoint_100/
145+
```
146+
147+
In the visualization UI, you can
148+
- see the branching of your program evolution in a network visualization, with node radius chosen by the program fitness (= the currently selected metric),
149+
- see the parent-child relationship of nodes and click through them in the sidebar (use the yellow locator icon in the sidebar to center the node in the graph),
150+
- select the metric of interest (with the available metric choices depending on your data set),
151+
- highlight nodes, for example the top score (for the chosen metric) or the MAP-elites members,
152+
- click nodes to see their code and prompts (if available from the checkpoint data) in a sidebar,
153+
- in the "Performance" tab, see their selected metric score vs generation in a graph
154+
155+
![OpenEvolve Visualizer](openevolve-visualizer.png)
156+
131157
### Docker
132158

133159
You can also install and execute via Docker:

openevolve-visualizer.png

678 KB
Loading

openevolve/config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class LLMConfig(LLMModelConfig):
4040

4141
# API configuration
4242
api_base: str = "https://api.openai.com/v1"
43-
name: str = "gpt-4o"
4443

4544
# Generation parameters
4645
system_message: Optional[str] = "system_message"
@@ -60,10 +59,10 @@ class LLMConfig(LLMModelConfig):
6059
evaluator_models: List[LLMModelConfig] = field(default_factory=lambda: [])
6160

6261
# Backwardes compatibility with primary_model(_weight) options
63-
primary_model: str = "gemini-2.0-flash-lite"
64-
primary_model_weight: float = 0.8
65-
secondary_model: str = "gemini-2.0-flash"
66-
secondary_model_weight: float = 0.2
62+
primary_model: str = None
63+
primary_model_weight: float = None
64+
secondary_model: str = None
65+
secondary_model_weight: float = None
6766

6867
def __post_init__(self):
6968
"""Post-initialization to set up model configurations"""

openevolve/llm/openai.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,8 @@ async def _call_api(self, params: Dict[str, Any]) -> str:
107107
response = await loop.run_in_executor(
108108
None, lambda: self.client.chat.completions.create(**params)
109109
)
110+
# Logging of system prompt, user message and response content
111+
logger = logging.getLogger(__name__)
112+
logger.debug(f"API parameters: {params}")
113+
logger.debug(f"API response: {response.choices[0].message.content}")
110114
return response.choices[0].message.content

openevolve/prompt/sampler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ def _format_evolution_history(
264264

265265
# Only compare if both values are numeric
266266
if isinstance(prog_value, (int, float)) and isinstance(parent_value, (int, float)):
267-
if prog_value >= parent_value:
267+
if prog_value > parent_value:
268268
numeric_comparisons_improved.append(True)
269269
else:
270270
numeric_comparisons_improved.append(False)
271271

272-
if prog_value <= parent_value:
272+
if prog_value < parent_value:
273273
numeric_comparisons_regressed.append(True)
274274
else:
275275
numeric_comparisons_regressed.append(False)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies = [
1717
"pyyaml>=6.0",
1818
"numpy>=1.22.0",
1919
"tqdm>=4.64.0",
20+
"flask",
2021
]
2122

2223
[project.optional-dependencies]

scripts/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
flask

0 commit comments

Comments
 (0)