Downloads Β· 30 days
0
jmurray10/phase4-quantum-compression
phase4-quantum-compression is a machine learning model from jmurray10. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
[](https://opensource.org/licenses/Apache-2.0) []() []() []()
Downloads Β· 30 days
0
Access
Public
Updated Aug 27, 2025
Repo size
3.6 MB
Likes
0
Public
Click a slice to open those files.
.pth3.4 MB Β· 89%
From the Hugging Face model README
This repository contains compressed PyTorch models from the Phase 4 experiment, demonstrating:
| Model | Original Size | Compressed Size | Ratio | Download |
|---|---|---|---|---|
| MLP | 943,404 bytes | 241,202 bytes | 3.91Γ | mlp_compressed_int8.pth |
| CNN | 1,689,976 bytes | 483,378 bytes | 3.50Γ | cnn_compressed_int8.pth |
pip install torch huggingface-hub
from huggingface_hub import hf_hub_download
import torch
import torch.nn as nn
# Download compressed MLP model
model_path = hf_hub_download(
repo_id="jmurray10/phase4-quantum-compression",
filename="models/mlp_compressed_int8.pth"
)
# Load model
compressed_model = torch.load(model_path)
print(f"Model loaded from: {model_path}")
# Use for inference
test_input = torch.randn(1, 784)
with torch.no_grad():
output = compressed_model(test_input)
print(f"Output shape: {output.shape}")
# Download original for comparison
original_path = hf_hub_download(
repo_id="jmurray10/phase4-quantum-compression",
filename="models/mlp_original_fp32.pth"
)
original_model = torch.load(original_path)
# Compare sizes
import os
original_size = os.path.getsize(original_path)
compressed_size = os.path.getsize(model_path)
ratio = original_size / compressed_size
print(f"Original: {original_size:,} bytes")
print(f"Compressed: {compressed_size:,} bytes")
print(f"Compression ratio: {ratio:.2f}Γ")
# How models were compressed
import torch.quantization as quant
model.eval()
quantized_model = quant.quantize_dynamic(
model,
{nn.Linear, nn.Conv2d}, # Quantize these layer types
dtype=torch.qint8 # Use INT8
)
MLP Model (235K parameters):
βββ FP32 Size: 943KB
βββ INT8 Size: 241KB
βββ Ratio: 3.91Γ
βββ Quality: 99.8% preserved
CNN Model (422K parameters):
βββ FP32 Size: 1,690KB
βββ INT8 Size: 483KB
βββ Ratio: 3.50Γ
βββ Quality: 99.7% preserved
Baseline (FP32):
βββ Power: 125W average
βββ Energy: 1,894 kJ/1M tokens
Quantized (INT8):
βββ Power: 68.75W average
βββ Energy: 813 kJ/1M tokens
βββ Reduction: 57.1%
These models were benchmarked alongside quantum computing experiments:
phase4-quantum-compression/
βββ models/
β βββ mlp_original_fp32.pth # Original model
β βββ mlp_compressed_int8.pth # Compressed model
β βββ cnn_original_fp32.pth # Original CNN
β βββ cnn_compressed_int8.pth # Compressed CNN
βββ src/
β βββ compression_pipeline.py # Compression code
β βββ benchmark.py # Benchmarking utilities
β βββ validate.py # Quality validation
βββ results/
β βββ compression_metrics.json # Detailed metrics
β βββ energy_measurements.csv # Energy data
βββ notebooks/
βββ demo.ipynb # Interactive demo
All models have been validated for:
@software{phase4_compression_2025,
title={Phase 4: Quantum-ML Compression Models},
author={Phase 4 Research Team},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/jmurray10/phase4-quantum-compression}
}
Apache License 2.0 - See LICENSE file
Contributions welcome! Areas for improvement: