Predict GPU execution time & memory for PyTorch models โ without running them.
Project description
Blink ๐ญ
GPU Performance Predictor for Deep Learning Models
Blink predicts execution time and memory usage of PyTorch neural networks on GPU without actually running them. It combines classical ML (XGBoost, Random Forest) with a Graph Neural Network (GNN) that encodes the computational graph of any model architecture.
๐ Table of Contents
- Overview
- Architecture
- Project Structure
- Installation
- Usage
- Data Pipeline
- Model Performance
- Dashboard
- Paper Reproducibility
Overview
Given a PyTorch model and a batch size, Blink answers:
- How long will a forward pass take on this GPU?
- How much GPU memory will it consume?
This is useful for:
- Batch size optimization before deployment
- Hardware cost estimation for training runs
- NAS (Neural Architecture Search) โ filtering architectures by predicted cost
Architecture
PyTorch Model
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Feature Extractor โ โ layer counts, FLOPs, params, depth, width, skip connections
โ + GNN Extractor โ โ graph-based architecture encoding (ArchitectureGNN)
โโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Prediction Models โ
โ โโโโโโโโโโโโโโโโโ โ
โ ยท XGBoost (tuned) โ โ main predictor (best MAPE)
โ ยท Random Forest โ โ ensemble comparison
โ ยท GNN Predictor โ โ graph-native, generalizes across architectures
โ ยท Linear / Ridge โ โ baselines
โโโโโโโโโโโฌโโโโโโโโโโโโ
โ
โผ
Predicted: execution_time_ms, memory_mb
+ Uncertainty bounds (lower / upper)
Project Structure
Blink/
โโโ dashboard.py # ๐ฅ๏ธ Main Streamlit web app (run this)
โโโ prediction_api.py # ๐ Flask REST API
โ
โโโ โโ Core ML Modules โโ
โ โโโ model_profiler.py # GPU profiler (CUDA events)
โ โโโ feature_extractor.py # Static feature extraction from nn.Module
โ โโโ gnn_extractor.py # GNN-based graph feature extraction
โ โโโ gnn_model.py # ArchitectureGNN model definition (PyG)
โ โโโ prediction_model.py # Train XGBoost / RF / Linear models
โ โโโ train_gnn.py # Train the GNN predictor
โ โโโ train_memory_model.py# Train memory prediction model
โ โโโ gpu_predictor.py # Inference class with caching & batch support
โ โโโ model_analyser.py # Model complexity analysis utilities
โ โโโ advanced_features.py # Extended feature engineering
โ โโโ dynamic_predictor.py # Dynamic / online prediction
โ โโโ gpu_info.py # GPU metadata (pynvml)
โ โโโ workload_scheduler.py# Batch workload scheduler
โ โโโ performance_monitor.py
โ
โโโ scripts/ # ๐ฌ Experiment & data scripts
โ โโโ collect_data.py # Profile CNN/Transformer/custom models โ data/raw/
โ โโโ enhance_dataset.py # Augment dataset (more batch sizes / models)
โ โโโ diverse_architectures.py # Profile diverse arch families
โ โโโ ablation_study.py # 5-condition ablation (Table II in paper)
โ โโโ generate_paper_figures.py # Reproduce all paper figures
โ โโโ generate_paper_tables.py # Reproduce paper tables
โ
โโโ tests/ # โ
Test suite
โ โโโ test_diverse_models.py
โ โโโ test_predictors.py
โ โโโ test_profiler.py
โ โโโ test_gnn_scaling.py
โ โโโ evaluate_gnn_vs_xgb.py
โ
โโโ data/
โ โโโ raw/ # Raw profiling CSVs (gitignored)
โ โโโ processed/ # Feature-engineered CSVs
โ โโโ enriched/ # Final training-ready dataset
โ โโโ feedback_log.csv # Online feedback loop log
โ
โโโ models/ # Serialized model artifacts (gitignored)
โ โโโ xgboost_(tuned)_model.joblib
โ โโโ random_forest_model.joblib
โ โโโ gnn_predictor.pth
โ โโโ memory_model.joblib
โ โโโ ...
โ
โโโ results/
โ โโโ figures/ # Paper figures (PNG)
โ โโโ ablation_study_table.csv
โ โโโ gnn_scaling_table.csv
โ โโโ ...
โ
โโโ templates/index.html # HTML template for web interface
โโโ legacy/ # Archived / superseded scripts
โโโ requirements.txt
โโโ .gitignore
Installation
# 1. Clone the repo
git clone <your-repo-url>
cd Blink
# 2. Create a virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Linux/macOS
# 3. Install dependencies
pip install -r requirements.txt
# 4. Install PyTorch Geometric (match your CUDA version)
# See: https://pytorch-geometric.readthedocs.io/en/latest/install/installation.html
pip install torch-geometric
Requirements: NVIDIA GPU with CUDA, Python โฅ 3.10
Usage
1. Launch the Dashboard
streamlit run dashboard.py
Features: live model prediction, batch size optimizer, model comparison, performance monitor.
2. Collect Profiling Data
python scripts/collect_data.py --batch-sizes 1 4 16 32 64
3. Train Prediction Models
# Train XGBoost / RF / Linear baseline models
python prediction_model.py
# Train GNN predictor
python train_gnn.py
# Train memory model
python train_memory_model.py
4. Run Ablation Study
python scripts/ablation_study.py
5. Predict via Python API
from gpu_predictor import GPUPredictor
import torchvision.models as models
predictor = GPUPredictor()
model = models.resnet50(pretrained=False)
result = predictor.predict_for_custom_model(model, batch_size=16)
print(result)
# {'execution_time_ms': 12.4, 'memory_mb': 1820, 'confidence_lower': 11.1, ...}
Data Pipeline
collect_data.py
โโโถ data/raw/*.csv (GPU profiling measurements)
โ
โผ
feature_extractor.py
โโโถ data/processed/*.csv (static model features)
โ
โผ
enhance_dataset.py
โโโถ data/enriched/*.csv (augmented, training-ready)
โ
โผ
prediction_model.py / train_gnn.py
โโโถ models/ (trained predictors)
Model Performance
Results on held-out test set (20% split):
| Model | Exec Time MAPE | Memory MAPE | Notes |
|---|---|---|---|
| XGBoost (tuned) | ~8% | ~6% | Best overall |
| Random Forest | ~11% | ~9% | Robust baseline |
| GNN Predictor | ~10% | ~8% | Best on unseen architectures |
| Linear Regression | ~22% | ~19% | Baseline |
(Full ablation study results: results/ablation_study_table.csv)
Dashboard
The Streamlit dashboard (dashboard.py) provides:
| Tab | Description |
|---|---|
| ๐ฏ Prediction | Predict execution time & memory for standard or custom models |
| โก Batch Optimizer | Find optimal batch size within a memory budget |
| ๐ Model Comparison | Compare predictions across multiple architectures |
| ๐ Performance Monitor | Live GPU utilization and prediction history |
Paper Reproducibility
To reproduce all paper figures and tables:
python scripts/generate_paper_figures.py
python scripts/generate_paper_tables.py
python scripts/ablation_study.py
Outputs saved to results/figures/.
License
MIT License โ see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blink_gpu-0.1.0.tar.gz.
File metadata
- Download URL: blink_gpu-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8005ab7f8e210f1d127ebe2d5c8c7dbde541b2b9b8496360a6b74bac47b55b4
|
|
| MD5 |
3b74c1523cdbc819bb135025a6dca76e
|
|
| BLAKE2b-256 |
bfe8c76923fe63db0ae8771f01f3eb6a520689dff18ba03135ff5632b6e1c518
|
File details
Details for the file blink_gpu-0.1.0-py3-none-any.whl.
File metadata
- Download URL: blink_gpu-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa9d5eda9449a670ed7da2f5787294d042104f002f849afa6a33ab043e4762da
|
|
| MD5 |
8223cc0fee97ec93d6ca8bb7672ee5be
|
|
| BLAKE2b-256 |
f0d57b434549a276ef26486990e998fdd44f19b7681af5077ef0bc23f963742c
|