This workshop provides a hands-on experience for optimizing machine learning models to improve performance and reduce costs. You'll learn various optimization techniques including quantization, pruning, knowledge distillation, and fine-tuning.
This workshop uses a minimal dependency approach where each notebook manages its own dependencies:
- Each notebook installs only the packages it needs
- Version requirements are specified directly in each notebook
- Common settings are stored in
workshop_config.json
- Introduction and Setup - Environment setup and model download
- Quantization - Applying quantization techniques
- Pruning - Implementing pruning techniques
- Knowledge Distillation - Creating smaller student models
- Fine-tuning - Adapting models to specific tasks
- Cost Analysis - Analyzing cost implications and ROI
- Resource Cleanup - Cleaning up AWS resources
- AWS account with access to SageMaker
- Basic understanding of machine learning and deep learning concepts
- Familiarity with Python and PyTorch
The easiest way to set up the workshop environment is using the provided CloudFormation template:
- Navigate to the
cloudformationdirectory - Follow the instructions in the
README.mdfile to deploy the CloudFormation stack - After the stack is deployed, follow the "Getting Started" instructions to clone the repository and set up the workshop environment
If you prefer to set up the environment manually:
-
Launch a SageMaker notebook instance with the following specifications:
- Instance type: ml.t3.xlarge (minimum) or ml.g4dn.xlarge (recommended for GPU acceleration)
- Use the standard ML AMI provided by SageMaker
- Attach an IAM role with the necessary permissions (AmazonSageMakerFullAccess and S3 access)
-
Clone this repository to your SageMaker notebook instance:
git clone https://github.com/SaRedfiche/model-optimization-workshop.git cd model-optimization-workshop -
Install the required packages:
pip install -r requirements.txt
-
Open the first notebook
01_introduction_and_setup.ipynband follow the instructions.
If you prefer to run the workshop locally:
-
Clone this repository:
git clone https://github.com/SaRedfiche/model-optimization-workshop.git cd model-optimization-workshop -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Configure AWS credentials:
aws configure
-
Open the first notebook
01_introduction_and_setup.ipynband follow the instructions.
-
Notebook Instance:
- ml.t3.medium: Good for initial notebooks and smaller models (4 vCPUs, 16 GB memory)
- ml.t3.large: Better for more demanding notebooks (2 vCPU, 8 GiB memory)
- ml.g4dn.xlarge: For GPU-accelerated tasks (4 vCPU, 16 GiB memory, 1 GPU)
-
Optimization Instance (for distributed processing):
- ml.c5.xlarge: Good for CPU-based quantization (4 vCPU, 8 GiB memory)
- ml.g4dn.xlarge: For GPU-accelerated tasks (4 vCPU, 16 GiB memory, 1 GPU)
cloudformation/README.md- Instructions for deploying with CloudFormationmodel_optimization_techniques.md- Overview of model optimization techniquesquantization_deep_dive.md- Detailed explanation of quantization methodspruning_techniques.md- Detailed explanation of pruning techniquescost_estimation_for_model_optimization.md- Guide to estimating cost savings
update_notebooks.py- Script to update all notebooks to use standardized importscheck_imports.py- Script to check for import conflicts across notebooks
This project is licensed under the MIT License - see the LICENSE file for details.