-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d5c14e
commit 8474072
Showing
16 changed files
with
1,205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.