GithubHelp home page GithubHelp logo

qulacs-osaka / qulacs-osaka Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 6.0 3.45 MB

Development branch of qulacs at Osaka Univ

License: MIT License

CMake 3.09% C++ 80.01% Dockerfile 0.19% Python 5.31% Shell 0.08% Batchfile 0.14% C 1.36% Cuda 9.81%

qulacs-osaka's Introduction

Qulacs-Osaka

Ubuntu & Windows CI Downloads

Qulacs-Osaka is a python/C++ library for fast simulation of large, noisy, or parametric quantum circuits. This project is (implicitly) forked from Qulacs and developed at Osaka University and NTT.

Qulacs-Osaka is licensed under the MIT license.

Relation to Qulacs

The commits in Qulacs are merged into Qulacs-Osaka up to the pull request corresponding to the commit 987474b31a6e60eba116d2e40ab538dcf8086038 (link to the corresponding commit in Qulacs and in Qulacs-Osaka). After that commit, this project is developed independently from Qulacs and has many new features that have not been available in Qulacs.

Note Qulacs-Osaka/qulacs-osaka will be integrated into the qulacs/qulacs. For more details, please refer to Information section.

Features

  • Fast quantum circuit simulation with parallelized C/C++ backend
  • Noisy quantum gate for simulation of NISQ devices
  • Parametric quantum gates for variational methods
  • Circuit compression for fast simulation
  • GPU support for fast simulation
  • Many utility functions for research

Performance

  • Compared following libraries on March, 2020
Package Version
Qulacs GPU 0.1.9
Cirq 0.6.0
Qiskit Aer 0.3.4
ProjectQ 0.4.2
qHiPSTER latest master branch
Python interface of QuEST (PyQuest-cffi) 3.0.0
qsim latest master branch

Test environment:

  • Azure NC6s_v3 (6vcpu / Mem112GiB)
    • Intel(R) Xeon(R) CPU E5-2690 v4 @ 2.60GHz
    • Tesla V100 PCIE (driver 440.33.01)

What is Benchmarked

For each qubit number N:

  • Apply simultaneous random single-qubit Pauli-X rotation

and then repeat:

  • Apply CNOT(i,(i+1)%N) for all i in [0..N-1]
  • Apply simultaneous random single-qubit Pauli-X rotation

for N times.

Note

  • Execution time include time for creating quantum circuit
  • Benchmark was done with float64 precision (qsim was done with float32)

Single thread benchmark

single thread benchmark

Multi thread / GPU benchmark

multi thread benchmark

This benchmark was done with majour quantum circuit simulators with python interface.
Yao is quantum circuit simulator using Julia that is as fast as Qulacs.
Benchmark inculde Yao can be found here.

Requirements

  • C++ compiler (gcc or VisualStudio)
    • gcc/g++ >= 7.0.0 (checked in Linux, MacOS, cygwin, MinGW, and WSL)
    • Microsoft VisualStudio C++ 2015 or later
  • Boost >= 1.71.0 (Minimum version tested in CI)
  • Python >= 3.7
  • CMake >= 3.0
  • git
  • (option) CUDA >= 8.0
  • (option) AVX2 support

If your system supports AVX2 instructions, SIMD optimization is automatically enabled. If you want to enable GPU simulator, install qulacs through qulacs-gpu package or build from source. Note that qulacs-gpu includes CPU simulator. You don't need to install both.

Qulacs is tested on the following systems.

  • Ubuntu 20.04
  • macOS Big Sur 11
  • Windows Server 2019

Install via pip

You can install the Python package via pip.

pip install qulacs-osaka

Install from Source

If you encounter some troubles, see troubleshooting.

Install Python library from source

Install (Multi-thread without GPU)

python setup.py install

Install (Multi-thread with GPU. CUDA is required)

USE_GPU=Yes python setup.py install

Uninstall

pip uninstall qulacs

Build C++ library

GCC

git clone https://github.com/Qulacs-Osaka/qulacs-osaka.git
cd qulacs-osaka
./script/build_gcc.sh

When you want to build with GPU, use build_gcc_with_gpu.sh.

MSVC

git clone https://github.com/Qulacs-Osaka/qulacs-osaka.git
cd qulacs-osaka
./script/build_msvc_2017.bat

When you want to build with GPU, use build_msvc_2017_with_gpu.bat. If you use MSVC2015, replace "2017" in file names to "2015".

Tutorial and API document

See the following documents for more detail.

Sample code

Python

from qulacs import Observable, QuantumCircuit, QuantumState
from qulacs.gate import Y,CNOT,merge

state = QuantumState(3)
state.set_Haar_random_state()

circuit = QuantumCircuit(3)
circuit.add_X_gate(0)
merged_gate = merge(CNOT(0,1),Y(1))
circuit.add_gate(merged_gate)
circuit.add_RX_gate(1,0.5)
circuit.update_quantum_state(state)

observable = Observable(3)
observable.add_operator(2.0, "X 2 Y 1 Z 0")
observable.add_operator(-3.0, "Z 2")
value = observable.get_expectation_value(state)
print(value)

If you want to run it on GPU, install GPU-enabled qulacs and replace QuantumState in the above codes to QuantumStateGpu.

C++

#include <iostream>
#include <cppsim/state.hpp>
#include <cppsim/circuit.hpp>
#include <cppsim/observable.hpp>
#include <cppsim/gate_factory.hpp>
#include <cppsim/gate_merge.hpp>

int main(){
    QuantumState state(3);
    state.set_Haar_random_state();

    QuantumCircuit circuit(3);
    circuit.add_X_gate(0);
    auto merged_gate = gate::merge(gate::CNOT(0,1),gate::Y(1));
    circuit.add_gate(merged_gate);
    circuit.add_RX_gate(1,0.5);
    circuit.update_quantum_state(&state);

    Observable observable(3);
    observable.add_operator(2.0, "X 2 Y 1 Z 0");
    observable.add_operator(-3.0, "Z 2");
    auto value = observable.get_expectation_value(&state);
    std::cout << value << std::endl;
    return 0;
}

Build command for g++:

g++ -O2 -I ./include -L ./lib main.cpp -fopenmp -lcppsim_static -lcsim_static

If you want to run it on GPU, include cppsim/state_gpu.hpp and replace QuantumState with QuantumStateGpu.

How to cite

Please cite this arXiv paper: Qulacs: a fast and versatile quantum circuit simulator for research purpose

Information

Experimental new features of Qulacs that have been developed in the Osaka University repository Qulacs-Osaka/qulacs-osaka will be integrated into the original Qulacs. The following new features will be added!!!

Integration date

Scheduled around August 2022.

New features

The main new features are as follows

  • Providing type hint files for Python
    • Configure tools such as mypy to take full advantage of type hint information.
    • mypy can detect the use of incorrect argument types in the qulacs API.
  • Sending exceptions with detailed information
    • Makes it easier to understand the cause of the error.
    • (For Jupyter Notebook users) kernel is less likely to crash if incorrect input is given.
  • Added backprop (gradient calculation by error back propagation method) to ParametricQuantumCircuit
    • It is faster than calculating gradients one by one.
  • Gradient Calculator

Scope of impact

The existing functionality has not been changed, so the existing code using Qulacs will continue to work as is. However, since the implementation language of csim has been changed from C to C++, changes may be necessary if you have been using direct calls to csim. Due to the C++ change, all complex numbers are now handled by std::complex.

Add dependency libraries

This integration adds boost as a dependency library. There will be some changes in the installation procedure.

qulacs-osaka's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

qulacs-osaka's Issues

[Bug] :bomb: ubuntu CI sometimes fails to run test

概要

https://github.com/Qulacs-Osaka/qulacs-osaka/actions/runs/1480221659
このように、ubuntu CIがテストを実行できず落ちることがあります。

対策

@kodack64 と対策を話した結果、CI環境ではマシンのCPUアーキテクチャが異なるために失敗するのではないかという結論に至りました。
そこで、CI時にはコンパイルターゲットをhaswellアーキテクチャで固定します。

state.get_zero_state()の削除

based on PR #189

WA_TLE
他のと機能が丸被りしている技術的負債を消した

この関数はすべての値が0になる状態ベクトル(≠ 状態ベクトル|00...0>)を返します。この挙動は名前からわかりにくいので関数を削除します。

[Bug] :bug: Illegal Instruction error on Ubuntu CI

概要

qulacs-osakaのGitHub Actionsでのテスト中にIllegal instructionというエラーが表示されて失敗することがあります。
これは確率的な挙動であり、ある程度高い確率で再現することを確認しています。
発生例

チェック方法

各テストについて3回実行しエラー箇所を特定します。

  • csim
  • cppsim
  • cppsim_experimental
  • vqcsim

[Feat] Remove wheel-build

概要

wheel-buildが激重なので一旦削除して、devブランチのマージ時にのみ回るようにしたい。

[CI] Speed up CI

Ubuntu の self-hosted-runner が特に遅いため高速化します.

現状,

  1. 同じビルドを3回行っている.1回2分未満だが直列に実行されるため5~6分かかってしまう
  2. テストの実行に1時間近くかかっている.他の環境ではかかっても数分程度(計測はしていない)なので,異常に遅い

という問題があります.それぞれ以下の issue で対応します.

dev-container を用意する

scikit-qulacs と同様に dev-container を用意します.
こっちは C++ と Python を用意しないといけないのでちょっと面倒そうです.
個人的には C++ の開発環境がインストールされた dev-container 用のイメージに Python を入れるのがよさそうだと思っています.

Fix shadowing in NoiseSimulator

Yasunari Suzuki:
@kotamanegi
昨日warningの箇所の整理とかをしていたのですが、
https://github.com/Qulacs-Osaka/qulacs-osaka/blob/dev/src/cppsim_experimental/noisesimulator.cpp#L34
で変数iが二重に定義されているのは正しく動作する状態でしょうか?(多分しない気がする)
もし可能であれば直しておいてもらうのと、現状出ているPRでもし対応している場合、次の勤務の際にconflictを避けるためマ ージしておいてもらっていいでしょうか?現状cppsimとcppsim_experimentalで二重にnoisesimulatorを管理していると思いますが、これが大変な場合はcppsim_experimentalには後で移植する形でも一応問題ないです。

[Bug] wheel build CI fails on Python 3.6

概要

devブランチのwheel build CI がPython3.6で失敗しています。
この失敗の原因はpillowライブラリがインストールできないからだと考えられます。

詳細

cp36-manylinux_x86_64 wheel のtest wheelステップで落ちており、Qulacsの内容には問題がないと考えられます。
pillowからは

The headers or library files could not be found for jpeg,
    a required dependency when compiling Pillow from source.

というエラーが出ており、ソースビルドが始まってしまっていることがわかります。

エラーが混入したのは#147ですが、実際にはpillowライブラリの方がバグを持っている可能性が有るので調査が必要です。

[CI] build_gcc.sh never run in gcc8-build

strategy:
matrix:
python-version: ["3.7.5"]
os: ["docker-runner"]

- name: Install qulacs for Ubuntu
run: ./script/build_gcc.sh
if: ${{ contains(matrix.os, 'ubuntu') }}

- name: Test in Ubuntu
run: |
cd ./build
make test
make pythontest
if: ${{ contains(matrix.os, 'ubuntu') }}

gcc8-build内のmatrix.osが docker-runner であるので、ビルドやテストが行われない状態になっています。

operatorの高速化

Observableにオーバーロードした演算子が遅いので高速化する

Remove build in checking format

clang-format を実行する CI ではビルドをする必要はないのでビルドをするステップは除去していいと思います.

VQE documentation return value cost function change

In the documentation, subchapter "Define VQE cost function" (http://docs.qulacs.org/en/latest/apply/6.2_vqe.html#Define-VQE-cost-function) the return value of the cost function should be np.real(qulacs_hamiltonian.get_expectation_value(state))
instead of qulacs_hamiltonian.get_expectation_value(state).
This is because of the scipy.optimize.minimize function in http://docs.qulacs.org/en/latest/apply/6.2_vqe.html#Run-VQE, which expects a cost function returning a float number.

[CI] nvcc test does not run

nvcc でのテストがスキップされています.
テストを行うかの判定を matrix.osubuntu を含むかどうかで行っていますが,実際には matrix.os は定義されていないためスキップされます.
定義する意味もないので matrix を消してしまってもいいと思います

nvcc-gcc8-GPUbuild:
name: nvcc + gcc8 build
strategy:
matrix:
python-version: ["3.7.5"]

- name: Test in Ubuntu
run: |
cd ./build
make test -j
make pythontest -j
if: ${{ contains(matrix.os, 'ubuntu') }}

Building cp310-manylinux_x86_64 wheel でfailする

現象

PR #105 のCIで、

  • Ubuntu & Windows CI / Python wheel build (3.7.5, ubuntu-self-hosted) (push)
    • Python wheel build (3.7.5, ubuntu-self-hosted)
    • Run cibuildwheel
    • Building cp310-manylinux_x86_64 wheel
    • pip install numpy scipy openfermion

でfailしている。

2021-08-20T10:19:24.5721583Z     + pip install numpy scipy openfermion
2021-08-20T10:22:30.9335760Z     ERROR: Command errored out with exit status 1:
2021-08-20T10:22:30.9338554Z      command: /tmp/tmp.G6kDQp2bEC/venv/bin/python /tmp/tmp.G6kDQp2bEC/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpq0rspzxv
2021-08-20T10:22:30.9341037Z          cwd: /tmp/pip-install-27oarnbz/scipy_1faa84663d224ca682bca876db764906
2021-08-20T10:22:30.9342137Z     Complete output (144 lines):
2021-08-20T10:22:30.9348204Z     setup.py:461: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /tmp/pip-modern-metadata-8gwycyhf'), proceeding with generating Cython sources and expanding templates
2021-08-20T10:22:30.9350406Z       warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
2021-08-20T10:22:30.9351079Z     Running from SciPy source directory.
2021-08-20T10:22:30.9351511Z     lapack_opt_info:
2021-08-20T10:22:30.9351864Z     lapack_mkl_info:
2021-08-20T10:22:30.9352270Z     customize UnixCCompiler
2021-08-20T10:22:30.9353181Z       libraries mkl_rt not found in ['/tmp/tmp.G6kDQp2bEC/venv/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
2021-08-20T10:22:30.9353839Z       NOT AVAILABLE
2021-08-20T10:22:30.9354137Z     
2021-08-20T10:22:30.9354466Z     openblas_lapack_info:
2021-08-20T10:22:30.9355355Z       libraries openblas not found in ['/tmp/tmp.G6kDQp2bEC/venv/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
2021-08-20T10:22:30.9356124Z       NOT AVAILABLE
2021-08-20T10:22:30.9356428Z     
2021-08-20T10:22:30.9356759Z     openblas_clapack_info:
2021-08-20T10:22:30.9357713Z       libraries openblas,lapack not found in ['/tmp/tmp.G6kDQp2bEC/venv/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
2021-08-20T10:22:30.9358440Z       NOT AVAILABLE
2021-08-20T10:22:30.9358737Z     
2021-08-20T10:22:30.9359019Z     flame_info:
2021-08-20T10:22:30.9359839Z       libraries flame not found in ['/tmp/tmp.G6kDQp2bEC/venv/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
2021-08-20T10:22:30.9360496Z       NOT AVAILABLE
2021-08-20T10:22:30.9360792Z     
2021-08-20T10:22:30.9361107Z     accelerate_info:
2021-08-20T10:22:30.9361467Z       NOT AVAILABLE
2021-08-20T10:22:30.9361766Z     
2021-08-20T10:22:30.9362081Z     atlas_3_10_threads_info:
2021-08-20T10:22:30.9362470Z     Setting PTATLAS=ATLAS
2021-08-20T10:22:30.9363035Z       libraries lapack_atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9363757Z       libraries tatlas,tatlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9364416Z       libraries lapack_atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9365190Z       libraries tatlas,tatlas not found in /usr/local/lib64
2021-08-20T10:22:30.9365785Z       libraries lapack_atlas not found in /usr/local/lib
2021-08-20T10:22:30.9366371Z       libraries tatlas,tatlas not found in /usr/local/lib
2021-08-20T10:22:30.9366960Z       libraries lapack_atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9367545Z       libraries tatlas,tatlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9368121Z       libraries lapack_atlas not found in /usr/lib64
2021-08-20T10:22:30.9368688Z       libraries tatlas,tatlas not found in /usr/lib64
2021-08-20T10:22:30.9369245Z       libraries lapack_atlas not found in /usr/lib
2021-08-20T10:22:30.9369788Z       libraries tatlas,tatlas not found in /usr/lib
2021-08-20T10:22:30.9370352Z       libraries lapack_atlas not found in /usr/lib/
2021-08-20T10:22:30.9370902Z       libraries tatlas,tatlas not found in /usr/lib/
2021-08-20T10:22:30.9371733Z     <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
2021-08-20T10:22:30.9372283Z       NOT AVAILABLE
2021-08-20T10:22:30.9372585Z     
2021-08-20T10:22:30.9372871Z     atlas_3_10_info:
2021-08-20T10:22:30.9373388Z       libraries lapack_atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9374115Z       libraries satlas,satlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9374783Z       libraries lapack_atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9375381Z       libraries satlas,satlas not found in /usr/local/lib64
2021-08-20T10:22:30.9376075Z       libraries lapack_atlas not found in /usr/local/lib
2021-08-20T10:22:30.9376685Z       libraries satlas,satlas not found in /usr/local/lib
2021-08-20T10:22:30.9377276Z       libraries lapack_atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9377875Z       libraries satlas,satlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9378450Z       libraries lapack_atlas not found in /usr/lib64
2021-08-20T10:22:30.9379004Z       libraries satlas,satlas not found in /usr/lib64
2021-08-20T10:22:30.9379566Z       libraries lapack_atlas not found in /usr/lib
2021-08-20T10:22:30.9380119Z       libraries satlas,satlas not found in /usr/lib
2021-08-20T10:22:30.9380671Z       libraries lapack_atlas not found in /usr/lib/
2021-08-20T10:22:30.9381226Z       libraries satlas,satlas not found in /usr/lib/
2021-08-20T10:22:30.9382008Z     <class 'numpy.distutils.system_info.atlas_3_10_info'>
2021-08-20T10:22:30.9382527Z       NOT AVAILABLE
2021-08-20T10:22:30.9382827Z     
2021-08-20T10:22:30.9383137Z     atlas_threads_info:
2021-08-20T10:22:30.9383538Z     Setting PTATLAS=ATLAS
2021-08-20T10:22:30.9384105Z       libraries lapack_atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9384909Z       libraries ptf77blas,ptcblas,atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9385651Z       libraries lapack_atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9386328Z       libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9386995Z       libraries lapack_atlas not found in /usr/local/lib
2021-08-20T10:22:30.9387661Z       libraries ptf77blas,ptcblas,atlas not found in /usr/local/lib
2021-08-20T10:22:30.9388330Z       libraries lapack_atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9388999Z       libraries ptf77blas,ptcblas,atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9389658Z       libraries lapack_atlas not found in /usr/lib64
2021-08-20T10:22:30.9390427Z       libraries ptf77blas,ptcblas,atlas not found in /usr/lib64
2021-08-20T10:22:30.9391042Z       libraries lapack_atlas not found in /usr/lib
2021-08-20T10:22:30.9391656Z       libraries ptf77blas,ptcblas,atlas not found in /usr/lib
2021-08-20T10:22:30.9392271Z       libraries lapack_atlas not found in /usr/lib/
2021-08-20T10:22:30.9392882Z       libraries ptf77blas,ptcblas,atlas not found in /usr/lib/
2021-08-20T10:22:30.9393736Z     <class 'numpy.distutils.system_info.atlas_threads_info'>
2021-08-20T10:22:30.9394270Z       NOT AVAILABLE
2021-08-20T10:22:30.9394656Z     
2021-08-20T10:22:30.9394934Z     atlas_info:
2021-08-20T10:22:30.9395433Z       libraries lapack_atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9396570Z       libraries f77blas,cblas,atlas not found in /tmp/tmp.G6kDQp2bEC/venv/lib
2021-08-20T10:22:30.9397250Z       libraries lapack_atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9397865Z       libraries f77blas,cblas,atlas not found in /usr/local/lib64
2021-08-20T10:22:30.9398483Z       libraries lapack_atlas not found in /usr/local/lib
2021-08-20T10:22:30.9399091Z       libraries f77blas,cblas,atlas not found in /usr/local/lib
2021-08-20T10:22:30.9399692Z       libraries lapack_atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9400302Z       libraries f77blas,cblas,atlas not found in /usr/lib64/sse2
2021-08-20T10:22:30.9400896Z       libraries lapack_atlas not found in /usr/lib64
2021-08-20T10:22:30.9401467Z       libraries f77blas,cblas,atlas not found in /usr/lib64
2021-08-20T10:22:30.9402038Z       libraries lapack_atlas not found in /usr/lib
2021-08-20T10:22:30.9402606Z       libraries f77blas,cblas,atlas not found in /usr/lib
2021-08-20T10:22:30.9403169Z       libraries lapack_atlas not found in /usr/lib/
2021-08-20T10:22:30.9403744Z       libraries f77blas,cblas,atlas not found in /usr/lib/
2021-08-20T10:22:30.9404543Z     <class 'numpy.distutils.system_info.atlas_info'>
2021-08-20T10:22:30.9405042Z       NOT AVAILABLE
2021-08-20T10:22:30.9405332Z     
2021-08-20T10:22:30.9405612Z     lapack_info:
2021-08-20T10:22:30.9406525Z       libraries lapack not found in ['/tmp/tmp.G6kDQp2bEC/venv/lib', '/usr/local/lib64', '/usr/local/lib', '/usr/lib64', '/usr/lib', '/usr/lib/']
2021-08-20T10:22:30.9407196Z       NOT AVAILABLE
2021-08-20T10:22:30.9407484Z     
2021-08-20T10:22:30.9408381Z     /tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/numpy/distutils/system_info.py:1858: UserWarning:
2021-08-20T10:22:30.9409395Z         Lapack (http://www.netlib.org/lapack/) libraries not found.
2021-08-20T10:22:30.9410146Z         Directories to search for the libraries can be specified in the
2021-08-20T10:22:30.9410828Z         numpy/distutils/site.cfg file (section [lapack]) or by setting
2021-08-20T10:22:30.9411412Z         the LAPACK environment variable.
2021-08-20T10:22:30.9412053Z       return getattr(self, '_calc_info_{}'.format(name))()
2021-08-20T10:22:30.9412497Z     lapack_src_info:
2021-08-20T10:22:30.9412839Z       NOT AVAILABLE
2021-08-20T10:22:30.9413127Z     
2021-08-20T10:22:30.9414002Z     /tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/numpy/distutils/system_info.py:1858: UserWarning:
2021-08-20T10:22:30.9414993Z         Lapack (http://www.netlib.org/lapack/) sources not found.
2021-08-20T10:22:30.9415721Z         Directories to search for the sources can be specified in the
2021-08-20T10:22:30.9416404Z         numpy/distutils/site.cfg file (section [lapack_src]) or by setting
2021-08-20T10:22:30.9417012Z         the LAPACK_SRC environment variable.
2021-08-20T10:22:30.9417667Z       return getattr(self, '_calc_info_{}'.format(name))()
2021-08-20T10:22:30.9418105Z       NOT AVAILABLE
2021-08-20T10:22:30.9418392Z     
2021-08-20T10:22:30.9418745Z     Traceback (most recent call last):
2021-08-20T10:22:30.9420445Z       File "/tmp/tmp.G6kDQp2bEC/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
2021-08-20T10:22:30.9421204Z         main()
2021-08-20T10:22:30.9422189Z       File "/tmp/tmp.G6kDQp2bEC/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
2021-08-20T10:22:30.9423150Z         json_out['return_val'] = hook(**hook_input['kwargs'])
2021-08-20T10:22:30.9424325Z       File "/tmp/tmp.G6kDQp2bEC/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 151, in prepare_metadata_for_build_wheel
2021-08-20T10:22:30.9425290Z         return hook(metadata_directory, config_settings)
2021-08-20T10:22:30.9426524Z       File "/tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 161, in prepare_metadata_for_build_wheel
2021-08-20T10:22:30.9427527Z         self.run_setup()
2021-08-20T10:22:30.9428540Z       File "/tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 253, in run_setup
2021-08-20T10:22:30.9429443Z         super(_BuildMetaLegacyBackend,
2021-08-20T10:22:30.9430544Z       File "/tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 145, in run_setup
2021-08-20T10:22:30.9431526Z         exec(compile(code, __file__, 'exec'), locals())
2021-08-20T10:22:30.9432067Z       File "setup.py", line 588, in <module>
2021-08-20T10:22:30.9432480Z         setup_package()
2021-08-20T10:22:30.9432955Z       File "setup.py", line 584, in setup_package
2021-08-20T10:22:30.9433401Z         setup(**metadata)
2021-08-20T10:22:30.9434367Z       File "/tmp/pip-build-env-d2pxf9bw/overlay/lib/python3.10/site-packages/numpy/distutils/core.py", line 135, in setup
2021-08-20T10:22:30.9435169Z         config = configuration()
2021-08-20T10:22:30.9435689Z       File "setup.py", line 499, in configuration
2021-08-20T10:22:30.9436604Z         raise NotFoundError(msg)
2021-08-20T10:22:30.9437294Z     numpy.distutils.system_info.NotFoundError: No BLAS/LAPACK libraries found.
2021-08-20T10:22:30.9438135Z     To build Scipy from sources, BLAS & LAPACK libraries need to be installed.
2021-08-20T10:22:30.9438849Z     See site.cfg.example in the Scipy source directory and
2021-08-20T10:22:30.9439776Z     https://docs.scipy.org/doc/scipy/reference/building/index.html for details.
2021-08-20T10:22:30.9440664Z     ----------------------------------------
2021-08-20T10:22:30.9443938Z WARNING: Discarding https://files.pythonhosted.org/packages/26/68/84dbe18583e79e56e4cee8d00232a8dd7d4ae33bc3acf3be1c347991848f/scipy-1.6.1.tar.gz#sha256=c4fceb864890b6168e79b0e714c585dbe2fd4222768ee90bc1aa0f8218691b11 (from https://pypi.org/simple/scipy/) (requires-python:>=3.7). Command errored out with exit status 1: /tmp/tmp.G6kDQp2bEC/venv/bin/python /tmp/tmp.G6kDQp2bEC/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpq0rspzxv Check the logs for full command output.

原因

以前のbuildとは、cp310-manylinux_x86_64 wheelが実行されるようになったことが違う。

Python 3.10でのビルドが実行されること自体に問題はないが、まだscipyのPython 3.10 manylinux wheelsが配布されていないことにより、ビルドに失敗している。
Python 3.9まではpip install scipyでwheelが取得出来ていたが、Python 3.10では出来ないので、ソース(scipy-1.6.1.tar.gz)からビルドする必要があるようになっており、ビルドするためのライブラリを要求するようになっている。

2021-08-20T10:22:30.9438135Z     To build Scipy from sources, BLAS & LAPACK libraries need to be installed.

改善方法

Python 3.10でのビルドを一旦待つか、指示に従いBLAS & LAPACK librariesをインストールすれば解決する。

Limit CI trigger

.md や .devcontainer/ の修正は CI に影響しないので,そういったファイルのみが含まれる PR については CI を実行する必要がないです.
paths_ignore で無視するようにします.

Use ccache in wheel build

wheel build でも他の workflow で生成されたキャッシュが使えるはずなので設定します

wheel build の並列化

wheel build を Python のバージョンごとに並列化したいです.可能かどうかはまだ確かめていません.

tutorial_4のミス

value = operator.apply_to_state(state, result)ってあるけど、それではだめだった

apply_to_stateの定義は(self: qulacs_core.Observable, work_state: QuantumStateBase, state_to_be_multiplied: QuantumStateBase, dst_state: QuantumStateBase) -> None

つまりapply_to_state(作業用、state,result )が必要

Change project name

setup.py の project_namequlacs-osaka に変更します.
現在は Qulacs になっていますが,すでに PyPI に存在するため,リリースしようとしても拒否されるはずだからです.

[Feat] serialize observable

目的

このIssueではObservableクラスをCerealでシリアライズ出来るようにすることが目的です。

[CI] Format check does not fail

clang-format でフォーマットを確認するステップで,フォーマットできていないコードがずっとパスしていたことが分かりました.

状況

このステップは以下のようになっていて,echo -n $diff | wc -l が今いるブランチをフォーマットしたことによってできる diff の行数になります.つまりフォーマットができているコードに対して実行すると0になります.これを test で0と比較しているので,1行以上の diff があれば exit code が1となり,ワークフローは失敗するはずです.

- name: Compare diff
run: |
diff=$(git diff)
echo $diff
test $(echo -n $diff | wc -l) -eq 0

実際に手元で dev に対して diff の行数を見ると0より大きく,test の exit code も1になります.しかし CI は落ちていません.

Use GitHub-hosted runner

public 化されれば CI で GitHub-hosted runner を無制限に使えるようになるので,self-hosted runner ではなくこっちを使うようにします.

cibuildwheelの実行時にcp310-manylinux_x86_64をbuildする

現状では、#106 の問題を解決するために、cibuildwheelの実行時にcp310-manylinux_x86_64のbuildをskipするようにしている。

# See https://github.com/Qulacs-Osaka/qulacs-osaka/issues/106
CIBW_SKIP: "cp310-manylinux_x86_64"

Python 3.10向けscipyのwheelが配布されたことが確認できれば、cp310-manylinux_x86_64をbuildするように修正する。

Redundant build on build_gcc.sh and setup.py

build_gcc.sh でビルドしてから setup.py で Python パッケージをビルドすると, .o ファイルなどが再度ビルドされているようです.
まだ不確かなのでしっかり確認する必要があります.

原因としては,これら2つのファイルで cmake に渡している引数が異なる可能性があることが挙げられます.

[Feat] :up: update gcc version 8 -> version 10

概要

現行で使用しているgcc-8には、Intelの11世代以降のCPUがサポートされていないという問題があります。
このような環境下ではコンパイルエラーが出て停止してしまいます。

また、GitHub Actionsのmacos版ではgcc-8がプレインストールから外れ、手動でインストール作業を行わなければならない状況です。

そこで、gcc-10にバージョンアップすることによってこれらの問題を解決します。
gcc-10の選定理由は、

  • ubuntu 20.04でダウンロードできる最新のバージョンである。
  • ubuntu 21.10がgcc-11をサポートしていることを考えると、ubuntu 22.04でも問題が生じないと考えられる。
  • cuda-11.4.1からgcc-11までのサポートになったので、GPUコードの再利用が可能である。
    です。
    gcc-10のデメリットは、
  • gcc-11でサポートされている12世代(alderlake)が現時点ではgcc-10でサポートされていない
    です。

disable activating virtual environment

devcontainer内のターミナルでは自動的にpyenvの仮想環境を使用しようとするが、その必要はない(eval "$(pyenv init -)"を.bashrcに書いていないためどうせ失敗するので無効化する。

参考:https://code.visualstudio.com/docs/python/environments#:~:text=Tip%3A%20To%20prevent%20automatic%20activation%20of%20a%20selected%20environment%2C%20add%20%22python.terminal.activateEnvironment%22%3A%20false%20to%20your%20settings.json%20file%20(it%20can%20be%20placed%20anywhere%20as%20a%20sibling%20to%20the%20existing%20settings)

[CI] Speed up clang-format

Ubuntu の CI のフォーマットのチェックは1分30秒程度かかっていますが,./script/build_gcc.sh の実行にほとんどの時間を使っており,clang-format が動いているのはたったの数秒です.
e.g. https://github.com/Qulacs-Osaka/qulacs-osaka/runs/3844294507?check_suite_focus=true

この実行時間を短縮するには

  • ./script/build_gcc.sh ではなく cmake 単体を実行する
    • cmake の target として clang-format を使用しているため少なくとも1回は cmake を実行する必要がある
    • 手元でも cmake の target としてフォーマットをするため,一貫性のためにこの方法でフォーマットを確認したほうがよさそう
  • ccache でビルド時間を短縮する

という2つの方法があります.ビルドをする必要はまったくないので,個人的には1つ目の方法がいいと考えています.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.