Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacika02 authored Nov 15, 2023
2 parents b4e2f1c + 6a10cd5 commit dc3fc7e
Show file tree
Hide file tree
Showing 328 changed files with 59,533 additions and 4,579 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: pre-commit
on:
pull_request:
push:
branches: [master]
branches: [main]

jobs:
pre-commit:
Expand All @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10.6' # TODO: Remove .6 when mypy fixes issue 13627
python-version: '3.11'
- name: set PY
run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- uses: actions/cache@v1
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ name: tests
on:
pull_request:
push:
branches: [master]
branches: [main]

jobs:
tests:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [macOS-latest, windows-latest, ubuntu-latest]
Expand All @@ -20,10 +21,12 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Upgrade python environment
run: python -m pip install --upgrade virtualenv setuptools pip
- name: Upgrade test dependencies
run: python -m pip install psutil pytest 'hypothesis[zoneinfo]' qiskit
- name: Install BQSKit
env:
SYSTEM_VERSION_COMPAT: 0
NUMBER_RANDOM_CIRCUITS: 100
run: pip install '.[ext,dev]'
run: pip install .
- name: Run tests
run: pytest
26 changes: 10 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ repos:
args: [--django]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending
- id: check-added-large-files
args: ['--maxkb=8192']
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ['--remove']
- id: no-commit-to-branch
args: [--branch, master]
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
rev: v1.7.5
hooks:
- id: docformatter
args:
Expand All @@ -33,7 +30,7 @@ repos:
- --wrap-summaries=80
- --wrap-descriptions=80
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.1
rev: v2.0.2
hooks:
- id: autopep8
args:
Expand All @@ -42,13 +39,13 @@ repos:
- --ignore=E731
exclude: 'tests/ext.*'
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.10.1
hooks:
- id: pyupgrade
args:
- --py38-plus
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.9.0
rev: v3.10.0
hooks:
- id: reorder-python-imports
args:
Expand All @@ -57,32 +54,29 @@ repos:
- --py37-plus
exclude: 'tests/ext.*'
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.4.0
rev: v3.0.1
hooks:
- id: add-trailing-comma
args:
- --py36-plus
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.2.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
rev: v2.2.0
hooks:
- id: autoflake
args:
- --in-place
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.5.0
hooks:
- id: mypy
exclude: tests/qis/test_pauli.py
additional_dependencies: ["numpy>=1.21"]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
args:
- --ignore=E741,E241,E226,F405,F403,W503,F901,E731,TYP006
- --ignore=E741,W503,F901,E731,TYP006,TYP001,TYP002
- --max-line-length=80
- --per-file-ignores=bqskit/runtime/worker.py:E402
additional_dependencies: [flake8-typing-imports==1.13.0]
68 changes: 36 additions & 32 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,36 @@

The Berkeley Quantum Synthesis Toolkit is an open-source superoptimizing
compiler committed to making synthesis easy to use and quick to extend.
As such, it is one our main goals to allow everyone to join our community
As such, one of our primary goals is to allow everyone to join our community
and contribute to the BQSKit project. This page describes how to do just
that.

> If you encounter any issues or need any help, please don't hesitate to reach
> out through a GitHub Issue.
## Getting Started

You will probably want to familiarize yourself with the codebase and
documentation, and set up a development environment before making any
contribution. We will welcome all contributions, but we envision there
will be two common types of contributions to BQSKit: ones extending the
IR with new gates, and ones implementing algorithms in a compiler pass.
If you plan to make a similar contribution, you can find documentation
for the IR and supported algorithms under the API Reference section.
Before contributing, you will probably want to familiarize yourself with
the codebase and documentation and set up a development environment. We
welcome all contributions, but we envision two common contributions to
BQSKit: extending the IR with new gates and implementing or altering
algorithms in a compiler pass. If you plan to make a similar contribution,
you can find documentation for the IR and supported algorithms under the
API Reference section.

### Development Environment

You will want to install BQSKit from source, by cloning the repository from github:
You will want to install BQSKit from the source by cloning the repository
from GitHub:

