Skip to main content

Production-grade CLI tool for optimizing HuggingFace models with multiple backends

Project description

๐Ÿš€ Optimum CLI Pro

Production-grade CLI tool for optimizing any HuggingFace model with multiple acceleration backends

A comprehensive solution for model optimization, benchmarking, registry management, A/B testing, and production serving with a beautiful web interface.

Python 3.10+ License: MIT Code style: black


๐Ÿ“‘ Table of Contents


โœจ Features

๐ŸŽฏ Model Optimization

  • 4 Acceleration Backends: ONNX Runtime, OpenVINO, BetterTransformer, Auto-detection
  • Automatic Task Detection: Infers task type from model architecture
  • Quantization Support: INT8 quantization for 2-4x size reduction
  • Custom Optimization: Configure batch size, sequence length, and more
  • Universal Support: Works with 100+ HuggingFace models (BERT, GPT, ViT, etc.)

๐Ÿ“ฆ Model Registry

  • SQLite-Based Registry: Persistent storage for optimized models
  • Version Control: Track multiple versions of the same model
  • Metadata Management: Store optimization settings, metrics, tags, and descriptions
  • Easy Discovery: List, search, and inspect registered models
  • Async Operations: High-performance database queries

๐Ÿงช A/B Testing

  • Side-by-Side Comparison: Compare optimized models against each other
  • Performance Metrics: Throughput (req/s), latency, memory usage, model size
  • Statistical Analysis: Automatic speedup calculation and winner detection
  • Test History: Track all A/B test results with timestamps
  • CLI & API Support: Run tests from command line or REST API

๐ŸŒ REST API & Web Interface

  • FastAPI Server: High-performance async API with OpenAPI documentation
  • Beautiful Custom UI: Gradient-themed web interface (no Swagger!)
  • Real-Time Inference: Test models directly from the browser
  • Visual Comparisons: Interactive A/B testing dashboard with metrics
  • Model Management: Browse and manage registry via intuitive UI
  • Server Status: Real-time health monitoring

๐Ÿ“ˆ MLOps Integration

  • MLflow Support: Track experiments, models, and metrics
  • Weights & Biases: Log optimization results and compare runs
  • Cost Tracking: Monitor optimization time and resource usage

๐Ÿš€ Production Ready

  • Docker Support: Containerized deployment with docker-compose
  • AWS CloudFormation: One-click infrastructure setup for cloud deployment
  • Health Checks: Built-in monitoring endpoints (/health, /api/v1/health)
  • Async Operations: High concurrency support with aiosqlite
  • Error Handling: Comprehensive error messages and logging

๐Ÿ“ฅ Installation

Prerequisites

  • Python: 3.10 or higher
  • pip: 21.0 or higher
  • OS: Windows, Linux, or macOS
  • (Optional) Intel CPU for OpenVINO optimization

Install from Source

# Clone the repository
git clone https://github.com/yourusername/optimum-cli-pro.git
cd optimum-cli-pro

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
.\venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install the package
pip install -e .

Install with Optional Dependencies

# Install with all backends and MLOps tools
pip install -e ".[all]"

# Install with specific backends only
pip install -e ".[onnx]"      # ONNX Runtime only
pip install -e ".[openvino]"  # OpenVINO only
pip install -e ".[mlops]"     # MLflow + Weights & Biases

Verify Installation

optimum-pro --help

You should see:

 Usage: optimum-pro [OPTIONS] COMMAND [ARGS]...

โ•ญโ”€ Commands โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ optimize   Optimize a HuggingFace model             โ”‚
โ”‚ registry   Model registry management                โ”‚
โ”‚ serve      Start API server                         โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿš€ Quick Start

1. Optimize Your First Model

# Optimize BERT with ONNX backend (recommended for cross-platform)
optimum-pro optimize model bert-base-uncased --backend onnx

# Let the CLI choose the best backend for your hardware
optimum-pro optimize model bert-base-uncased --backend auto

# Optimize with OpenVINO (fastest on Intel CPUs)
optimum-pro optimize model bert-base-uncased --backend openvino

# Optimize with custom settings
optimum-pro optimize model roberta-large \
  --backend onnx \
  --batch-size 8 \
  --sequence-length 512 \
  --quantization \
  --output ./my_models

Output Example:

๐Ÿ” Loading model bert-base-uncased...
โœ… Model loaded successfully
๐ŸŽฏ Task detected: fill-mask
๐Ÿš€ Optimizing with ONNX backend...
โฑ๏ธ  Optimization time: 19.23s
๐Ÿ“Š Model size: 418.92 MB
โœ… Model saved to: ./optimized_models/bert-base-uncased

2. Register Your Model

# Register the optimized model in the registry
optimum-pro registry push \
  --name "bert-opt-v1" \
  --path "./optimized_models/bert-base-uncased" \
  --backend onnx \
  --version "1.0.0" \
  --description "BERT base optimized with ONNX Runtime and INT8 quantization"

# List all registered models
optimum-pro registry list

Output Example:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Registered Models โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Name          Version  Backend    Size        Created            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ bert-opt-v1   1.0.0    onnx      418.92 MB   2026-01-30 10:30  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

3. Test Your Model

