# microsoft/nni architecture

> Architecture diagram of the GitHub repository microsoft/nni, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/nni
- Repository: https://github.com/microsoft/nni

## Overview

##### High-Level Architecture Components

**a. User Interface Layer**
- Web UI (ts/webui)
- Command Line Interface (nni/tools/nnictl)
- Python API (nni/*.py)

**b. Core Service Layer**
- Experiment Management (nni/experiment)
- Training Service Management (nni/training_service)
- Runtime Management (nni/runtime)

**c. Algorithm Layer**
- HPO (Hyperparameter Optimization)
- NAS (Neural Architecture Search)
- Model Compression
- Feature Engineering

##### Key Component Relationships

**a. Communication Channels**
- REST API (between UI and Core)
- Command Channels (between Core and Training)
- WebSocket (for real-time updates)

**b. Storage Components**
- Database (for experiment data)
- File Storage (for logs and checkpoints)
- Shared Storage Services

##### Training Service Integration

**a. Supported Platforms**
- Local
- Remote
- Cloud (AML)
- Kubernetes-based (OpenPAI, Kubeflow, etc.)

**b. Platform-specific Components**
- Trial Keeper
- GPU Scheduler
- Resource Manager

##### Algorithm Framework Integration

A section displaying:
**a. Framework Support**
- PyTorch
- TensorFlow
- Scikit-learn
- Others

**b. Algorithm Categories**
- Tuners
- Assessors
- Advisors

- Core Components (e.g., blue)
- External Services (e.g., green)
- User Interfaces (e.g., orange)
- Algorithm Components (e.g., purple)
- Storage Components (e.g., yellow)

##### Important Implementation Details

Architectural patterns:
- Modular Design (shown by clear component boundaries)
- Plugin Architecture (for algorithms)
- REST API Design
- Event-driven Communication

##### Deployment View

A section showing:
- Container Support (Docker)
- Multi-platform Deployment
- Scaling Capabilities

- Component Types
- Connection Types
- Version Information

##### The scalability of the system

This structure reflects NNI's sophisticated architecture while making it accessible to understand how the different components interact to provide automated machine learning capabilities.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef ui fill:#FF9900,stroke:#333,stroke-width:2px
    classDef core fill:#3498DB,stroke:#333,stroke-width:2px
    classDef algo fill:#9B59B6,stroke:#333,stroke-width:2px
    classDef storage fill:#F1C40F,stroke:#333,stroke-width:2px
    classDef service fill:#2ECC71,stroke:#333,stroke-width:2px
    classDef framework fill:#E74C3C,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph UI_Layer["User Interface Layer"]
        WebUI["Web UI"]:::ui
        CLI["Command Line Interface"]:::ui
        PyAPI["Python API"]:::ui
    end

    %% Core Service Layer
    subgraph Core_Layer["Core Service Layer"]
        ExpMgmt["Experiment Management"]:::core
        TrainMgmt["Training Service Management"]:::core
        RuntimeMgmt["Runtime Management"]:::core
        CoreServ["Core Services"]:::core
        RestAPI["REST API Server"]:::core
        ExpConfig["Experiment Configuration"]:::core
    end

    %% Algorithm Layer
    subgraph Algo_Layer["Algorithm Layer"]
        HPO["Hyperparameter Optimization"]:::algo
        NAS["Neural Architecture Search"]:::algo
        ModelComp["Model Compression"]:::algo
        FeatEng["Feature Engineering"]:::algo
    end

    %% Storage Components
    DB[(Database)]:::storage
    FileStore[(File Storage)]:::storage

    %% Training Services
    subgraph Train_Services["Training Services"]
        Local["Local"]:::service
        Remote["Remote"]:::service
        Cloud["Cloud (AML)"]:::service
        K8s["Kubernetes"]:::service
    end

    %% Framework Support
    subgraph Frameworks["Framework Support"]
        PyTorch["PyTorch"]:::framework
        TF["TensorFlow"]:::framework
        SKLearn["Scikit-learn"]:::framework
    end

    %% Connections
    WebUI --> RestAPI
    CLI --> CoreServ
    PyAPI --> CoreServ
    RestAPI --> ExpMgmt
    CoreServ --> ExpMgmt
    ExpMgmt --> TrainMgmt
    TrainMgmt --> RuntimeMgmt
    ExpMgmt --> DB
    RuntimeMgmt --> FileStore
    TrainMgmt --> Train_Services
    ExpConfig --> ExpMgmt
    
    %% Algorithm Connections
    HPO --> ExpMgmt
    NAS --> ExpMgmt
    ModelComp --> ExpMgmt
    FeatEng --> ExpMgmt

    %% Framework Connections
    Train_Services --> Frameworks

    %% Click Events
    click WebUI "https://github.com/microsoft/nni/tree/master/ts/webui/"
    click CLI "https://github.com/microsoft/nni/tree/master/nni/tools/nnictl/"
    click PyAPI "https://github.com/microsoft/nni/blob/master/nni/__init__.py"
    click ExpMgmt "https://github.com/microsoft/nni/tree/master/nni/experiment/"
    click TrainMgmt "https://github.com/microsoft/nni/tree/master/nni/training_service/"
    click RuntimeMgmt "https://github.com/microsoft/nni/tree/master/nni/runtime/"
    click HPO "https://github.com/microsoft/nni/tree/master/nni/algorithms/hpo/"
    click NAS "https://github.com/microsoft/nni/tree/master/nni/nas/"
    click ModelComp "https://github.com/microsoft/nni/tree/master/nni/compression/"
    click FeatEng "https://github.com/microsoft/nni/tree/master/nni/algorithms/feature_engineering/"
    click CoreServ "https://github.com/microsoft/nni/tree/master/nni/core/"
    click RestAPI "https://github.com/microsoft/nni/tree/master/ts/nni_manager/rest_server/"
    click ExpConfig "https://github.com/microsoft/nni/tree/master/nni/experiment/config/"
    click Train_Services "https://github.com/microsoft/nni/tree/master/ts/nni_manager/training_service/"

    %% Legend
    subgraph Legend
        UI_L["User Interface"]:::ui
        Core_L["Core Component"]:::core
        Algo_L["Algorithm"]:::algo
        Store_L["Storage"]:::storage
        Service_L["Service"]:::service
        Framework_L["Framework"]:::framework
    end
```
