# kaistmm/audio-mamba-aum architecture

> Architecture diagram of the GitHub repository kaistmm/audio-mamba-aum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kaistmm/audio-mamba-aum
- Repository: https://github.com/kaistmm/audio-mamba-aum

## Overview

##### Project type and purpose
- Audio-Mamba (AuM) is a machine-learning project implementing a bidirectional state space model for audio classification.
- It provides code for data loading/processing, model definitions, training orchestration (multi-GPU via Hugging Face Accelerate), experiment scripts, and inference examples.

##### File structure
Top-level directories and files
- examples/inference – Jupyter notebook and sample data showing how to load a trained model and run inference.
- exps – Predefined experiment folders for each benchmark dataset (AudioSet, Epic-Sounds, VGGSound, etc.). Each contains:
– bash scripts (e.g., aum_eval.sh, training configs)
– data subfolders with class labels and split files
- src – Core Python code:
– dataloader.py – dataset wrapper, spectrogram extraction, augmentations
– src/epic_sounds/epic_data – data loader and config for EPIC-SOUNDS (YAML config, build logic, distributed utils, spec-augment)
– src/models – AST- and Mamba-based model definitions (ast_models.py, mamba_models.py)
– run.py, traintest.py – CLI entry points for training/evaluation
– src/utilities – helper modules (tokenization, stats, utilities)
- vim-mamba_ssm – a vendored copy of the Mamba SSM library (state space operations, triton kernels, module wrappers)
- requirements.txt – Python dependencies
- README.md, LICENSE, .gitignore

##### README for additional insights
- Dependencies: PyTorch, torchvision, torchaudio, Hugging Face Accelerate, causal_conv1d, mamba_ssm.
- EPIC-SOUNDS uses a special YAML config and a dedicated loader in src/epic_sounds/epic_data.

a. Main components
1. Data Sources
- Benchmark datasets (AudioSet, VGGSound, VoxCeleb, SpeechCommands, EPIC-SOUNDS, etc.)
- Sample WAV files (examples/inference/data)
2. Data Ingestion & Preprocessing
- dataloader.py and epic_data module – waveform loading, spectrogram extraction, spec-augment
3. Core Model
- AuM model classes (src/models/mamba_models.py)
- AST backbone variants (src/models/ast_models.py)
- MambaSSM library (vim-mamba_ssm/mamba_ssm) for state space layers
4. Training Orchestration
- run.py / traintest.py – command-line interface invoking Accelerate for multi-GPU
- exps/*/*.sh – experiment bash scripts setting hyperparameters, dataset paths, output dirs
5. Inference & Evaluation
- examples/inference/inference.ipynb – loading checkpoint, running forward pass on sample audio
- exps/*/aum_eval.sh – dataset-specific evaluation scripts
6. External Services & Artifacts
- Hugging Face Accelerate (multi-GPU distribution)
- PyTorch ecosystem
- Checkpoint storage (Google Drive links)

b. Relationships and interactions
- Data Sources feed into Data Ingestion modules
- Preprocessed features passed to Core Model
- Core Model forwards use MambaSSM components for bidirectional state processing
- Training Orchestration schedules epochs, handles multi-GPU via Accelerate
- Checkpoints written to disk or cloud storage
- Inference modules load checkpoints and mirror the data preprocessing + model forward path
- Experiment scripts wrap run.py/training entry points with dataset-specific configs

c. Architectural patterns and design principles
- Modular separation: data, model, training, utilities, experiments
- Reuse of external libraries – AST code, MambaSSM for SSM operations, Accelerate for distribution
- Config-driven design – YAML for EPIC-SOUNDS, shell scripts for experiments
- CLI-based entry points (run.py, traintest.py) rather than monolithic notebooks

d. Key technologies, frameworks, and libraries
- Python 3.10
- PyTorch / torchvision / torchaudio
- Hugging Face Accelerate
- causal_conv1d, mamba_ssm (state space operations)
- Jupyter (inference notebook)
- Bash for experiment orchestration

