Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
7aa1177
Fix unit tests, apply whitespace formatting, update .gitignore, and c…
anurag-r20 Nov 22, 2025
f39b4f9
Changed .gitignore to only ignore data and files relevant to IBM_QAOA
anurag-r20 Nov 23, 2025
93dbe43
chore: update .gitignore for examples and data artifacts
anurag-r20 Nov 25, 2025
6d78673
test: add IBM QAOA test fixtures
anurag-r20 Nov 25, 2025
1cd6967
test: add comprehensive test suite for IBM QAOA processing
anurag-r20 Nov 25, 2025
0d71087
feat: add performance optimizations to IBM QAOA processing
anurag-r20 Nov 25, 2025
804a03f
docs: add performance optimization roadmap
anurag-r20 Nov 25, 2025
0d9bff8
chore: clear notebook outputs in ibm_qaoa_analysis
anurag-r20 Nov 25, 2025
bef72e2
feat: add hardware analysis notebook for IBM QAOA
anurag-r20 Nov 25, 2025
7b929fc
refactor: move Pandas group tests to main tests directory
anurag-r20 Nov 25, 2025
cba3085
README.md edit minor corrections in .json file nomencalture
anurag-r20 Nov 25, 2025
3ac09b8
feat: add support for multiple marker types based on optimization flags
anurag-r20 Nov 25, 2025
927644c
Add minmax cuts integration for approximation ratio calculation
anurag-r20 Dec 22, 2025
009316a
Add integration test for minmax cuts functionality
anurag-r20 Dec 22, 2025
b533a7b
Update analysis notebook with latest cell outputs
anurag-r20 Dec 22, 2025
e030ffe
Separate opt and noOpt variants as independent methods in cross-metho…
anurag-r20 Dec 22, 2025
af173ef
Archived old code, started new processing script
anurag-r20 Feb 9, 2026
5969631
Moved old code to archive
anurag-r20 Feb 9, 2026
a3e3f62
Major revisions to training class
anurag-r20 Feb 10, 2026
fc26b25
Minor revisions to QAOA training class
anurag-r20 Feb 10, 2026
78e8c6d
Create src/ for Processing.py, notebooks/ for Analysis.ipynb
anurag-r20 Feb 10, 2026
4400217
Minor changes to Analysis.ipynb
anurag-r20 Feb 10, 2026
a1ced14
Added DataFrame based analysis and script to evaluate approx ratio fo…
anurag-r20 Feb 10, 2026
269d519
Script and notebook modification to calucate approximation ratios
anurag-r20 Feb 10, 2026
3956d56
Succesful integration of approx ratio calculation for maxcut + IVM QA…
anurag-r20 Feb 11, 2026
dbe9943
Minor fix on QPU_time and num_shots
anurag-r20 Feb 11, 2026
1d5f74c
IBM QAOA training data analysis version 1.0
anurag-r20 Feb 12, 2026
302726d
Preliminary clean up for training DataFrame
anurag-r20 Feb 12, 2026
0d58f3b
minor fix to tables
anurag-r20 Feb 12, 2026
a5800fd
Doctring added to functions and classes. Version 1.0 ready
anurag-r20 Feb 12, 2026
6ee6034
Revert conversion.ipynb to upstream version
anurag-r20 Feb 12, 2026
f57a7d6
Create utils.py, extract instance specific details in DataFrame
anurag-r20 Feb 16, 2026
f45c206
Generated final DataFrame for performance plots
anurag-r20 Feb 16, 2026
b09f4a8
Fixed changes reviewed in PR for Archived code
anurag-r20 Feb 18, 2026
0e63984
Cleaned and up to date notebooks, processing files and README.md
anurag-r20 Feb 21, 2026
3f382fe
Move archived IBM QAOA tests out of main test suite
anurag-r20 Feb 21, 2026
63b4887
Clean scripts
anurag-r20 Feb 23, 2026
9e18ff5
Added markdown for Analysis.ipynb, random seed for iterative QAOA not…
anurag-r20 Feb 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Comment thread
bernalde marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ notebooks/example_data/sk_pleiades_n=200/*
notebooks/example_data/sk_pleiades_n=100/checkpoints/*.DS_Store

# Project-specific data artifacts (examples, runs, plots)
examples/**/exp_raw/
examples/IBM_QAOA/exp_raw/
examples/**/R3R/
examples/**/runs/
examples/**/plots/
Expand Down
157 changes: 0 additions & 157 deletions examples/IBM_QAOA/20250721_171511_example.json

