Skip to content

Commit 3abf767

Browse files
committed
Remove worker-to-island mapping logic and related tests
Eliminated the worker-to-island pinning mechanism from ProcessParallelController and removed all associated unit tests. This simplifies the parallel processing logic and test suite by no longer distributing workers across islands using a static mapping.
1 parent 545f72f commit 3abf767

File tree

2 files changed

+0
-85
lines changed

2 files changed

+0
-85
lines changed

openevolve/process_parallel.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,9 @@ def __init__(self, config: Config, evaluation_file: str, database: ProgramDataba
288288

289289
# Number of worker processes
290290
self.num_workers = config.evaluator.parallel_evaluations
291-
292-
# Worker-to-island pinning for true island isolation
293291
self.num_islands = config.database.num_islands
294-
self.worker_island_map = {}
295-
296-
# Distribute workers across islands using modulo
297-
for worker_id in range(self.num_workers):
298-
island_id = worker_id % self.num_islands
299-
self.worker_island_map[worker_id] = island_id
300292

301293
logger.info(f"Initialized process parallel controller with {self.num_workers} workers")
302-
logger.info(f"Worker-to-island mapping: {self.worker_island_map}")
303294

304295
def _serialize_config(self, config: Config) -> dict:
305296
"""Serialize config object to a dictionary that can be pickled"""

tests/test_island_isolation.py

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,6 @@ def setUp(self):
2424
self.database = ProgramDatabase(self.config.database)
2525
self.evaluation_file = "mock_evaluator.py"
2626

27-
def test_worker_island_mapping(self):
28-
"""Test that workers are correctly mapped to islands"""
29-
controller = ProcessParallelController(self.config, self.evaluation_file, self.database)
30-
31-
# Check mapping is correct
32-
expected_mapping = {
33-
0: 0, # Worker 0 -> Island 0
34-
1: 1, # Worker 1 -> Island 1
35-
2: 2, # Worker 2 -> Island 2
36-
3: 0, # Worker 3 -> Island 0
37-
4: 1, # Worker 4 -> Island 1
38-
5: 2, # Worker 5 -> Island 2
39-
}
40-
41-
self.assertEqual(controller.worker_island_map, expected_mapping)
42-
43-
def test_uneven_worker_distribution(self):
44-
"""Test mapping when workers don't divide evenly into islands"""
45-
self.config.evaluator.parallel_evaluations = 7 # Not divisible by 3
46-
47-
controller = ProcessParallelController(self.config, self.evaluation_file, self.database)
48-
49-
# Island 0 should get 3 workers, islands 1 and 2 get 2 each
50-
island_worker_counts = {0: 0, 1: 0, 2: 0}
51-
for worker_id, island_id in controller.worker_island_map.items():
52-
island_worker_counts[island_id] += 1
53-
54-
self.assertEqual(island_worker_counts[0], 3)
55-
self.assertEqual(island_worker_counts[1], 2)
56-
self.assertEqual(island_worker_counts[2], 2)
57-
5827
def test_submit_iteration_uses_correct_island(self):
5928
"""Test that _submit_iteration samples from the specified island"""
6029
controller = ProcessParallelController(self.config, self.evaluation_file, self.database)
@@ -117,21 +86,6 @@ def mock_sample_from_island(island_id, num_inspirations=None):
11786
# Check that correct islands were sampled
11887
self.assertEqual(sampled_islands, [0, 1, 2, 0])
11988

120-
def test_fewer_workers_than_islands(self):
121-
"""Test handling when there are fewer workers than islands"""
122-
self.config.evaluator.parallel_evaluations = 2 # Only 2 workers for 3 islands
123-
124-
controller = ProcessParallelController(self.config, self.evaluation_file, self.database)
125-
126-
# Workers should be distributed across available islands
127-
expected_mapping = {
128-
0: 0, # Worker 0 -> Island 0
129-
1: 1, # Worker 1 -> Island 1
130-
# Island 2 has no dedicated worker
131-
}
132-
133-
self.assertEqual(controller.worker_island_map, expected_mapping)
134-
13589
def test_database_current_island_restoration(self):
13690
"""Test that database current_island is properly restored after sampling"""
13791
controller = ProcessParallelController(self.config, self.evaluation_file, self.database)
@@ -271,35 +225,5 @@ def test_migration_preserves_island_structure(self):
271225
"No programs should have _migrant_ suffixes with new implementation")
272226

273227

274-
class TestWorkerPinningEdgeCases(unittest.TestCase):
275-
"""Test edge cases for worker-to-island pinning"""
276-
277-
def test_single_island(self):
278-
"""Test behavior with only one island"""
279-
config = Config()
280-
config.database.num_islands = 1
281-
config.evaluator.parallel_evaluations = 4
282-
283-
database = ProgramDatabase(config.database)
284-
controller = ProcessParallelController(config, "test.py", database)
285-
286-
# All workers should map to island 0
287-
expected_mapping = {0: 0, 1: 0, 2: 0, 3: 0}
288-
self.assertEqual(controller.worker_island_map, expected_mapping)
289-
290-
def test_single_worker(self):
291-
"""Test behavior with only one worker"""
292-
config = Config()
293-
config.database.num_islands = 5
294-
config.evaluator.parallel_evaluations = 1
295-
296-
database = ProgramDatabase(config.database)
297-
controller = ProcessParallelController(config, "test.py", database)
298-
299-
# Single worker should map to island 0
300-
expected_mapping = {0: 0}
301-
self.assertEqual(controller.worker_island_map, expected_mapping)
302-
303-
304228
if __name__ == "__main__":
305229
unittest.main()

0 commit comments

Comments
 (0)