Skip to content

Commit

Permalink
Merge pull request #37 from Fujitsu-UTokyo-QDD/develop
Browse files Browse the repository at this point in the history
QDD v0.2.0
  • Loading branch information
NT-marlowe authored Mar 26, 2024
2 parents 4dbab52 + 985afec commit 387709d
Show file tree
Hide file tree
Showing 46 changed files with 1,887 additions and 3,180 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/publish_to_pypi_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish Python distribution to PyPI

on:
push:
branches:
- 'main'
jobs:
build:
name: Build distribution
runs-on: ubuntu-22.04

strategy:
matrix:
include:
- python-version: '3.8'
python-version-sub: '38'
- python-version: '3.9'
python-version-sub: '39'
- python-version: '3.10'
python-version-sub: '310'

steps:
- uses: actions/checkout@v4

# Build by cibuildwheel
- name: Build wheels
uses: pypa/[email protected]
env:
python-version: ${{ matrix.python-version }}
# Modify as needed, you may need to adjust this line according to your requirements
CIBW_BUILD: 'cp${{ matrix.python-version-sub }}-manylinux_x86_64'
CIBW_BEFORE_BUILD: "cmake . -DPYTHON_EXECUTABLE=/usr/local/bin/python${{ matrix.python-version }} -DCMAKE_BUILD_TYPE=Release && cmake --build . -j"

- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: ./wheelhouse/*.whl


publish-to-pypi:
name: Publish Python distribution to PyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/qdd
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
19 changes: 19 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Contributing Guidelines

This file explains how to contribute to our project.

## Branch Management Rules (tentative)

- We use three types of branches: `main`, `develop`, and `topic`.
- `topic` branches are for specific features or bug fixes.
- Naming convention for `topic` branches:
- Branch for adding a feature: `feature/xxx` (e.g. `feature/add-circuit`)
- Branch for fixing a bug: `bugfix/xxx` (e.g. `bugfix/py-version`)
- Work is done on `topic` branches branched off from `develop`.
- Pull requests from `topic` to `develop` is made.
- When ready to release (e.g., bumping QDD version), pull requests from `develop` to `main` is made.

## QDD Versioning

- Manually Update Git Tag SemVer Based on Commits to `main`.
- After a PR to `main` is merged, create a new tag from the release notes creation page.
19 changes: 19 additions & 0 deletions CONTRIBUTING_ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ブランチ管理規則

このファイルは、このプロジェクトへのコミットの仕方を説明するものです。

## ブランチ管理ルール (暫定)

- 3つの種類のブランチを使用します: `main`, `develop`, `topic`.
- `topic` ブランチは、特定の機能やバグ修正用です。
- `topic` ブランチの命名規則:
- 機能追加ブランチ:`feature/xxx` (e.g. `feature/add-circuit`)
- バグ修正ブランチ:`bugfix/xxx` (e.g. `bugfix/py-version`)
- 作業は、`develop` ブランチから分岐した `topic` ブランチで行います。
- `topic` から `develop` へのプルリクエストを作成してください。
- リリースの準備が整った場合(例: QDDのバージョンを上げる場合)、`develop` から `main` へのプルリクエストを作成してください。

## QDDのバージョニング方法

- `main` へのコミットの内容に応じてGit TagのSemVerを手動で更新します。
- `main` へのPRがマージされた後、release noteの作成画面から新しいタグを作成してください。
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,54 @@ You must prepare the following software.
* cmake (>=3.25)
* You can download the executable from [Official GitHub](https://github.com/Kitware/CMake/releases).
* If you use Ubuntu, [the Kitware repository](https://apt.kitware.com/) is easier to install.
* poetry
* See [the installation manual](https://python-poetry.org/docs/#installing-with-the-official-installer).
* build
* Just install it via pip.

You can build QDD as follows.
```
```sh
$ cmake . -DCMAKE_BUILD_TYPE=Release
$ cmake --build . -j
$ poetry build
$ python3 -m pip install build
$ python3 -m build
```
BUILD_TYPE can be either `Release`, `Debug` or `RelWithDebInfo`.
You can find an installable wheel file in 'dist' directory.

## Instllation
Please move to your working directory and install the wheel file created in the build phase.
```
```sh
$ pip install {QDD_DIR}/dist/qdd-XXX.whl
```

## Usage
QDD works as a Qiskit backend.

```
from qiskit import QuantumCircuit, execute
from qdd import QddBackend, QddProvider
```py
from qiskit import QuantumCircuit
from qiskit.primitives import BackendSampler

from qdd import QddProvider

backend = QddProvider().get_backend()
circ = QuantumCircuit(3)
circ.h(0)
circ.cx(0,1)
circ.measure_all()
qdd_job = execute(circ, backend=backend, shots=1000)
sampler = BackendSampler(backend=backend)
qdd_job = sampler.run(circuits=circ)
print(qdd_job.result())
```

If you need statevector, create the backend as follows.
QDD has its own implementation of the Sampler class
```py
from qdd.qdd_sampler import Sampler
sampler = Sampler()
qdd_job = sampler.run(circuits=circ)
print(qdd_job.result())
```

If you need statevector, create the backend as follows.
```py
backend = QddProvider().get_backend('statevector_simulator')
```

Expand Down
6 changes: 3 additions & 3 deletions README_MPI.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
## MPI
You need to add some options.
```
```sh
$ CC=mpicc CXX=mpicxx Boost_DIR=/usr/lib/x86_64-linux-gnu/cmake cmake -B build -DCMAKE_BUILD_TYPE=Release -DisMPI=ON
$ cmake --build build -j
```

You can run the MPI programs as follows.
```
```sh
$ mpirun -np 4 ./build/test/mpt_test
$ mpirun -np 4 ./build/test/mpi_test_grover 20
```
Currently, python bindings does NOT support MPI.
Currently, python bindings does NOT support MPI.
4 changes: 4 additions & 0 deletions include/dd.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ std::string measureAll(vEdge &rootEdge, const bool collapse,
std::mt19937_64 &mt, double epsilon = 0.001);
char measureOneCollapsing(vEdge &rootEdge, const Qubit index,
std::mt19937_64 &mt, double epsilon = 0.001);
double measureOne(vEdge &rootEdge, const Qubit index,
std::mt19937_64 &mt, double epsilon = 0.001);

std::vector<double> probabilities(const vEdge &rootEdge);

mEdge RX(QubitCount qnum, int target, double angle);

Expand Down
Loading

0 comments on commit 387709d

Please sign in to comment.