# satwik-kundu/dynamic-parameter-prediction architecture

> Architecture diagram of the GitHub repository satwik-kundu/dynamic-parameter-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/satwik-kundu/dynamic-parameter-prediction
- Repository: https://github.com/satwik-kundu/dynamic-parameter-prediction

## Overview

##### Project type and purpose
- This is a research-oriented quantum machine learning codebase implementing “DyPP” (Dynamic Parameter Prediction) to accelerate convergence of Variational Quantum Neural Networks (QNNs) on an MNIST classification task.
- Key indicators: Python scripts for data generation (`autoencoder.py`), QNN building/training (`qnn_torch.py`), circuit modules under `app/encoder`, `app/pqc`, `app/measurement`, and a paper overview in the README.

##### File structure
Top-level:
- `autoencoder.py` – builds & trains a convolutional autoencoder to compress MNIST to a lower-dimensional feature set.
- `qnn_torch.py` – main entry point for building the QNN (using app/ modules), applying DyPP, and training on the compressed data.
- `prediction.py` – uses the trained DyPP model to predict QNN parameters.
- `train_function.py` – contains the generic training loop (used by `qnn_torch.py`).
- `app/encoder/encoding_circuits.py` – defines feature‐to‐qubit encoding circuits.
- `app/pqc/parametric_circuits.py` – defines parameterized quantum circuit blocks.
- `app/measurement/measurement_circuits.py` – defines measurement operator circuits.
- `app/qnn_builder.py` – orchestrates assembling encoding + PQC + measurement into a full QNN circuit.
- `requirements.txt` – python dependencies (e.g., PyTorch, PennyLane/qiskit, NumPy, Pandas).
- `dypp-overview.pdf` – project overview with schematic.

##### README for additional insights
- Describes the DyPP algorithm and its hyperparameters (`p`, `d`, `k`, `dr`).

a. Main components
1. Data Layer
– Raw MNIST images
– Compressed feature CSV (`latent_mnist_test_d32.csv`)
2. Autoencoder Module (`autoencoder.py`)
– Convolutional encoder/decoder pipeline
3. QNN Builder Layer (`app/encoder`, `app/pqc`, `app/measurement`, `app/qnn_builder.py`)
4. DyPP Predictor (inside `qnn_torch.py`)
5. Training Engine (`train_function.py`)
6. Inference/Prediction Module (`prediction.py`)
7. External Dependencies (PyTorch, PennyLane/qiskit, Pandas, NumPy)

b. Relationships & interactions
- Raw MNIST → Autoencoder → latent feature CSV
- QNN Builder reads CSV → builds circuit graph → PyTorch QNN model
- Training Engine loops: forward(input → QNN), compute loss, backprop + DyPP predictor updates parameters (at interval `p`)
- Prediction Module loads trained DyPP model → predicts next parameters for new circuits
- All modules share common config/hyperparameters (in `qnn_torch.py`)

c. Architectural patterns & principles
- Modular separation: data‐processing (autoencoder), model‐building (circuit modules), training/prediction.
- Plug-and-play circuit blocks: each circuit type (encoding, parametric, measurement) is isolated for extensibility.
- Parameter‐prediction (DyPP) is orthogonal to the training process and can be swapped in/out.

d. Key technologies/frameworks
- Python 3.x
- PyTorch (neural network training)
- PennyLane or Qiskit (quantum circuit simulation) – inferred from QNN context
- Pandas/NumPy (data handling)

##### Detailed elements
- Component labels matching file names or directory names.
- Hyperparameter config block (show `p`, `d`, `k`, `dr`).
- Version of Python or environment (via `requirements.txt`).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Data Preparation"
        raw["Raw MNIST Images"]:::data
        AE["autoencoder.py"]:::comp
        csv["latent_mnist_test_d32.csv"]:::data
    end
    raw -->|"images"| AE
    AE -->|"features"| csv

    subgraph "Quantum Model Construction"
        subgraph "Circuit Modules"
            EC["encoding_circuits.py"]:::quantum
            PC["parametric_circuits.py"]:::quantum
            MC["measurement_circuits.py"]:::quantum
        end
        QB["app/qnn_builder.py"]:::comp
    end
    csv -->|"features"| EC
    EC --> PC
    PC --> MC
    MC -->|"circuit graph"| QB

    subgraph "Training & DyPP"
        TL["train_function.py"]:::comp
        DP["qnn_torch.py"]:::comp
        model["Trained DyPP Model"]:::data
    end
    QB -->|"PyTorch QNN Model"| TL
    TL -->|"training loop"| DP
    DP -->|"parameters"| TL
    DP -->|"model"| model

    subgraph "Inference"
        PR["prediction.py"]:::comp
    end
    model -->|"load model"| PR

    subgraph "Documentation & Dependencies"
        RR["README.md"]:::comp
        REQ["requirements.txt"]:::comp
        PDF["dypp-overview.pdf"]:::comp
    end

    classDef data fill:#9f6,stroke:#333,stroke-width:1px
    classDef comp fill:#6cf,stroke:#333,stroke-width:1px
    classDef quantum fill:#f96,stroke:#333,stroke-width:1px

    click AE "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/autoencoder.py"
    click EC "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/app/encoder/encoding_circuits.py"
    click PC "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/app/pqc/parametric_circuits.py"
    click MC "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/app/measurement/measurement_circuits.py"
    click QB "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/app/qnn_builder.py"
    click TL "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/train_function.py"
    click DP "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/qnn_torch.py"
    click PR "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/prediction.py"
    click PDF "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/dypp-overview.pdf"
    click REQ "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/requirements.txt"
    click RR "https://github.com/satwik-kundu/dynamic-parameter-prediction/blob/main/README.md"
```