This file was deleted.

204 changes: 204 additions & 0 deletions examples/IBM_QAOA/Archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# IBM QAOA Data Processing

This directory contains tools for processing IBM quantum hardware QAOA (Quantum Approximate Optimization Algorithm) experimental data for MaxCut problems.

## Directory Structure

The processing pipeline requires N-based subdirectory organization:

```
IBM_QAOA/
├── instances/
│ ├── random_regular/N{n}/*.json # R3R problem instances
│ └── heavy_hex/N{n}/*.json # Heavy-hex problem instances
├── R3R/
│ └── minmax_cuts/N{n}/*.json # Minmax cuts for R3R
├── heavy_hex/
│ └── minmax_cuts/N{n}/*.json # Minmax cuts for heavy-hex
├── R3R_results_hardware/ # Hardware results (R3R topology)
├── heavy_hex_results_hardware/ # Hardware results (heavy-hex topology)
└── ibm_qaoa_processing.py # Main processing script
```

**Note**: All data must be organized in N-based subdirectories (e.g., `N40/`, `N144/`). Flat structures are not supported.

## Key Terminology

### QAOA Parameters
- **p** (QAOA layers): Number of parameter layers in QAOA circuit
- Each layer consists of a pair of parameters (γ, β)
- Common values: p = 2, 4, 5, 6, 10
- ⚠️ **Not** circuit depth (which includes all gates)

### Qubit Terminology
- **Program qubits**: Qubits as defined in the problem Hamiltonian (pre-mapping)
- **Physical qubits**: Actual hardware qubits after SAT mapping
- **Edge map**: Dictionary mapping program qubit indices to physical qubit indices

### Energy and Cut Values
- **eval_energy**: QAOA expectation value `<H>` from hardware (can be positive or negative)
- **cut_value**: Sum of weights for edges crossing the partition (always positive)
- **Approximation ratio**: Performance metric in range [0, 1]

## Energy Convention

QAOA for MaxCut uses the Hamiltonian:

```
H = -0.5 * Σ w_ij (1 - Z_i Z_j) for all edges (i,j)
```

Key conversions:
```python
# Transform QAOA energy to cut value
cut_val = eval_energy + 0.5 * sum_weights

# Calculate approximation ratio
approx_ratio = (cut_val - min_cut) / (max_cut - min_cut)
```

## Processing Pipeline

### 1. Load Instance Data
```python
edges = load_instance_file(instance_id, n_nodes, topology='R3R')
# Returns: Dict[(i,j), weight] for program qubits
```

### 2. Load Minmax Cuts
```python
minmax_data = load_minmax_cuts(minmax_dir='R3R/minmax_cuts', n_nodes=40)
# Returns: Dict with min_cut, max_cut, sum_weights for each instance
```

### 3. Process Hardware Trials
```python
result = parse_hardware_trial(trial_data, instance_id, depth, minmax_data, topology)
# Returns: QAOAResult with approximation_ratio, bitstring_cut_values, etc.
```

### 4. Convert to DataFrame
```python
df = results_to_dataframe(results, parameter_names)
# Returns: DataFrame with columns: instance, p, Approximation_Ratio, MeanTime, etc.
```

## Quick Start