# Get model information and run a test inference
optimum-pro registry info bert-opt-v1 --test --input "Paris is the capital of [MASK]."

Output Example:

๐Ÿ“ฆ Model: bert-opt-v1
๐Ÿท๏ธ  Version: 1.0.0
โš™๏ธ  Backend: onnx
๐Ÿ“Š Size: 418.92 MB
๐ŸŽฏ Task: fill-mask
๐Ÿ“ Description: BERT base optimized with ONNX Runtime

๐Ÿงช Test Inference:
Input: "Paris is the capital of [MASK]."
Output: france (score: 0.9821)

4. Optimize Another Model for Comparison

# Optimize with a different backend
optimum-pro optimize model bert-base-uncased --backend openvino

# Register the second version
optimum-pro registry push \
  --name "bert-opt-v2" \
  --path "./optimized_models/bert-base-uncased" \
  --backend openvino \
  --version "1.0.0" \
  --description "BERT base optimized with OpenVINO"

5. Run A/B Testing

# Create an A/B test to compare both models
optimum-pro registry ab-test \
  --name "onnx-vs-openvino" \
  --model-a bert-opt-v1 \
  --model-b bert-opt-v2 \
  --description "ONNX vs OpenVINO performance comparison"

# Run the comparison with 100 iterations
optimum-pro registry ab-compare onnx-vs-openvino \
  --input "The capital of France is [MASK]." \
  --iterations 100

# View all A/B test results
optimum-pro registry ab-list

Output Example:

๐Ÿงช A/B Test Results: onnx-vs-openvino
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Model A (bert-opt-v1):
  Throughput: 46.44 requests/sec
  Latency: 21.53 ms
  Size: 508.29 MB

Model B (bert-opt-v2):
  Throughput: 43.36 requests/sec
  Latency: 23.07 ms
  Size: 418.92 MB

๐Ÿ† Winner: Model A (bert-opt-v1)
๐Ÿ“Š Speedup: 1.07x faster
๐Ÿ’พ Size Difference: Model B is 89.37 MB smaller

6. Start the Web Server

# Start the API server with web interface
optimum-pro serve start --port 8000 --host 0.0.0.0

# Server runs at: http://localhost:8000

Access the Web Interface:

Open your browser and navigate to http://localhost:8000 to access:

  • ๐Ÿ“Š Models Tab: Browse all registered models
  • ๐ŸŽฏ Inference Tab: Test models with custom inputs
  • ๐Ÿงช A/B Testing Tab: Run and visualize model comparisons

๐ŸŽฏ Supported Tasks

Optimum CLI Pro supports 9+ task types across text, vision, and multimodal domains:

๐Ÿ“ Text Tasks

Task Description Example Models Example Use Case
fill-mask Predict masked tokens in text BERT, RoBERTa, DistilBERT, ALBERT "Paris is the capital of [MASK]" โ†’ "france"
text-classification Classify text into categories BERT, RoBERTa, DistilBERT "This movie is amazing!" โ†’ positive
token-classification Label each token (NER, POS) BERT, RoBERTa, DistilBERT "John lives in Paris" โ†’ John=PERSON, Paris=LOCATION
text-generation Generate text from prompts GPT-2, GPT-Neo, GPT-J, LLaMA "Once upon a time" โ†’ complete story
question-answering Extract answers from context BERT, RoBERTa, ALBERT, DistilBERT Context + "Who is the president?" โ†’ answer

๐Ÿ–ผ๏ธ Vision Tasks

Task Description Example Models Example Use Case
image-classification Classify images into categories ViT, ResNet, EfficientNet, ConvNeXt Image โ†’ "cat", "dog", "car"
object-detection Detect and locate objects YOLO, DETR, Faster R-CNN Find all people and cars in image
image-segmentation Segment image into regions SegFormer, Mask R-CNN, UNet Separate foreground from background

๐Ÿ”€ Multimodal Tasks

Task Description Example Models Example Use Case
zero-shot-image-classification Classify images without training CLIP, ALIGN Classify images with custom labels

๐Ÿ’ก Pro Tip: Tasks are automatically detected from model architecture. You don't need to specify --task unless you want to override the auto-detection.


๐Ÿ› ๏ธ CLI Commands

Main Command Groups

optimum-pro [OPTIONS] COMMAND [ARGS]...

Available Commands:

  • optimize - Optimize HuggingFace models
  • registry - Manage model registry
  • serve - Start REST API server

optimize model - Model Optimization

Optimize any HuggingFace model with various backends and configurations.

optimum-pro optimize model <MODEL_ID> [OPTIONS]

Required Arguments

Argument Description
MODEL_ID HuggingFace model ID (e.g., bert-base-uncased) or local path

Options

Option Short Type Default Description
--backend -b choice auto Backend to use: auto, onnx, openvino, bettertransformer
--output -o path ./optimized_models Output directory for optimized model
--task -t str auto-detect Task type (see Supported Tasks)
--batch-size int 1 Batch size for optimization
--sequence-length int 128 Maximum sequence length (for text models)
--quantization flag enabled Enable INT8 quantization (default: ON)
--no-quantization flag Disable quantization
--track-mlflow flag Enable MLflow experiment tracking
--track-wandb flag Enable Weights & Biases tracking

Backend Comparison

