|
# Setup Guide for Phase 4 Testing
|
|
|
|
## Quick Start
|
|
|
|
1. **Clone the repository:**
|
|
```bash
|
|
git clone https://huggingface.co/jmurray10/phase4-quantum-compression
|
|
cd phase4-quantum-compression
|
|
```
|
|
|
|
2. **Install dependencies:**
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. **Test compressed models:**
|
|
```python
|
|
import torch
|
|
|
|
# Load compressed model
|
|
model = torch.load('models/mlp_compressed_int8.pth')
|
|
print(f"Model loaded successfully!")
|
|
|
|
# Test inference
|
|
test_input = torch.randn(1, 784)
|
|
output = model(test_input)
|
|
print(f"Output shape: {output.shape}")
|
|
```
|
|
|
|
4. **Run validation tests:**
|
|
```bash
|
|
python tests/test_saved_models.py
|
|
python tests/test_compressed_model_usability.py
|
|
```
|
|
|
|
## Available Models
|
|
|
|
| Model | Type | Size | Path |
|
|
|-------|------|------|------|
|
|
| MLP Original | FP32 | 943KB | `models/mlp_original_fp32.pth` |
|
|
| MLP Compressed | INT8 | 241KB | `models/mlp_compressed_int8.pth` |
|
|
| CNN Original | FP32 | 1.69MB | `models/cnn_original_fp32.pth` |
|
|
| CNN Compressed | INT8 | 483KB | `models/cnn_compressed_int8.pth` |
|
|
|
|
## Running Quantum Experiments
|
|
|
|
```python
|
|
# Example: Run Grover's algorithm
|
|
from src.quantum.qiskit.grover_aer import run_grover_experiment
|
|
|
|
result = run_grover_experiment(n_qubits=3, marked_state=5)
|
|
print(f"Success probability: {result['success_rate']:.3f}")
|
|
```
|
|
|
|
## Energy Measurement
|
|
|
|
```python
|
|
# Example: Measure model energy consumption
|
|
from src.energy.energy_logger_nvml import EnergyLogger
|
|
|
|
logger = EnergyLogger()
|
|
energy = logger.measure_inference_energy(model, test_data)
|
|
print(f"Energy consumed: {energy:.2f} J")
|
|
```
|
|
|
|
## Reproducing Results
|
|
|
|
All results can be reproduced by running the scripts in the `src/` directory.
|
|
No hardcoded values - everything is computed at runtime!
|
|
|