```python
import ibm_qaoa_processing as ibm

# Process hardware data
sb, agg_df = ibm.process_qaoa_data(
json_pattern='heavy_hex_results_hardware/N144/*.json',
output_dir='heavy_hex_results_hardware',
n_nodes=144,
topology='heavy_hex',
minmax_dir='heavy_hex/minmax_cuts'
)

# View results
print(agg_df[['instance', 'p', 'Approximation_Ratio', 'method']].head())
```

## Data Files

### Instance Files
Format: `{instance_id}_{params}_weighted.json`
```json
{
"edge list": [
{"nodes": [0, 1], "weight": 1.0},
{"nodes": [1, 2], "weight": 1.0}
],
"Description": "..."
}
```

### Minmax Cuts Files
Format: `{instance_id}_{params}_maxmin_cut.json`
```json
{
"min_cut": 20.0,
"max_cut": 80.0,
"sum_of_weights": 100.0,
"instance": "instances/random_regular/000_40nodes_random3regular.json"
}
```

### Hardware Results Files
Format: `{method}_{instance_id}_p{p}_{hash}.json`
```json
{
"trial_data": {
"counts": {"0101...": 1, "1010...": 1}
},
"circuit_metadata": {
"eval_energy": 10.5,
"params": [0.5, 1.2, ...],
"trainer": "FA_PP_opt_10"
},
"sat_mapper": {
"edge_map": {"0": 0, "1": 5, ...},
"duration": 12.3
}
}
```

## Topologies

### R3R (Random 3-Regular)
- **Structure**: Random 3-regular graphs
- **Node counts**: 10, 20, 40, 50, 60, 70 (All nodes not available for all methods)
- **SAT mapping**: Non-identity (requires bitstring remapping)
- **QAOA Parameter training methods tested**: F, FA, I, TQA, TS, RTS

### Heavy-Hex
- **Structure**: IBM native heavy-hex topology
- **Node counts**: 12, 39, 105, 106, 144 (All nodes not available for all methods)
- **SAT mapping**: Identity mapping (no remapping needed)
- **Methods tested**: F, I, TQA

## Common Issues

### 1. Approximation Ratios > 1
**Solution**: Fixed by applying the canonical energy-to-cut transformation: `cut_val = energy + 0.5 * sum_weights`. The `evaluate_bitstring_cut_value()` function now returns cut values directly.

### 2. Missing N-based Subdirectory
**Error**: `ValueError: N-based subdirectory not found`
**Solution**: Organize files in N-based subdirectories (e.g., `minmax_cuts/N40/`)

### 3. Bitstring Length Mismatch
**Warning**: `Bitstring length != edge_map size`
**Cause**: Hardware measurement on wrong number of qubits
**Impact**: Mismatched bitstrings are skipped

## Analysis Notebook

See `ibm_qaoa_analysis_hardware.ipynb` and - `ibm_qaoa_analysis.ipynb` for:
- Data loading and exploration
- Approximation ratio analysis by method and p
- Performance comparisons across topologies
- Bootstrap analysis for confidence intervals

## Files

- `ibm_qaoa_processing.py` - Main processing pipeline
- `ibm_qaoa_analysis.ipynb` - Simulation results analysis notebook
- `ibm_qaoa_analysis_hardware.ipynb` - Hardware results analysis notebook
- `transfer_simulation_data.py` - Transfer simulation experiment data from source repository
- `transfer_hardware_data.py` - Transfer hardware experiment data from source repository
- `test_approx_ratio_fix.py` - Validation tests for approximation ratio fix
- `demo_realistic_fix.py` - Demonstration with realistic values

## References

- **QAOA-Parameter-Setting repository**: https://github.com/Quantum-Working-Groups/QAOA-Parameter-Setting

- **Stochastic Benchmark framework**: Performance and statistical analysis tools https://github.com/usra-riacs/stochastic-benchmark

- **IBM Quantum**: Hardware execution platform https://www.ibm.com/quantum

## Contact

For questions about the data or processing pipeline, refer to the QAOA-Parameter-Setting repository.
Comment thread
anurag-r20 marked this conversation as resolved.
Loading