gadd

Genetic Algorithm-based Dynamical Decoupling with Qiskit

https://github.com/qiskit-community/gadd

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.7%) to scientific vocabulary
Last synced: 9 months ago · JSON representation ·

Repository

Genetic Algorithm-based Dynamical Decoupling with Qiskit

Basic Info
Statistics
  • Stars: 2
  • Watchers: 3
  • Forks: 1
  • Open Issues: 3
  • Releases: 0
Created over 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License Citation

README.md

GADD: Genetic Algorithm for Dynamical Decoupling optimization

Cover Image

Python 3.9+ Qiskit License Coverage Status

GADD is a Python package for empirically optimizing dynamical decoupling (DD) sequences on quantum processors using a genetic algorithm as described in the research paper "Empirical learning of dynamical decoupling on quantum processors".

Installation

Requirements

This package is designed to be used with Qiskit and the Qiskit Runtime IBM Client. To run on IBM hardware, you will need an IBM Quantum account.

Install from PyPI

bash pip install gadd

To install optional dependencies for developing the package and building documentation, run pip install gadd[dev] and pip install gadd[docs] respectively.

Install from Source

bash git clone https://github.com/qiskit-community/gadd.git cd gadd pip install -e .

Usage Examples

The core class GADD runs the genetic algorithm training process on training circuits, outputting the best sequence and intermediate training data, if desired:

1. Basic training

```python from gadd import GADD, TrainingConfig from gadd.utilityfunctions import successprobabilityutility from qiskitibm_runtime import QiskitRuntimeService, Sampler

service = QiskitRuntimeService() backend = service.least_busy()

Create a simple quantum circuit

circuit = QuantumCircuit(3) circuit.h(0) circuit.cx(0, 1) circuit.cx(1, 2) circuit.measure_all()

Simple configuration

config = TrainingConfig(popsize=16, niterations=10) gadd = GADD(backend=backend, config=config)

beststrategy, result = gadd.train( sampler=sampler, trainingcircuit=circuit, utilityfunction=successprobability_utility ) ```

2. Custom parameters

The package supports customizing training parameters and utility functions. Plotting the training progression and running the circuit on the target circuit are also supported.

```python from qiskit.visualization import timeline_drawer

config = TrainingConfig( popsize=32, # Larger population sequencelength=8, # 8-gate DD sequences niterations=50, # More iterations mutationprobability=0.8, # Higher mutation rate shots=8000, # More shots per evaluation numcolors=3, # 3-coloring for qubit graph dynamicmutation=True # Adaptive mutation )

gadd = GADD( backend=backend, config=config, seed=42 )

Train with checkpointing and comparing against canonical sequences

beststrategy, result = gadd.train( sampler=sampler, trainingcircuit=circuit, utilityfunction=utilityfunction, savepath="./checkpoints", benchmarkstrategies=['cpmg', 'cpmgstaggered', 'xy4', 'xy4staggered', 'edd', 'edd_staggered'] )

Plot results

gadd.plottrainingprogress(result, savepath="trainingplot.png")

Run the best sequence on the target circuit

result = gadd.run( strategy = beststrategy, targetcircuit=target_circuit, sampler=sampler ) ```

3. Save and resume training

```python

Resume from previous training

previousstate = gadd.loadtrainingstate("./checkpoints/checkpointiter_20.json")

beststrategy, result = gadd.train( sampler=sampler, trainingcircuit=circuit, utilityfunction=utilityfunction, resumefromstate=previous_state ) ```

4. Custom utility functions

```python def customfidelity(circuit, result): """Custom fidelity-based utility function.""" counts = result.getcounts() total_shots = sum(counts.values())

# Expected distribution for your specific circuit
expected_dist = {'000': 0.5, '111': 0.5}  # GHZ state

# Calculate 1-norm distance
observed_dist = {state: count/total_shots for state, count in counts.items()}

fidelity = 1 - 0.5 * sum(abs(expected_dist.get(state, 0) - observed_dist.get(state, 0)) 
                         for state in set(expected_dist.keys()) | set(observed_dist.keys()))

return fidelity

Use custom utility function

beststrategy, result = gadd.train( sampler=sampler, trainingcircuit=circuit, utilityfunction=UtilityFactory.custom(customfidelity, "Custom Fidelity") ) ```

Directory structure

```text gadd/ ├── README.md # This file ├── pyproject.toml # Package configuration ├── LICENSE # Apache 2.0 license ├── CITATION.bib # BibTeX citation file │ ├── gadd/ # Package directory │ ├── init.py # Package initialization │ ├── gadd.py # Main GADD algorithm implementation │ ├── experiments.py # GADD experiments from the paper │ ├── strategies.py # DD strategy definitions │ ├── utilityfunctions.py # Utility function implementations │ ├── groupoperations.py # Group theory operations │ └── circuitpadding.py # Circuit padding utilities | └── tests/ # Test suite directory ├── _init_.py # Test initialization ├── testgadd.py # Core algorithm tests ├── testsequences.py # DD sequence tests ├── testutilityfunctions.py # Utility function tests ├── testgroupoperations.py # Group operation tests ├── testcircuitpadding.py # Test circuit padding ├── testintegration.py # Integration tests └── fixtures.py # Mock fixtures for testing

```

Citation

If you use GADD in your work, please cite as per the included BibTeX file.

Owner

  • Name: Qiskit Community
  • Login: qiskit-community
  • Kind: organization

Citation (CITATION.bib)

@article{tong2024empirical,
  title={Empirical learning of dynamical decoupling on quantum processors},
  author={Tong, Christopher and Zhang, Helena and Pokharel, Bibek},
  journal={arXiv preprint arXiv:2403.02294},
  year={2024}
}

GitHub Events

Total
  • Watch event: 3
  • Delete event: 1
  • Issue comment event: 1
  • Member event: 1
  • Push event: 16
  • Pull request event: 3
  • Fork event: 1
  • Create event: 8
Last Year
  • Watch event: 3
  • Delete event: 1
  • Issue comment event: 1
  • Member event: 1
  • Push event: 16
  • Pull request event: 3
  • Fork event: 1
  • Create event: 8

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
setup.py pypi