```
git clone https://github.com/BQSKit/BQSKit.git
cd bqskit
pip install -e '.[dev]'
```

You can run `tox` to install all development packages, setup virtual
environments for all supported versions of python, perform all stylistic
You can run `tox` to install all development packages, set up virtual
environments for all supported Python versions, perform all stylistic
checks and modifications, and run the test suite.

## Guidelines
Expand All @@ -36,51 +40,51 @@ Please follow the below short list of guidelines when contributing.

### Pull Request Checklist

1. Please ensure pre-commit was run successfully on your branch. This will
ensure the code style of the project is matched in addition to other checks.
This can be done, by executing `tox` locally before pushing. Note that `tox`
or `pre-commit` will make stylistic modifications to your code.
1. Please ensure the pre-commit checks ran successfully on your branch. These
ensure your changes match the project's code style and perform other critical
analyses. To do this, either execute `pre-commit run --all-files` or `tox`
locally before pushing. Note that `tox` or `pre-commit` will make stylistic
modifications directly to your code.

2. Please ensure that all tests are still passing, which can also be done
2. Please ensure all tests are still passing, which can also be done
with `tox`. Also, if appropriate, please add tests to ensure your change
behaves correctly. See the testing section below for more information.

3. Please ensure that any added package, module, class, attribute, function,
or method has an appropriate google-style docstring. These are used by the
documentation engine to produce api references. Additionally, if you have
created a user-facing class, please add those to the autosummary list in
top level package's `__init__.py`, e.g. `bqskit.ir.__init__`.
or method has an appropriate Google-style docstring. The documentation
engine uses these to produce API references. If you have created a
user-facing class, please add those to the autosummary list in the top-level
package's `__init__.py`, e.g., `bqskit.ir.__init__`.

