Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
coruscating committed Dec 4, 2024
1 parent 4d5c14e commit 8474072
Show file tree
Hide file tree
Showing 16 changed files with 1,205 additions and 1 deletion.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Python Code Quality Checks

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
code-quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black pylint pytest
pip install .
- name: Check code formatting with Black
run: |
black --check --diff .
- name: Run Pylint
run: |
pylint $(git ls-files '*.py') --disable=C0301,R0913,R0914
- name: Run tests
run: |
python -m pytest tests/ -v
build-success:
needs: code-quality
runs-on: ubuntu-latest
steps:
- name: Build success
run: echo "All code quality checks passed!"
44 changes: 44 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# editor files
.vscode/
.idea/

#standard python ignores follow

# Byte-compiled / optimized / DLL files
__pycache__/
.pytest_cache/
*.py[cod]
*$py.class

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

.DS_Store
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# gadd
# Genetic Algorithm-based optimization of Dynamical Decoupling (GADD)

This is the companion repository to the paper [Empirical learning of dynamical decoupling on quantum processors](https://arxiv.org/abs/2403.02294). You can use this code to train on physical processors then run target circuits with sequences found via GADD.

## Installation

The package can be installed by running `pip install .` in the root directory of the package. If you would like to make changes to the package, you should run `pip install -e .` instead to install it in editable mode.

## Usage

This package is designed to be used on top of [Qiskit](https://github.com/Qiskit/qiskit) and the [Qiskit Runtime IBM Client](https://github.com/Qiskit/qiskit-ibm-runtime).

The core class `GADD` runs the genetic algorithm training process
on training circuits, outputting the best sequence and intermediate training data, if desired, which can be then used to run on a target circuit:

```
service = QiskitRuntimeService()
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=n_qubits)
with Batch(backend=backend):
sampler = SamplerV2()
gadd = GADD(backend=backend)
# train
[seq, data] = gadd.train(backend=backend,
sampler=sampler,
training_circuit=training_circuit,
utility_function=utility_function,
save_iterations=True,
comparison_seqs=["baseline", "xy4", "cpmg","edd"])
# visualize the training progression
gadd.plot(seq, data)
# run on target circuit (can run on a different backend)
gadd.run(
seq = seq,
target_circuit=target_circuit,
sampler=sampler
)
```

1 change: 1 addition & 0 deletions gadd/VERSION.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1
4 changes: 4 additions & 0 deletions gadd/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .gadd import GADD
from .sequences import DDSequence, StandardSequences, DDStrategy
from .library import SequenceUtility
from .utility_functions import UtilityFunction
Loading

0 comments on commit 8474072

Please sign in to comment.