Backend Best For Speed Size Compatibility
auto Automatic selection - - Detects best backend for your hardware
onnx Cross-platform deployment โšกโšกโšก Fast ๐Ÿ“ฆ Medium Works everywhere (CPU/GPU)
openvino Intel CPUs โšกโšกโšกโšก Fastest ๐Ÿ“ฆ๐Ÿ“ฆ Small Intel CPUs only
bettertransformer Native PyTorch โšกโšก Medium ๐Ÿ“ฆ๐Ÿ“ฆ๐Ÿ“ฆ Large PyTorch environments

Examples

# Basic optimization with auto backend
optimum-pro optimize model bert-base-uncased --backend auto

# Optimize GPT-2 for text generation
optimum-pro optimize model gpt2 --backend onnx --task text-generation

# Optimize ViT for image classification with custom settings
optimum-pro optimize model google/vit-base-patch16-224 \
  --backend openvino \
  --batch-size 16 \
  --no-quantization

# Optimize with MLflow tracking
optimum-pro optimize model roberta-large \
  --backend onnx \
  --quantization \
  --track-mlflow

# Optimize and save to custom directory
optimum-pro optimize model distilbert-base-uncased \
  --backend onnx \
  --output ./my_models/distilbert

registry - Model Registry Management

Manage optimized models in a persistent SQLite registry.

Subcommands

optimum-pro registry [SUBCOMMAND] [OPTIONS]

registry push - Register a Model

Add an optimized model to the registry.

optimum-pro registry push [OPTIONS]

Options:

Option Short Type Required Description
--name -n str โœ… Unique model name
--path -p path โœ… Path to optimized model directory
--backend -b str โœ… Backend used: onnx, openvino, bettertransformer
--version -v str Model version (default: 1.0.0)
--description -d str Model description
--tags -t str Comma-separated tags

Example:

optimum-pro registry push \
  --name "bert-qa-prod" \
  --path "./optimized_models/bert-large-uncased-whole-word-masking-finetuned-squad" \
  --backend onnx \
  --version "2.1.0" \
  --description "Production BERT for Q&A with INT8 quantization" \
  --tags "qa,production,quantized"

registry list - List All Models

Display all registered models.

optimum-pro registry list

Example Output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Registered Models โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Name           Version  Backend    Size        Task          Created       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ bert-opt-v1    1.0.0    onnx      418.92 MB   fill-mask    2026-01-30    โ”‚
โ”‚ bert-opt-v2    1.0.0    openvino  508.29 MB   fill-mask    2026-01-30    โ”‚
โ”‚ gpt2-gen       1.0.0    onnx      548.12 MB   generation   2026-01-29    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

registry info - Get Model Details

Display detailed information about a specific model.

optimum-pro registry info <MODEL_NAME> [OPTIONS]

Arguments:

Argument Description
MODEL_NAME Name of the registered model

Options:

Option Description
--test Run a test inference
--input Test input text (requires --test)

Example:

optimum-pro registry info bert-opt-v1 --test --input "Machine learning is [MASK]."

Example Output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Model Information โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Name:        bert-opt-v1                            โ”‚
โ”‚ Version:     1.0.0                                  โ”‚
โ”‚ Backend:     onnx                                   โ”‚
โ”‚ Task:        fill-mask                              โ”‚
โ”‚ Size:        418.92 MB                              โ”‚
โ”‚ Created:     2026-01-30 10:30:45                    โ”‚
โ”‚ Description: BERT base optimized with ONNX Runtime  โ”‚
โ”‚ Tags:        bert, fill-mask, onnx                  โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿงช Test Inference:
Input: "Machine learning is [MASK]."
Predictions:
  1. used      (score: 0.1234)
  2. important (score: 0.0987)
  3. popular   (score: 0.0765)

registry ab-test - Create A/B Test

Create a new A/B test to compare two models.

optimum-pro registry ab-test [OPTIONS]

Options:

Option Short Type Required Description
--name -n str โœ… Unique test name
--model-a -a str โœ… First model name
--model-b -b str โœ… Second model name
--description -d str Test description

Example:

optimum-pro registry ab-test \
  --name "onnx-vs-openvino-bert" \
  --model-a bert-opt-v1 \
  --model-b bert-opt-v2 \
  --description "Compare ONNX vs OpenVINO on BERT base"

registry ab-compare - Run A/B Test

Execute an A/B test and measure performance metrics.

optimum-pro registry ab-compare <TEST_NAME> [OPTIONS]

Arguments:

Argument Description
TEST_NAME Name of the A/B test

Options:

Option Short Type Default Description
--input -i str required Input text for testing
--iterations -n int 100 Number of iterations to run

Example:

optimum-pro registry ab-compare onnx-vs-openvino-bert \
  --input "The quick brown [MASK] jumps over the lazy dog." \
  --iterations 200

Example Output:

๐Ÿงช Running A/B Test: onnx-vs-openvino-bert
โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”

Testing Model A (bert-opt-v1)...
Progress: โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 100% (200/200)

Testing Model B (bert-opt-v2)...
Progress: โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ 100% (200/200)