4. BQSKit is a type-annotated python package, which helps catch some bugs
4. BQSKit is a type-annotated Python package, which helps catch some bugs
early with static code analysis tools like [Mypy](http://mypy-lang.org/).
You can see [PEP 484: Type Annotations](https://www.python.org/dev/peps/pep-0484/)
for more information. Please do annotate your contribution with types.
Sometimes this can be tricky, if you need help, please don't hesitate to ask.

for more information. Please annotate your contribution with types.
Sometimes, this can be tricky. If you need help, please don't hesitate to ask.

## Testing

After any changes, it is important to ensure that all the previous tests
After any changes, it is essential to ensure that all the previous tests
still pass on all supported versions of Python. This can be done by running
the `tox` command after install it. Additionally, you will want to write
the `tox` command after installing it. Additionally, you will want to write
tests for any appropriate changes. Our test suite resides in the `tests`
folder and uses a combination of `pytest` and `hypothesis`.

- [PyTest](https://docs.pytest.org/en/6.2.x/)
- [Hypothesis](https://hypothesis.readthedocs.io/en/latest/)

Pytest is a framework for writing and running tests. Any python method or
function that starts with `test_` that resides in the `tests` folder will
be collected and run as part of the test suite. You can write normal python
Pytest is a framework for writing and running tests. Any Python method or
function that starts with `test_` in the `tests` folder will
be collected and run as part of the test suite. You can write normal Python
code and use assert statements in your tests. Although you can place your
test anywhere in the `tests` folder, please do follow the same structure that is
there already. The `tests` directory structure closely follows the `bqskit`
test anywhere in the `tests` folder, please follow the same structure there
already. The `tests` directory structure closely follows the `bqskit`
package structure, which makes it easy to find tests. If you are not familiar
with Pytest, we recommend you read a few of the tests included already and
ask any questions you may have.

Hypothesis is a powerful library that will intelligently generate inputs
to tests. Any test that starts with a `given` decorator is using Hypothesis
to tests. Any test that starts with a `given` decorator uses Hypothesis
to generate inputs according to some strategy. BQSKit has several custom
strategies that can be found in `bqskit.utils.test` module. We recommend
using `hypothesis` to test complex functionality that may have corner cases.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Berkeley Quantum Synthesis Toolkit (BQSKit)

The Berkeley Quantum Synthesis Toolkit (BQSKit) \[bis • kit\] is a powerful and portable quantum compiler framework.
It can be used with ease to compile quantum programs to efficient physical circuits for any QPU.
The Berkeley Quantum Synthesis Toolkit (BQSKit) \[bis • kit\] is a powerful
and portable quantum compiler framework. It can be used with ease to compile
quantum programs to efficient physical circuits for any QPU.

## Installation

Expand All @@ -13,18 +14,12 @@ and as such, pip can easily install it:
pip install bqskit
```

An optional extension includes pre-built support for many quantum devices and modules for working with other quantum frameworks. Pip can install this extension by appending `[ext]` to the previous command:

```sh
pip install 'bqskit[ext]'
```

**Note**: If you are using a device with Apple Silicon, you will need to install BQSKit with Anaconda. See the [instructions here](https://github.com/BQSKit/bqskit-tutorial/blob/master/README.md) for more information. We are currently in the process of implementing native ARM support. When that is ready, we will update this note.


## Basic Usage

A standard workflow utilizing BQSKit consists of loading a program into the framework, modeling the target QPU, compiling the program, and exporting the resulting circuit. The below example uses BQSKit to optimize an input circuit provided by a qasm file:
A standard BQSKit workflow loads a program into the framework, models the
target QPU, compiles the program, and exports the resulting circuit. The
below example uses BQSKit to optimize an input circuit provided by a qasm
file:

```python
from bqskit import compile, Circuit
Expand All @@ -39,19 +34,24 @@ compiled_circuit = compile(circuit)
compiled_circuit.save("output.qasm")
```

To learn more about BQSKit, follow the [tutorial series](https://github.com/BQSKit/bqskit-tutorial/blob/master/1_comping_with_bqskit.ipynb) or refer to the [documentation](https://bqskit.readthedocs.io/en/latest/).
To learn more about BQSKit, follow the
[tutorial series](https://github.com/BQSKit/bqskit-tutorial/) or refer to
the [documentation](https://bqskit.readthedocs.io/en/latest/).

## How to Cite

You can use the [software disclosure](https://www.osti.gov/biblio/1785933) to cite the BQSKit package.
You can use the [software disclosure](https://www.osti.gov/biblio/1785933)
to cite the BQSKit package.

Additionally, if you used or extended a specific algorithm, you can cite that individually. BQSKit passes will include a relevant reference in their documentation.
Additionally, if you used or extended a specific algorithm, you should cite
that individually. BQSKit passes will include a relevant reference in
their documentation.

## License

The software in this repository is licensed under a **BSD free software license**
and can be used in source or binary form for any purpose as long as the simple
licensing requirements are followed. See the
The software in this repository is licensed under a **BSD free software
license** and can be used in source or binary form for any purpose as long
as the simple licensing requirements are followed. See the
**[LICENSE](https://github.com/BQSKit/bqskit/blob/master/LICENSE)** file
for more information.

Expand All @@ -64,12 +64,12 @@ approvals from the U.S. Dept. of Energy) and Massachusetts
Institute of Technology (MIT). All rights reserved.

If you have questions about your rights to use or distribute this software,
please contact Berkeley Lab's Intellectual Property Office at
IPO@lbl.gov.
please contact Berkeley Lab's Intellectual Property Office at IPO@lbl.gov.

NOTICE. This Software was developed under funding from the U.S. Department
of Energy and the U.S. Government consequently retains certain rights. As
such, the U.S. Government has been granted for itself and others acting on
its behalf a paid-up, nonexclusive, irrevocable, worldwide license in the
Software to reproduce, distribute copies to the public, prepare derivative
works, and perform publicly and display publicly, and to permit others to do so.
works, and perform publicly and display publicly, and to permit others to
do so.
Loading

0 comments on commit dc3fc7e

Please sign in to comment.