> ## Documentation Index
> Fetch the complete documentation index at: https://doc.blueapi.ir/llms.txt
> Use this file to discover all available pages before exploring further.

# EMEP Executive System Dependency Map

> High-level dependency chain from base models through merge, evolution, evaluation, and deployment, with optional fine-tuning and RAG side loops.

The executive dependency map shows the top-level data and control flow through EMEP. Each stage depends on the successful completion of all upstream stages.

## Dependency Chain

```mermaid theme={null}
flowchart LR
    A["Base Models"] --> B["Compatibility Analysis"]
    B --> C["ModelRegistry"]
    C --> D["MergeEngine"]
    D --> E["CandidateGenerator"]
    E --> F["EvaluationEngine"]
    F --> G["FitnessEngine"]
    G --> H["EvolutionEngine"]
    H --> I{"Converged?"}
    I -->|No| D
    I -->|Yes| J["Model Selection"]
    J --> K["QuantizationEngine"]
    K --> L["DeploymentManager"]

    subgraph Optional["Optional Side Loops"]
        M["LoRA / QLoRA<br/>Fine-Tuning"] -.-> E
        N["RAG Architecture"] -.-> L
    end

    style Optional stroke-dasharray: 5 5
    style A fill:#e3f2fd
    style L fill:#e8f5e9
```

## Stage Descriptions

| Stage                  | Input                                                                  | Output                                                        | Failure Mode                                                                   |
| ---------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| Base Models            | External checkpoints (Hugging Face Hub, enterprise mirror, local path) | DISCOVERED models in ArtifactStore                            | Import failure, corrupted weights, unsupported format                          |
| Compatibility Analysis | Model pairs or sets                                                    | COMPATIBLE / CONDITIONALLY\_COMPATIBLE / INCOMPATIBLE verdict | Shape mismatch, tokenizer vocabulary mismatch, architecture divergence         |
| ModelRegistry          | Validated models                                                       | REGISTERED entries with metadata and lineage                  | Duplicate registration, metadata validation failure                            |
| MergeEngine            | REGISTERED models + MergeStrategy                                      | Merged weight tensors                                         | Out of memory, numerical instability, strategy mismatch                        |
| CandidateGenerator     | Merged weights                                                         | CANDIDATE model with manifest and signature                   | Manifest generation failure, signing error                                     |
| EvaluationEngine       | CANDIDATE + benchmark splits                                           | Metric collection per split                                   | Benchmark execution error, timeout, contamination detected                     |
| FitnessEngine          | Evaluation metrics                                                     | Scalar or vector fitness score                                | Missing required metrics, normalization failure                                |
| EvolutionEngine        | Population + fitness scores                                            | Next generation or termination                                | Premature convergence, diversity collapse, GPU exhaustion                      |
| Model Selection        | Pareto front                                                           | Selected PROMOTED model                                       | No non-dominated candidate meets thresholds                                    |
| QuantizationEngine     | PROMOTED model weights                                                 | Quantized weights (int8, int4)                                | Accuracy degradation beyond tolerance, unsupported ops                         |
| DeploymentManager      | Quantized model + config                                               | RELEASED / DEPLOYED artifact                                  | Packaging failure, signature verification failure, target environment mismatch |

## Optional Side Loops

* **Fine-tuning**: LoRA or QLoRA adapters may be applied to base models before merge, producing task vectors. This loop feeds into CandidateGenerator but is not required for the primary pipeline.
* **RAG**: Retrieval-augmented generation architecture may be attached to deployed models. This is a downstream serving enhancement, not a merge-time dependency.

## Feedback Loop

The evolution cycle creates an iterative dependency: EvolutionEngine feeds back to MergeEngine when convergence is not reached. This loop continues until the population converges or a generation limit is exceeded.

## Next Steps

See [Component Dependency Graph](/maps/component-dependency-graph) for the internal runtime call graph, or [Data Flow Map](/maps/data-flow-map) for the data class flows between stages.