๐Ÿ“Š Results:
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Metric          Model A      Model B      Winner     โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Throughput      46.44 req/s  43.36 req/s  Model A    โ”‚
โ”‚ Avg Latency     21.53 ms     23.07 ms     Model A    โ”‚
โ”‚ Model Size      508.29 MB    418.92 MB    Model B    โ”‚
โ”‚ Memory Usage    1.2 GB       1.0 GB       Model B    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

๐Ÿ† Overall Winner: Model A (bert-opt-v1)
๐Ÿ“ˆ Speedup: 1.07x faster
๐Ÿ’พ Size Trade-off: 89.37 MB larger

registry ab-list - List All A/B Tests

Display all A/B tests and their results.

optimum-pro registry ab-list

Example Output:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ A/B Test History โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ Test Name              Models               Status  Winner    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ onnx-vs-openvino-bert  bert-v1 vs bert-v2  โœ… Done  bert-v1  โ”‚
โ”‚ quantized-comparison   bert-q8 vs bert-fp32 โœ… Done bert-q8  โ”‚
โ”‚ gpt-backends           gpt-onnx vs gpt-ov   โœ… Done gpt-onnx โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

serve - Start API Server

Start the FastAPI server with web interface.

Subcommands


serve start - Start Server

Launch the REST API server with web UI.

optimum-pro serve start [OPTIONS]

Options:

Option Short Type Default Description
--host -h str 0.0.0.0 Host to bind to
--port -p int 8000 Port to listen on
--reload flag Enable auto-reload (development)
--workers -w int 1 Number of worker processes

Examples:

# Start server on default port (8000)
optimum-pro serve start

# Start on custom port with auto-reload (development)
optimum-pro serve start --port 3000 --reload

# Production server with multiple workers
optimum-pro serve start --host 0.0.0.0 --port 8000 --workers 4

Server Endpoints:

  • http://localhost:8000 - Web Interface
  • http://localhost:8000/docs - API Documentation (Swagger UI)
  • http://localhost:8000/redoc - Alternative API Docs
  • http://localhost:8000/health - Health Check

serve stop - Stop Server

Stop the running API server.

optimum-pro serve stop

serve status - Server Status

Check if the server is running.

optimum-pro serve status

โš™๏ธ Configuration

Environment Variables

Create a .env file in the project root:

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
API_WORKERS=1

# Model Registry
REGISTRY_DB_PATH=./data/registry.db

# Model Storage
MODELS_DIR=./optimized_models

# MLflow Configuration
MLFLOW_TRACKING_URI=http://localhost:5000
MLFLOW_EXPERIMENT_NAME=optimum-cli

# Weights & Biases
WANDB_PROJECT=optimum-cli
WANDB_ENTITY=your-username

# Logging
LOG_LEVEL=INFO
LOG_FILE=./logs/optimum-cli.log

# Optimization Defaults
DEFAULT_BACKEND=auto
DEFAULT_BATCH_SIZE=1
DEFAULT_SEQUENCE_LENGTH=128
ENABLE_QUANTIZATION=true

Configuration File

Create config.yaml:

# config.yaml
api:
  host: "0.0.0.0"
  port: 8000
  workers: 4
  cors_origins:
    - "http://localhost:3000"
    - "https://yourdomain.com"

registry:
  db_path: "./data/registry.db"
  backup_enabled: true
  backup_interval: "24h"

optimization:
  default_backend: "auto"
  default_batch_size: 1
  default_sequence_length: 128
  quantization_enabled: true
  
  backends:
    onnx:
      enabled: true
      optimization_level: 99
    openvino:
      enabled: true
      device: "CPU"
    bettertransformer:
      enabled: true

mlops:
  mlflow:
    enabled: false
    tracking_uri: "http://localhost:5000"
    experiment_name: "optimum-cli"
  
  wandb:
    enabled: false
    project: "optimum-cli"
    entity: "your-username"

logging:
  level: "INFO"
  format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
  file: "./logs/optimum-cli.log"
  rotation: "10 MB"

๐ŸŒ REST API

Base URL

http://localhost:8000/api/v1

Authentication

Currently, the API is open (no authentication required). For production, implement JWT or API key authentication.


Endpoints

Health Check

GET /health
GET /api/v1/health

Response:

{
  "status": "healthy",
  "timestamp": "2026-01-30T10:30:00Z",
  "version": "1.0.0"
}

List Models

Get all registered models.

GET /api/v1/registry/models

Response:

{
  "models": [
    {
      "name": "bert-opt-v1",
      "version": "1.0.0",
      "backend": "onnx",
      "task": "fill-mask",
      "size_mb": 418.92,
      "created_at": "2026-01-30T10:30:00Z",
      "description": "BERT optimized with ONNX"
    }
  ],
  "total": 1
}

Get Model Info

Get detailed information about a specific model.

GET /api/v1/registry/models/{model_name}

Response:

{
  "name": "bert-opt-v1",
  "version": "1.0.0",
  "backend": "onnx",
  "task": "fill-mask",
  "size_mb": 418.92,
  "path": "./optimized_models/bert-base-uncased",
  "created_at": "2026-01-30T10:30:00Z",
  "updated_at": "2026-01-30T10:30:00Z",
  "description": "BERT optimized with ONNX Runtime",
  "tags": ["bert", "fill-mask", "onnx"],
  "metadata": {
    "quantization": true,
    "batch_size": 1,
    "sequence_length": 128
  }
}

