Intelligent framework for optimizing deep learning models with automatic constraint solving, multi-objective optimization, and hardware-aware deployment.
Quick Start β’ Benchmarks β’ Features β’ Examples
| Feature | Standard Tools | This Framework |
|---|---|---|
| Optimization | Single technique | 100+ combinations tested |
| Decision Making | Manual trial-error | Automated constraint solving |
| Deployment | Generic export | Hardware-specific (7 platforms) |
| Analysis | Model file only | Reports + visualizations |
Real Results: 3.67Γ smaller models, 2.48Γ faster inference, 96.6% accuracy retained
Optimized for Snapdragon 8 Gen 2 (mobile deployment):
| Metric | Original | Optimized | Improvement |
|---|---|---|---|
| Model Size | 12.26 MB | 3.34 MB | 3.67Γ smaller β¬οΈ |
| Inference Latency | 147 ms | 59 ms | 2.48Γ faster β‘ |
| Accuracy (mAP) | 37.3% | 36.0% | 96.6% retained β |
Optimization Applied: Dynamic INT8 + Structured Pruning (35%)
Our framework automatically identifies Pareto-optimal solutions from 102 tested combinations - configurations that offer the best trade-offs.
Accuracy vs Latency trade-offs |
Accuracy vs Model Size |
102 combinations tested (β = Pareto optimal) |
3D Pareto visualization |
Performance heatmap across 102 configurations |
Multi-dimensional comparison (Top 20 variants) |
| Metric | Value | Technique |
|---|---|---|
| Best Compression | 3.67Γ | Dynamic INT8 + Magnitude 10% |
| Best Speedup | 3.04Γ | Dynamic INT8 + Structured 65% |
| Best Balanced | Score 11.15 | Dynamic INT8 + Structured 65% |
| Success Rate | 100% (102/102) | All combinations worked |
| Pareto Optimal | 3 solutions | Automatically identified |
π‘ All visualizations auto-generated by running:
python examples/real_world/02_optimize_yolov8.py
git clone https://github.com/N-SriKrishna/ml-optimization-framework.git
cd ml-optimization-framework
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtgit clone https://github.com/N-SriKrishna/ml-optimization-framework.git
cd ml-optimization-framework
pip install -q colorama onnx onnxruntime torch numpy pandas matplotlib pyyaml tqdm ultralytics
python examples/real_world/01_download_yolov8.py
python examples/real_world/02_optimize_yolov8.pyfrom src.analyzers.combination_explorer import CombinationExplorer
from src.converters.smart_deployment_exporter import SmartDeploymentExporter
from src.solvers.constraint_solver import HardwareConstraints
# Explore all combinations
explorer = CombinationExplorer('outputs')
results = explorer.explore_all_combinations('model.onnx', max_combinations=36)
# Get deployment recommendations
hardware = HardwareConstraints(device_name="Snapdragon 888", has_npu=True)
exporter = SmartDeploymentExporter()
exporter.create_deployment_package('model.onnx', hardware, 'outputs/deploy')| Metric | Original | Optimized | Improvement |
|---|---|---|---|
| Model Size | 12.26 MB | 3.34 MB | 3.67Γ smaller β¬οΈ |
| Latency | 147 ms | 59 ms | 2.48Γ faster β‘ |
| Memory | 3.19M params | 2.06M params | 35% less πΎ |
| Accuracy | 37.3% mAP | 36.0% mAP | 96.6% retained β |
| Power | 2.4W | 0.98W | 59% less π |
Configuration: Dynamic INT8 + Structured 35% Pruning
| Platform | Runtime | Latency | Acceleration |
|---|---|---|---|
| Snapdragon 888 | QNN | 59 ms | Hexagon NPU |
| Apple M2 | Core ML | 12 ms | Neural Engine |
| NVIDIA RTX 4090 | TensorRT | 3.2 ms | Tensor Cores |
| Intel Core i9 | OpenVINO | 45 ms | AVX512 |
Convert PyTorch, TensorFlow, TFLite β ONNX with auto-detection and validation
FLOPs, memory profiling, bottleneck identification, layer-wise breakdown
- Quantization: INT8, FP16, mixed-precision
- Pruning: Magnitude, structured, iterative
- Graph Optimization: Fusion, constant folding
from src.solvers.constraint_solver import ConstraintSolver, OptimizationConstraints
constraints = OptimizationConstraints(
hardware=HardwareConstraints(device_name="Snapdragon 888", has_npu=True),
performance=PerformanceConstraints(
max_latency_ms=100,
max_model_size_mb=20,
min_accuracy=0.90
),
optimization_goal='balanced'
)
solver = ConstraintSolver(constraints)
strategy = solver.solve(analysis) # Auto-generates optimal strategyTests 102 combinations (3 quantization Γ 17 pruning Γ 2 orderings) automatically with intelligent exploration
Multi-objective optimization with 7 visualization types (3D plots, radar charts, heatmaps)
Auto-recommends optimal runtime for 7 platforms: Qualcomm, Apple, NVIDIA, Intel, MediaTek, ARM, Android
from src.optimizers.quantizer import quantize_dynamic_int8
from src.optimizers.pruner import prune_magnitude_global
quantize_dynamic_int8('model.onnx', 'model_int8.onnx')
prune_magnitude_global('model.onnx', 'model_pruned.onnx', sparsity=0.5)# Download and optimize YOLOv8
python examples/real_world/01_download_yolov8.py
python examples/real_world/02_optimize_yolov8.py
# Output: 5 variants, Pareto analysis, 7 visualizations, deployment guideml-optimization-framework/
βββ src/
β βββ converters/ # Model conversion & deployment
β βββ analyzers/ # Analysis & combination exploration
β βββ optimizers/ # Quantization & pruning
β βββ solvers/ # Constraint solving
β βββ evaluators/ # Pareto analysis & visualization
β βββ utils/ # Utilities
βββ tests/ # 27 tests, 100% coverage
βββ examples/ # Usage examples
βββ requirements.txt
PYTHONPATH=. pytest tests/ -v
# 27 passed, 33 warnings in 17.31sObject Detection: YOLO (v5, v8, v11), SSD, EfficientDet, Faster R-CNN
Classification: ResNet, EfficientNet, MobileNet, ViT
Segmentation: U-Net, DeepLab, Mask R-CNN
Custom: Any PyTorch/TensorFlow model exportable to ONNX
- Fork the repository
- Create feature branch (
git checkout -b feature/name) - Add tests and ensure they pass
- Submit Pull Request
MIT License - see LICENSE file
ONNX Runtime, PyTorch, TensorFlow, Ultralytics, Qualcomm, Apple, NVIDIA
- Issues: Report bugs
- Discussions: Ask questions
@software{ml_optimization_framework,
title={ML Model Optimization Framework},
author={N Sri Krishna},
year={2025},
url={https://github.com/N-SriKrishna/ml-optimization-framework}
}v1.1: Web GUI, transformer support, Docker
v1.2: NAS, knowledge distillation, cloud deployment
v2.0: GPTQ/AWQ, federated optimization, MLOps integration
β Star this repo if you find it useful! β
Made with β€οΈ for efficient AI deployment





