Skip to content

ERROR - Error in novelty LLM check: asyncio.run() cannot be called from a running event loop #313

@daniel-sintef

Description

@daniel-sintef

Hi Everyone!

I'm trying to get openevolve to run locally on an HPC cluster with GPU access. I noticed that embeddings are not supported by default so I've made the following relatively minor modifications to the basic example and how embeddings are called:


iff --git a/examples/function_minimization/config.yaml b/examples/function_minimization/config.yaml
index 42fb739..a153ec7 100644
--- a/examples/function_minimization/config.yaml
+++ b/examples/function_minimization/config.yaml
@@ -5,16 +5,17 @@ checkpoint_interval: 5
 # LLM configuration
 llm:
   # primary_model: "gemini-2.5-flash-lite"
-  primary_model: "gpt-5-mini"
+  #primary_model: "gpt-5-mini"
   # primary_model: "llama3.1-8b"
+  primary_model: "gemma3:27b"
   primary_model_weight: 0.8
   # secondary_model: "gemini-2.5-flash"
   # secondary_model: "llama-4-scout-17b-16e-instruct"
-  secondary_model: "gpt-5-nano"
+  secondary_model: "gemma3:27b"
   secondary_model_weight: 0.2
   # api_base: "https://generativelanguage.googleapis.com/v1beta/openai/"
   # api_base: "https://api.cerebras.ai/v1"
-  api_base: "https://api.openai.com/v1"
+  api_base: "http://127.0.0.1:11434/v1"
   temperature: 0.7
   max_tokens: 16000
   timeout: 120
@@ -31,7 +32,7 @@ database:
   elite_selection_ratio: 0.2
   exploitation_ratio: 0.7

-  embedding_model: "text-embedding-3-small"
+  embedding_model: "embeddinggemma:latest"
   similarity_threshold: 0.99

 # Evaluator configuration
@@ -42,4 +43,4 @@ evaluator:

 # Evolution settings
 diff_based_evolution: true
-max_code_length: 20000
\ No newline at end of file
+max_code_length: 20000
diff --git a/openevolve/embedding.py b/openevolve/embedding.py
index 74d3c57..a75ee3f 100644
--- a/openevolve/embedding.py
+++ b/openevolve/embedding.py
@@ -17,6 +17,10 @@ OPENAI_EMBEDDING_MODELS = [
     "text-embedding-3-large",
 ]

+OLLAMA_EMBEDDING_MODELS = [
+    "embeddinggemma:latest",
+]
+
 AZURE_EMBEDDING_MODELS = [
     "azure-text-embedding-3-small",
     "azure-text-embedding-3-large",
@@ -50,6 +54,12 @@ class EmbeddingClient:
                 api_version=os.getenv("AZURE_API_VERSION"),
                 azure_endpoint=os.getenv("AZURE_API_ENDPOINT"),
             )
+        elif model_name in OLLAMA_EMBEDDING_MODELS:
+            client = openai.OpenAI(
+                base_url=os.getenv("OLLAMA_BASE_URL", "http://localhost:11434/v1/"),
+                api_key=os.getenv("OLLAMA_API_KEY", "ollama"),
+            )
+            model_to_use = model_name
         else:
             raise ValueError(f"Invalid embedding model: {model_name}")

However when running:

python openevolve-run.py examples/function_minimization/initial_program.py examples/function_minimization/evaluator.py --config examples/function_minimization/config.yaml --iterations 50

I get the following error

2025-11-06 17:23:16,806 - ERROR - Error in novelty LLM check: asyncio.run() cannot be called from a running event loop /cluster/work/danimarc/openevolve_testing/openevolve/openevolve/database.py:1018: RuntimeWarning: coroutine 'LLMEnsemble.generate_with_context' was never awaited logger.error(f"Error in novelty LLM check: {e}")

and later

2025-11-06 17:32:54,927 - ERROR - Error in novelty LLM check: asyncio.run() cannot be called from a running event loop

I wonder if maybe this has something to do with running locally as opposed to making remote LLM calls. I'm very happy make my setup clearer if this can make debugging easier.

Best,

Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions