# aloshdenny/superfloat-accelerator architecture

> Architecture diagram of the GitHub repository aloshdenny/superfloat-accelerator, 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/aloshdenny/superfloat-accelerator
- Repository: https://github.com/aloshdenny/superfloat-accelerator

## Overview

##### Main Components

a) Core Quantization Components:
- SuperFloat Quantization Engine
- WASQ (Weight and Activation SuperFloat Quantization) System
- LTH (Lottery Ticket Hypothesis) Module

b) Processing Pipeline Components:
- Model Input Handler
- Quantization Processor
- Activation Analysis System
- Evaluation System
- Inference Engine

**┌─────────────────────────────────────────────┐**
- Input Layer                    │
- (Original Model Weights & Activations)      │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Processing Layer                  │
- ┌─────────────┐  ┌─────────────┐  ┌──────┐ │
- SuperFloat │  │    WASQ     │  │ LTH  │ │
- Engine    │←→│  Pipeline   │←→│Module│ │
- ┘  └─────────────┘  └──────┘ │
- ┘
- ↓
**┌─────────────────────────────────────────────┐**
- Output Layer                    │
- (Optimized Quantized Model)                 │
- ┘

##### Detailed Component Breakdown

a) SuperFloat Engine (Core):
- Sign-Exponent Representation (1 bit sign, x-1 bits exponent)
- Value Clamping System (-1 to 1 range)
- Bit-width Scaling (3-16 bits)

b) WASQ Pipeline:
- Weight Quantization Module
- Activation Quantization Module
- Optimization Algorithms:
- WASQ OPT
- Full Parameter Method (FPM)
- Vanilla Implementation

c) LTH Analysis System:
- Activation Magnitude Analyzer
- Weight Pruning Module
- Fine-tuning Controller

##### Integration Points

Connections with:
- Modal Integration
- E2E Cloud Interface
- Tencent Systems

##### The modular nature of the system, showing clear separation between
- Basic quantization (SuperFloat)
- Advanced optimization (WASQ)
- Fine-tuning mechanisms (LTH)

##### The pipeline flow from input through processing to output, with
- Clear entry points for different model types
- Processing stages for weight and activation quantization
- Evaluation and optimization feedback loops

##### The scalability aspects
- Bit-width flexibility (3-16 bits)
- Context length processing
- Parallel processing capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    classDef input fill:#b3d9ff,stroke:#333,stroke-width:2px
    classDef processing fill:#98FB98,stroke:#333,stroke-width:2px
    classDef output fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef analysis fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef core fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef modal fill:#F0E68C,stroke:#333,stroke-width:2px

    subgraph Input["Input Layer"]
        IM[Original Model Weights]:::input
        IA[Activations]:::input
    end

    subgraph Processing["Processing Layer"]
        subgraph Core["Core Components"]
            SFE[SuperFloat Engine]:::core
            WASQ[WASQ System]:::core
            click WASQ "https://github.com/aloshdenny/superfloat-accelerator/blob/main/wasq_opt.py"
            LTH[LTH Module]:::core
            click LTH "https://github.com/aloshdenny/superfloat-accelerator/blob/main/lth_analysis.py"
        end

        subgraph Pipeline["WASQ Pipeline"]
            WQM[Weight Quantization]:::processing
            AQM[Activation Quantization]:::processing
            OPT[Optimization Module]:::processing
            click OPT "https://github.com/aloshdenny/superfloat-accelerator/blob/main/wasq_fasteropt.py"
        end

        subgraph Analysis["Analysis System"]
            AMA[Activation Magnitude Analyzer]:::analysis
            WPM[Weight Pruning Module]:::analysis
            FTC[Fine-tuning Controller]:::analysis
        end

        subgraph Modal["Modal Integration"]
            ME[Modal Evaluator]:::modal
            click ME "https://github.com/aloshdenny/superfloat-accelerator/blob/main/modal/modal_eval.py"
            MO[Modal Optimizer]:::modal
            click MO "https://github.com/aloshdenny/superfloat-accelerator/blob/main/modal/modal_fasteropt.py"
            ML[Modal LTH]:::modal
            click ML "https://github.com/aloshdenny/superfloat-accelerator/blob/main/modal/modal_lth.py"
        end
    end

    subgraph Output["Output Layer"]
        EV[Evaluation System]:::output
        click EV "https://github.com/aloshdenny/superfloat-accelerator/blob/main/wasq_eval.py"
        IE[Inference Engine]:::output
        click IE "https://github.com/aloshdenny/superfloat-accelerator/blob/main/wasq_inference.py"
        QM[Quantized Model]:::output
    end

    %% Connections
    IM --> SFE
    IA --> SFE
    SFE <--> WASQ
    WASQ <--> LTH
    WASQ --> WQM
    WASQ --> AQM
    WQM --> OPT
    AQM --> OPT
    OPT --> AMA
    AMA --> WPM
    WPM --> FTC
    FTC --> ME
    ME --> MO
    MO --> ML
    ML --> EV
    EV --> IE
    IE --> QM

    %% Legend
    classDef legend fill:none,stroke:none
    subgraph Legend
        L1[Input Components]:::input
        L2[Processing Components]:::processing
        L3[Output Components]:::output
        L4[Analysis Components]:::analysis
        L5[Core Components]:::core
        L6[Modal Components]:::modal
    end
```