##### Diagramming recommendations
- Annotations for key interactions (e.g., “Accelerate.distributed.launch”, “spec_augment module”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Sources
    subgraph "Data Sources"
        direction TB
        DS1["Benchmark Datasets"]:::data
        DS2["Sample Audio"]:::data
    end

    %% Data Ingestion & Preprocessing
    subgraph "Data Ingestion & Preprocessing"
        direction TB
        DP1["Generic Loader\n(src/dataloader.py)"]:::preproc
        DP2["EPIC-SOUNDS Loader & Config\n(src/epic_sounds/epic_data/)"]:::preproc
    end

    %% Core Model
    subgraph "Core Model"
        direction TB
        CM1["AST Backbone Variants\n(src/models/ast_models.py)"]:::model
        CM2["AuM/Mamba Models\n(src/models/mamba_models.py)"]:::model
        CM3["State Space Modules & Ops\n(vim-mamba_ssm/mamba_ssm/)"]:::model
    end

    %% Training Orchestration
    subgraph "Training Orchestration"
        direction TB
        TO1["CLI Entry Points\n(src/run.py, src/traintest.py)"]:::train
        TO2["Experiment Bash Scripts\n(exps/*/*.sh)"]:::train
    end

    %% Inference & Evaluation
    subgraph "Inference & Evaluation"
        direction TB
        IE1["Inference Notebook\n(examples/inference/inference.ipynb)"]:::infer
        IE2["Eval Scripts\n(exps/*/aum_eval.sh)"]:::infer
    end

    %% Utilities & Stats
    subgraph "Utilities & Stats"
        direction TB
        U1["Utilities\n(src/utilities/)"]:::util
        U2["Dataset Stats Computation\n(src/get_norm_stats.py)"]:::util
    end

    %% Project Metadata & Dependencies
    subgraph "Project & Dependencies"
        direction TB
        P1["requirements.txt"]:::ext
        P2["README.md / LICENSE / .gitignore"]:::ext
    end

    %% Data Flow
    DS1 --> DP1
    DS1 --> DP2
    DS2 --> DP1
    DP1 --> CM1
    DP1 --> CM2
    DP2 --> CM2
    CM1 --> CM2
    CM2 --> CM3

    %% Training Flow
    CM3 --> TO1
    TO2 --> TO1
    DS1 --> TO2

    %% Inference Flow
    DP1 --> IE1
    CM2 --> IE1
    DS1 --> IE2
    CM2 --> IE2

    %% Utilities & Stats Connections
    U1 --> DP1
    U1 --> CM2
    U2 --> DP1

    %% Dependencies
    P1 --> CM2
    P1 --> TO1
    P1 --> IE1
    P2 --> TO1

    %% Click Events
    click DS2 "https://github.com/kaistmm/audio-mamba-aum/tree/main/examples/inference/data/"
    click DS1 "https://github.com/kaistmm/audio-mamba-aum/tree/main/exps/*/data/"
    click DP1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/dataloader.py"
    click DP2 "https://github.com/kaistmm/audio-mamba-aum/tree/main/src/epic_sounds/epic_data/"
    click CM1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/models/ast_models.py"
    click CM2 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/models/mamba_models.py"
    click CM3 "https://github.com/kaistmm/audio-mamba-aum/tree/main/vim-mamba_ssm/mamba_ssm/"
    click TO1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/run.py"
    click TO1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/traintest.py"
    click TO2 "https://github.com/kaistmm/audio-mamba-aum/blob/main/exps/*/*.sh"
    click IE1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/examples/inference/inference.ipynb"
    click IE2 "https://github.com/kaistmm/audio-mamba-aum/blob/main/exps/*/aum_eval.sh"
    click U1 "https://github.com/kaistmm/audio-mamba-aum/tree/main/src/utilities/"
    click U2 "https://github.com/kaistmm/audio-mamba-aum/blob/main/src/get_norm_stats.py"
    click P1 "https://github.com/kaistmm/audio-mamba-aum/blob/main/requirements.txt"
    click P2 "https://github.com/kaistmm/audio-mamba-aum/blob/main/README.md"

    %% Styles
    classDef data fill:#D6E9FF,stroke:#3B73AF,color:#0B214A;
    classDef preproc fill:#E0F7FA,stroke:#00796B,color:#004D40;
    classDef model fill:#E8F5E9,stroke:#388E3C,color:#1B5E20;
    classDef train fill:#FFF3E0,stroke:#F57C00,color:#E65100;
    classDef infer fill:#F3E5F5,stroke:#8E24AA,color:#4A148C;
    classDef util fill:#F0F4C3,stroke:#9E9D24,color:#827717;
    classDef ext fill:#ECEFF1,stroke:#607D8B,color:#263238;
```