Run Inference

Run inference on a registered model.

POST /api/v1/registry/models/{model_name}/predict
Content-Type: application/json

{
  "input": "Paris is the capital of [MASK].",
  "top_k": 5
}

Response:

{
  "model": "bert-opt-v1",
  "task": "fill-mask",
  "predictions": [
    {
      "token": "france",
      "score": 0.9821,
      "token_id": 2605
    },
    {
      "token": "europe",
      "score": 0.0087,
      "token_id": 2885
    }
  ],
  "inference_time_ms": 12.45
}

Create A/B Test

Create a new A/B test.

POST /api/v1/ab-tests
Content-Type: application/json

{
  "name": "onnx-vs-openvino",
  "model_a": "bert-opt-v1",
  "model_b": "bert-opt-v2",
  "description": "Compare ONNX vs OpenVINO"
}

Response:

{
  "test_id": "test_123",
  "name": "onnx-vs-openvino",
  "status": "created",
  "created_at": "2026-01-30T10:30:00Z"
}

Run A/B Test

Execute an A/B test.

POST /api/v1/ab-tests/{test_id}/run
Content-Type: application/json

{
  "input": "The capital of France is [MASK].",
  "iterations": 100
}

Response:

{
  "test_id": "test_123",
  "status": "completed",
  "results": {
    "model_a": {
      "name": "bert-opt-v1",
      "throughput": 46.44,
      "latency_ms": 21.53,
      "size_mb": 508.29
    },
    "model_b": {
      "name": "bert-opt-v2",
      "throughput": 43.36,
      "latency_ms": 23.07,
      "size_mb": 418.92
    },
    "winner": "model_a",
    "speedup": 1.07
  }
}

List A/B Tests

Get all A/B tests.

GET /api/v1/ab-tests

Response:

{
  "tests": [
    {
      "test_id": "test_123",
      "name": "onnx-vs-openvino",
      "model_a": "bert-opt-v1",
      "model_b": "bert-opt-v2",
      "status": "completed",
      "created_at": "2026-01-30T10:30:00Z"
    }
  ],
  "total": 1
}

๐ŸŽจ Web Interface

Features

The web interface provides a beautiful, gradient-themed UI for managing models:

1. Models Tab ๐Ÿ“Š

  • View all registered models in a grid layout
  • See model details: name, version, backend, size, task
  • Quick actions: test model, view details, delete
  • Real-time model count

2. Inference Tab ๐ŸŽฏ

  • Select any registered model from dropdown
  • Enter custom input text
  • Run inference with one click
  • View predictions with scores
  • See inference time

3. A/B Testing Tab ๐Ÿงช

  • Create new A/B tests
  • Select two models to compare
  • Configure test parameters (iterations)
  • Run comparisons
  • View results in a formatted table:
    • Throughput (req/s)
    • Latency (ms)
    • Model size (MB)
    • Memory usage
    • Winner indication with visual badges

Screenshots

Models Tab:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  ๐Ÿš€ Optimum CLI Pro                              โ”‚
โ”‚  โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”  โ”‚
โ”‚  [Models] [Inference] [A/B Testing]              โ”‚
โ”‚                                                   โ”‚
โ”‚  ๐Ÿ“ฆ Registered Models (2)                        โ”‚
โ”‚                                                   โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”‚
โ”‚  โ”‚ bert-opt-v1     โ”‚  โ”‚ bert-opt-v2     โ”‚       โ”‚
โ”‚  โ”‚ v1.0.0          โ”‚  โ”‚ v1.0.0          โ”‚       โ”‚
โ”‚  โ”‚ Backend: onnx   โ”‚  โ”‚ Backend: openvinoโ”‚      โ”‚
โ”‚  โ”‚ Size: 418.92 MB โ”‚  โ”‚ Size: 508.29 MB โ”‚       โ”‚
โ”‚  โ”‚ [Test] [Info]   โ”‚  โ”‚ [Test] [Info]   โ”‚       โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Accessing the UI

  1. Start the server:

    optimum-pro serve start --port 8000
    
  2. Open your browser:

    http://localhost:8000
    
  3. The UI will load automatically with all features available


๐Ÿ“ฆ Model Registry

Database Schema

The registry uses SQLite with three main tables:

models Table

CREATE TABLE models (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT UNIQUE NOT NULL,
    version TEXT NOT NULL,
    backend TEXT NOT NULL,
    task TEXT,
    path TEXT NOT NULL,
    size_mb REAL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    description TEXT,
    tags TEXT,
    metadata TEXT
);

ab_tests Table

CREATE TABLE ab_tests (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT UNIQUE NOT NULL,
    model_a_id INTEGER NOT NULL,
    model_b_id INTEGER NOT NULL,
    description TEXT,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (model_a_id) REFERENCES models (id),
    FOREIGN KEY (model_b_id) REFERENCES models (id)
);

ab_results Table

CREATE TABLE ab_results (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    test_id INTEGER NOT NULL,
    model_a_throughput REAL,
    model_a_latency REAL,
    model_b_throughput REAL,
    model_b_latency REAL,
    winner TEXT,
    speedup REAL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (test_id) REFERENCES ab_tests (id)
);

