This specification is for a system that has not yet been implemented. All algorithmic details, parameters, and performance characteristics are engineering assumptions unless otherwise tagged.
Master Algorithm Flowchart
The following flowchart describes the complete lifecycle of an evolutionary run from initialization through termination.Multi-Objective Sub-Flow
When running in multi-objective mode, the fitness calculation and selection steps are replaced by the following sub-flow:Purpose
The EvolutionEngine performs automated, directed search over the space of possible merged models. It uses evolutionary algorithms to explore combinations of parent models, merge strategies, and hyperparameters to produce candidates that outperform any individual parent on target benchmarks.Problem Definition
Given a set of base models (M = {m_1, m_2, …, m_n}), a set of merge strategies (S = {s_1, s_2, …, s_k}), and a fitness function (F), find the merged model (m^) that maximizes (F(m^)) subject to constraints on model size, inference latency, and safety thresholds.Inputs
Preconditions
- All
base_modelsmust be inREGISTEREDorEVALUATEDlifecycle state. - At least two base models must be marked
COMPATIBLEorCONDITIONALLY_COMPATIBLE. - The
evaluation_profilemust contain at least one benchmark split. compute_budgetmust be greater than zero.
Parameters
Tensor Shapes
Not applicable at the engine level. Tensor shapes are validated per-candidate by the MergeEngine and TensorEngine.Mathematical Formulation
Single-Objective Fitness Maximization
Where:- is the genome search space
- is the scalar fitness of genome
- is the constraint penalty
Multi-Objective Formulation
Subject to:- for all constraints
- produces a valid merged model
Step-by-Step Processing
1
Initialize Search Space
Enumerate all valid combinations of parent model IDs and merge strategies based on compatibility analysis. Filter out infeasible combinations (e.g., Franken-Merge requires architectural alignment).
2
Initialize Population
Generate
population_size genomes using the configured initialization strategy: random, seeded from known good configurations, or warm-started from a previous experiment.3
Validate Candidates
For each genome, invoke ModelCompatibilityAnalyzer to verify parent compatibility. Reject genomes with
INCOMPATIBLE parents before merge.4
Evaluate Candidates
Dispatch each valid candidate to the EvaluationEngine for benchmark execution. Collect per-metric scores.
5
Calculate Fitness
Aggregate per-metric scores into a fitness scalar (single-objective) or vector (multi-objective). Apply constraint penalties and regression penalties.
6
Rank Population
Sort by fitness descending (single-objective) or perform non-dominated sorting (multi-objective).
7
Check Termination
Evaluate termination criteria in order: max generations, max candidates, compute budget exhausted, no improvement for N generations.
8
Selection
Select parents for reproduction using tournament, truncation, or rank-based selection. In multi-objective mode, use NSGA-II selection with crowding distance.
9
Mutation
Apply mutation operators to selected genomes with probability
mutation_rate. See Mutation for operator details.10
Crossover
Apply crossover operators to pairs of selected genomes with probability
crossover_rate. See Crossover for operator details.11
Generate Offspring
Produce new genomes from mutated/crossed parents. Ensure population size is maintained.
12
Validate Offspring
Re-run compatibility and structural validation on new genomes. Reject invalid offspring.
13
Evaluate Offspring
Dispatch valid offspring to the EvaluationEngine.
14
Diversity and Constraint Check
Compute pairwise genome distances. If diversity falls below
diversity_threshold, inject random immigrants. Re-check constraints.15
Next Generation
Combine elites, surviving parents, and valid offspring to form the next generation. Increment generation counter.
Decision Points
Branch Conditions
- Single-objective branch: Uses weighted sum fitness, tournament selection, and elitism.
- Multi-objective branch: Uses Pareto dominance, non-dominated sorting, NSGA-II selection, and returns a Pareto front.
- Warm-start branch: If prior experiment lineage exists, seed initial population with top performers from related experiments.
Outputs
Failure Conditions
- Invalid configuration: Missing required fields or out-of-range parameters. Status:
FAILED. - No compatible parents: All base model pairs are
INCOMPATIBLE. Status:FAILED. - All candidates invalid: Merge or validation fails for every genome. Status:
FAILED. - Compute budget exhausted: Wall-clock or GPU-hour limit reached before termination. Status:
CANCELLED. - Evaluation failure: EvaluationEngine returns
INCOMPLETEfor all candidates. Status:FAILED.
Validation
- Configuration schema validated against JSON Schema before run start.
- All parent model IDs verified against ModelRegistry.
- Merge strategy compatibility checked per genome.
- Fitness values bounded to prevent NaN/Inf propagation.
Complexity
Memory Requirements
- Population storage: where is genome size (typically < 1 KB per genome).
- Model checkpoint caching: where = cached candidates, = model size.
- Fitness trajectory: where = max generations.
Numerical Stability
- Fitness scores clipped to to prevent overflow.
- Constraint penalties additive, not multiplicative, to avoid gradient collapse.
- Crowding distance computation uses normalized objective ranges.
Precision Considerations
- Fitness aggregation uses
float64to prevent precision loss across many objectives. - Alpha coefficients stored as
float32in genomes (sufficient for merge operations). - Generation counter:
int64.
Reproducibility
- Random seeds set for population initialization, mutation, and selection.
- All hyperparameters logged to ExperimentTracker.
- Genome lineage tracked via parent pointers for full provenance.
Unit Tests
Integration Tests
Acceptance Criteria
- Single-objective run produces a candidate with fitness greater than best parent baseline (Research hypothesis).
- Multi-objective run produces a Pareto front with at least two non-dominated solutions.
- Termination criteria are independently configurable and correctly enforced.
- All experiment states transition correctly:
CREATED→PREPARING→RUNNING→EVALUATING→COMPLETED. - Full lineage traceable from any output candidate to its original parents.
Known Limitations
- Evaluation cost dominates runtime; no asynchronous or batched evaluation specified yet (Future goal).
- No adaptive hyperparameter tuning during the run (Research hypothesis).
- Diversity metric is Hamming distance on genome encoding; may not reflect phenotypic diversity (Engineering assumption).
Research References
- Evolutionary Model Merge: Akiba et al. 2024
- NSGA-II: Deb et al. 2002 (for multi-objective selection)
- Model Soups: Wortsman et al. 2022 (for weighted merging baseline)