Registry Location

Default location: ./data/registry.db

You can change this via:

  • Environment variable: REGISTRY_DB_PATH
  • Config file: registry.db_path

Backup and Restore

# Backup registry
cp ./data/registry.db ./backups/registry_backup_$(date +%Y%m%d).db

# Restore registry
cp ./backups/registry_backup_20260130.db ./data/registry.db

๐Ÿงช A/B Testing

What is A/B Testing?

A/B testing compares two models side-by-side to determine which performs better. The CLI runs multiple iterations and measures:

  • Throughput: Requests per second
  • Latency: Average response time
  • Memory: RAM usage during inference
  • Size: Model file size

Best Practices

  1. Use Same Input: Always use identical input for fair comparison
  2. Multiple Iterations: Run at least 100 iterations for statistical significance
  3. Warm-up: The CLI automatically warms up models before testing
  4. Same Hardware: Run tests on the same machine for consistency

Interpreting Results

Model A (ONNX):     46.44 req/s, 508.29 MB
Model B (OpenVINO): 43.36 req/s, 418.92 MB

Winner: Model A (1.07x faster)
Trade-off: Model A is 89.37 MB larger

Decision Guide:

  • If speed is critical โ†’ Choose Model A (ONNX)
  • If size is critical โ†’ Choose Model B (OpenVINO)
  • If balanced โ†’ Consider 1.07x speedup vs 89 MB size increase

๐Ÿ—๏ธ Architecture

Project Structure

optimum-cli-pro/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ optimum_cli/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ __main__.py              # Entry point
โ”‚       โ”œโ”€โ”€ cli/
โ”‚       โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚       โ”‚   โ”œโ”€โ”€ main.py              # Main CLI app (Typer)
โ”‚       โ”‚   โ”œโ”€โ”€ optimize.py          # Optimize commands
โ”‚       โ”‚   โ”œโ”€โ”€ registry.py          # Registry commands
โ”‚       โ”‚   โ””โ”€โ”€ serve.py             # Serve commands
โ”‚       โ”œโ”€โ”€ core/
โ”‚       โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚       โ”‚   โ”œโ”€โ”€ config.py            # Configuration management
โ”‚       โ”‚   โ”œโ”€โ”€ model_loader.py      # Model loading & task detection
โ”‚       โ”‚   โ”œโ”€โ”€ optimizer.py         # Optimization logic
โ”‚       โ”‚   โ””โ”€โ”€ registry.py          # Registry database operations
โ”‚       โ”œโ”€โ”€ backends/
โ”‚       โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚       โ”‚   โ”œโ”€โ”€ base.py              # Abstract base backend
โ”‚       โ”‚   โ”œโ”€โ”€ onnx_backend.py      # ONNX Runtime backend
โ”‚       โ”‚   โ”œโ”€โ”€ openvino_backend.py  # OpenVINO backend
โ”‚       โ”‚   โ””โ”€โ”€ better_transformer.py # BetterTransformer backend
โ”‚       โ””โ”€โ”€ api/
โ”‚           โ”œโ”€โ”€ __init__.py
โ”‚           โ”œโ”€โ”€ main.py              # FastAPI app
โ”‚           โ”œโ”€โ”€ routes/
โ”‚           โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚           โ”‚   โ”œโ”€โ”€ health.py        # Health endpoints
โ”‚           โ”‚   โ”œโ”€โ”€ registry.py      # Registry endpoints
โ”‚           โ”‚   โ””โ”€โ”€ ab_testing.py    # A/B testing endpoints
โ”‚           โ””โ”€โ”€ static/
โ”‚               โ”œโ”€โ”€ index.html       # Main web UI
โ”‚               โ”œโ”€โ”€ style.css        # Gradient theme CSS
โ”‚               โ””โ”€โ”€ app.js           # Frontend JavaScript
โ”œโ”€โ”€ data/
โ”‚   โ””โ”€โ”€ registry.db                  # SQLite database
โ”œโ”€โ”€ optimized_models/                # Optimized model storage
โ”œโ”€โ”€ deployment/
โ”‚   โ”œโ”€โ”€ docker/
โ”‚   โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ”‚   โ””โ”€โ”€ docker-compose.yml
โ”‚   โ””โ”€โ”€ aws/
โ”‚       โ”œโ”€โ”€ cloudformation.yaml
โ”‚       โ””โ”€โ”€ deploy.sh
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ unit/
โ”‚   โ””โ”€โ”€ integration/
โ”œโ”€โ”€ docs/
โ”œโ”€โ”€ pyproject.toml                   # Project configuration
โ”œโ”€โ”€ requirements.txt                 # Python dependencies
โ”œโ”€โ”€ .env.example                     # Environment template
โ””โ”€โ”€ README.md                        # This file

Technology Stack

  • CLI Framework: Typer + Rich (beautiful terminal UI)
  • API Framework: FastAPI (async, high-performance)
  • Database: SQLite with aiosqlite (async operations)
  • Model Loading: HuggingFace Transformers + Optimum
  • Optimization Backends:
    • ONNX Runtime (optimum[onnxruntime])
    • OpenVINO (optimum-intel)
    • BetterTransformer (native PyTorch)
  • Frontend: Vanilla JavaScript + CSS (no frameworks)
  • Configuration: Pydantic v2 settings management
  • Logging: Python logging with rich formatting

๐Ÿ’ก Examples

Example 1: Optimize Multiple Models

# Optimize different model types
optimum-pro optimize model bert-base-uncased --backend onnx
optimum-pro optimize model gpt2 --backend onnx
optimum-pro optimize model google/vit-base-patch16-224 --backend openvino

# Register all of them
optimum-pro registry push --name bert-fill-mask --path ./optimized_models/bert-base-uncased --backend onnx
optimum-pro registry push --name gpt2-text-gen --path ./optimized_models/gpt2 --backend onnx
optimum-pro registry push --name vit-image-class --path ./optimized_models/vit-base-patch16-224 --backend openvino

Example 2: Complete A/B Testing Workflow

# 1. Optimize same model with different backends
optimum-pro optimize model bert-base-uncased --backend onnx
optimum-pro registry push --name bert-onnx --path ./optimized_models/bert-base-uncased --backend onnx

optimum-pro optimize model bert-base-uncased --backend openvino
optimum-pro registry push --name bert-openvino --path ./optimized_models/bert-base-uncased --backend openvino

# 2. Create A/B test
optimum-pro registry ab-test \
  --name backend-comparison \
  --model-a bert-onnx \
  --model-b bert-openvino \
  --description "ONNX vs OpenVINO on Intel CPU"

# 3. Run comparison
optimum-pro registry ab-compare backend-comparison \
  --input "Machine learning is revolutionizing [MASK]." \
  --iterations 200

# 4. View results
optimum-pro registry ab-list

Example 3: Production Deployment

# 1. Optimize for production
optimum-pro optimize model bert-large-uncased-whole-word-masking-finetuned-squad \
  --backend onnx \
  --quantization \
  --batch-size 8 \
  --sequence-length 512

# 2. Register with production metadata
optimum-pro registry push \
  --name "bert-qa-prod" \
  --path "./optimized_models/bert-large-uncased-whole-word-masking-finetuned-squad" \
  --backend onnx \
  --version "1.0.0" \
  --description "Production BERT Q&A model - INT8 quantized" \
  --tags "production,qa,quantized"

# 3. Start production server
optimum-pro serve start --host 0.0.0.0 --port 8000 --workers 4

# 4. Test via API
curl -X POST http://localhost:8000/api/v1/registry/models/bert-qa-prod/predict \
  -H "Content-Type: application/json" \
  -d '{
    "input": "What is machine learning?",
    "context": "Machine learning is a subset of artificial intelligence..."
  }'

Example 4: MLflow Integration

# Start MLflow server
mlflow server --host 0.0.0.0 --port 5000

# Optimize with MLflow tracking
export MLFLOW_TRACKING_URI=http://localhost:5000
optimum-pro optimize model bert-base-uncased \
  --backend onnx \
  --track-mlflow

# View in MLflow UI
open http://localhost:5000

๐Ÿ‘จโ€๐Ÿ’ป Development

Setup Development Environment

# Clone repository
git clone https://github.com/yourusername/optimum-cli-pro.git
cd optimum-cli-pro

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Linux/Mac
.\venv\Scripts\activate   # Windows

# Install in development mode with all dependencies
pip install -e ".[dev,all]"

# Install pre-commit hooks
pre-commit install

Run Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=optimum_cli --cov-report=html --cov-report=term

# Run specific test file
pytest tests/unit/test_optimizer.py

# Run with verbose output
pytest -v -s

Code Quality

# Format code
black src/ tests/
isort src/ tests/

# Lint code
flake8 src/ tests/
pylint src/

# Type checking
mypy src/

Building Package

# Build distribution
python -m build

# Install built package
pip install dist/optimum_cli_pro-1.0.0-py3-none-any.whl

๐Ÿณ Deployment

Docker Deployment

Build and Run

# Build Docker image
docker build -t optimum-cli-pro:latest .

# Run container
docker run -d \
  --name optimum-cli-pro \
  -p 8000:8000 \
  -v $(pwd)/data:/app/data \
  -v $(pwd)/optimized_models:/app/optimized_models \
  optimum-cli-pro:latest

# View logs
docker logs -f optimum-cli-pro

# Stop container
docker stop optimum-cli-pro

Docker Compose

# docker-compose.yml
version: '3.8'

services:
  api:
    build: .
    ports:
      - "8000:8000"
    volumes:
      - ./data:/app/data
      - ./optimized_models:/app/optimized_models
    environment:
      - API_HOST=0.0.0.0
      - API_PORT=8000
      - LOG_LEVEL=INFO
    restart: unless-stopped

  mlflow:
    image: ghcr.io/mlflow/mlflow:latest
    ports:
      - "5000:5000"
    command: mlflow server --host 0.0.0.0 --port 5000
    volumes:
      - ./mlflow:/mlflow
    restart: unless-stopped
# Start services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

AWS Deployment

Prerequisites

  • AWS CLI configured
  • AWS account with EC2 access
  • Key pair created in AWS

Deploy with CloudFormation

cd deployment/aws

# Deploy stack
aws cloudformation create-stack \
  --stack-name optimum-cli-pro \
  --template-body file://cloudformation.yaml \
  --parameters \
    ParameterKey=KeyName,ParameterValue=your-key-pair \
    ParameterKey=InstanceType,ParameterValue=t2.micro

# Wait for completion
aws cloudformation wait stack-create-complete \
  --stack-name optimum-cli-pro

# Get public IP
aws cloudformation describe-stacks \
  --stack-name optimum-cli-pro \
  --query 'Stacks[0].Outputs[?OutputKey==`PublicIP`].OutputValue' \
  --output text

Manual EC2 Setup

# SSH into EC2 instance
ssh -i your-key.pem ubuntu@your-ec2-ip

# Install dependencies
sudo apt update
sudo apt install -y python3-pip git

# Clone and install
git clone https://github.com/yourusername/optimum-cli-pro.git
cd optimum-cli-pro
pip3 install -e .

# Start server
optimum-pro serve start --host 0.0.0.0 --port 8000

๐Ÿ”ง Troubleshooting

Common Issues

1. "Command not found: optimum-pro"

Solution:

# Reinstall package
pip install -e .

# Or use full path
python -m optimum_cli optimize model bert-base-uncased --backend onnx

2. "Model not found" error

Solution:

# Check HuggingFace Hub connection
pip install -U transformers

# Manually download model
from transformers import AutoModel
model = AutoModel.from_pretrained("bert-base-uncased")

3. OpenVINO optimization fails

Solution:

# Install OpenVINO correctly
pip install optimum[openvino]
pip install openvino

# Verify installation
python -c "from optimum.intel import OVModelForMaskedLM; print('OK')"

4. Server won't start on port 8000

Solution:

# Check if port is in use
netstat -ano | findstr :8000  # Windows
lsof -i :8000                 # Linux/Mac

# Use different port
optimum-pro serve start --port 8080

5. "Too many indices for tensor" error (OpenVINO)

Known Issue: OpenVINO models may have tensor dimension issues with certain tasks.

Solution: Use ONNX backend instead:

optimum-pro optimize model bert-base-uncased --backend onnx

6. Database locked error

Solution:

# Close all connections and restart server
optimum-pro serve stop
rm -f ./data/registry.db-journal
optimum-pro serve start

Debug Mode

Enable debug logging:

# Set environment variable
export LOG_LEVEL=DEBUG

# Or use CLI flag (if implemented)
optimum-pro --debug optimize model bert-base-uncased --backend onnx

Getting Help


๐Ÿค Contributing

We welcome contributions! Here's how you can help:

Reporting Bugs

  1. Check existing issues first
  2. Create a new issue with:
    • Clear title and description
    • Steps to reproduce
    • Expected vs actual behavior
    • System info (OS, Python version)

Suggesting Features

  1. Open an issue with [Feature Request] tag
  2. Describe the feature and use case
  3. Explain why it would be useful

Pull Requests

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass: pytest
  6. Format code: black src/ tests/
  7. Commit: git commit -m 'Add amazing feature'
  8. Push: git push origin feature/amazing-feature
  9. Open a Pull Request

Code Style

  • Follow PEP 8
  • Use Black for formatting
  • Add type hints
  • Write docstrings
  • Add tests

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • HuggingFace: For the amazing Transformers and Optimum libraries
  • FastAPI: For the high-performance web framework
  • Typer: For the beautiful CLI framework
  • Rich: For terminal formatting
  • Intel: For OpenVINO toolkit
  • ONNX Runtime: For cross-platform inference

๐Ÿ“ˆ Roadmap

Version 1.1 (Q2 2026)

  • TensorRT backend support
  • GPU optimization
  • Batch inference API
  • Model versioning with Git
  • Prometheus metrics export

Version 1.2 (Q3 2026)

  • Kubernetes deployment
  • Multi-model serving
  • Model caching
  • Authentication & authorization
  • Rate limiting

Version 2.0 (Q4 2026)

  • Distributed inference
  • Model ensembles
  • AutoML for backend selection
  • Advanced monitoring dashboard
  • CI/CD integration

๐ŸŒŸ Star History

If you find this project useful, please consider giving it a star on GitHub! โญ


๐Ÿ“ž Contact


Made with โค๏ธ for the ML community | Powered by HuggingFace Optimum

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

optimum_cli_pro-1.0.1.tar.gz (82.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optimum_cli_pro-1.0.1-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

Details for the file optimum_cli_pro-1.0.1.tar.gz.

File metadata

  • Download URL: optimum_cli_pro-1.0.1.tar.gz
  • Upload date:
  • Size: 82.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for optimum_cli_pro-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2d3abab8a2e7ab46e48fc90c94bff2422d5fc6bde988276b52539989b5710185
MD5 01606184c00eeb4d6529e5618452c58c
BLAKE2b-256 1e7de7600268bea826efb4bc50d58e57d0e9410778ee97532d7500982da37f7e

See more details on using hashes here.

File details

Details for the file optimum_cli_pro-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for optimum_cli_pro-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 774f00c1170d63432975f91669b6f1a11f7c2e653ca65c6af5386f2cdc4d83dc
MD5 978a2327fff1dfb236c95c2e37ec4ccd
BLAKE2b-256 c249fbf71a9b7a34528ee7137d8c61918ff11ba5c5239e5bad1e0855d0fbc95d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page