kyulacs.jl

Unofficial Julia interface for qulacs.

https://github.com/atelierarith/kyulacs.jl

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.5%) to scientific vocabulary

Keywords

azarashi julia quantum-computing qulacs
Last synced: 6 months ago · JSON representation ·

Repository

Unofficial Julia interface for qulacs.

Basic Info
Statistics
  • Stars: 10
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Topics
azarashi julia quantum-computing qulacs
Created about 4 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

Kyulacs.jl

Build Status Stable Dev

Unofficial Julia interface for qulacs.

Prerequisites

  1. Install Python and qulacs >= 0.5.1, qulacsvis >= 0.3.2 via

console $ pip3 install qulacs qulacsvis

  1. Install Julia. If you're Julian, you can skip this step.

console $ pip3 install jill # A cross-platform installer for Pythonista $ jill install 1.8

After that you're supposed to add ${HOME}/.local/bin to your $PATH environment variable. You'll see the result below:

``console $ which julia $ ~/.local/bin/julia $ julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _ | | | | || | | | (| | | Version 1.8.3 (2022-11-14) / |_'|||_'| | Official https://julialang.org/ release |_/ |

julia> println("Hello") Hello

julia> exit() ```

  1. Install PyCall

``conosle $ julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _ | | | | || | | | (| | | Version 1.8.3 (2022-11-14) / |_'|||_'| | Official https://julialang.org/ release |_/ |

julia> ENV["PYTHON"] = Sys.which("python3") julia> using Pkg; Pkg.add("PyCall") ```

Having trouble with the error messages ImportError: No module named site? Did you install Python via pyenv or asdf? Please re-install or install another Python again with CONFIGURE_OPTS="--enable-shared" option. Namely run one of the following:

$ CONFIGURE_OPTS="--enable-shared" pyenv 3.8.11 $ CONFIGURE_OPTS="--enable-shared" asdf install python 3.8.11

  1. Install Kyulacs.jl

conosle $ git clone https://github.com/AtelierArith/Kyulacs.jl.git $ cd Kyulacs.jl $ julia --project=@. -e 'using Pkg; Pkg.instantiate()' $ julia --project=@. -e 'using Pkg; Pkg.test()'

How to use

Let's assume you've written a Python code which is similar to Python sample code given by qulacs.

```python

examples/readme_example.py

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

state = QuantumState(3) seed = 0 # set random seed state.setHaarrandom_state(seed)

circuit = QuantumCircuit(3) circuit.addXgate(0) mergedgate = merge(CNOT(0, 1), Y(1)) circuit.addgate(mergedgate) circuit.addRXgate(1, 0.5) circuit.updatequantum_state(state)

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

```

You can try this code out of the box even if you are not familiar with quantum computing.

conosle $ cd /path/to/this/repository $ julia --project=@. examples/readme_example.jl

In Julia, we can achieve the same functionality with Kyulacs package.

```julia:readmetestreadme_example.jl

examples/readme_example.jl

using Kyulacs: Observable, QuantumCircuit, QuantumState using Kyulacs.Gate: CNOT, Y, merge

state = QuantumState(3) seed = 0 # set random seed state.setHaarrandom_state(seed)

circuit = QuantumCircuit(3) circuit.addXgate(0) mergedgate = merge(CNOT(0, 1), Y(1)) circuit.addgate(mergedgate) circuit.addRXgate(1, 0.5) circuit.updatequantum_state(state)

observable = Observable(3) observable.addoperator(2.0, "X 2 Y 1 Z 0") observable.addoperator(-3.0, "Z 2") value = observable.getexpectationvalue(state) println(value) ```

Have a try!!!

console $ cd /path/to/this/repository $ julia -e "using InteractiveUtils; versioninfo()" Julia Version 1.7.2 Commit bf53498635 (2022-02-06 15:21 UTC) Platform Info: OS: macOS (x86_64-apple-darwin19.5.0) CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-12.0.1 (ORCJIT, skylake) $ julia --project=@. examples/readme_example.jl

These are pretty much the same thing. In fact, diff tells these are almost same.

```console $ diff readmeexample.py readmeexample.jl 1,3c1,3 < # readme_example.py < from qulacs import Observable, QuantumCircuit, QuantumState

< from qulacs.gate import Y, CNOT, merge

readme_example.jl

using Kyulacs: Observable, QuantumCircuit, QuantumState using Kyulacs.Gate: CNOT, Y, merge 21c21

< print(value)

println(value) ```

Code Design

When you want migrate your code from Python to Julia, the following table may help you:

Python | Julia ------------- | ------------- from qulacs import something | using Kyulacs: something from qulacs.circuit import something | using Kyulacs.Gate: something from qulacs.gate import something | using Kyulacs.Gate: something from qulacs.observable import something | using Kyulacs.ObservableFunctions: something from qulacs.quantum_operator import something | using Kyulacs.QuantumOperator: something from qulacs.state import something | using Kyulacs.State: something from qulacsvis.visualization import something | using Kyulacs.Vis: something

If you feel using Kyulacs.ObservableFunctions is too exaggerated. Please send your feedback/idea to our issue tracker.

GPU API

using Kyulacs.GPU will export StateVectorGpu and QuantumStateGpu that wraps qulacs.StateVectorGpu and qulacs.QuantumStateGpu respectively.

Visualization

Kyulacs.jl also supports qulacsvis integration. The statement using Kyulacs.Vis allows us to use Python API under qulacsvis.visualization. Consider the following Julia code:

```julia:readmetestcircuit_drawer.jl using Kyulacs: ParametricQuantumCircuit

exports circuit_drawer

using Kyulacs.Vis

nqubits = 2 circuit = ParametricQuantumCircuit(nqubits) circuit.addparametricRYgate(0, 0.0) circuit.addparametricRYgate(1, 0.0)

circuit.addparametricRYgate(0, 0.0) circuit.addCNOTgate(0, 1) circuit.addparametricRYgate(0, 0.0)

circuit_drawer(circuit) ```

We'll get:

```console


|pRY| |pRY| |pRY| --| |---| |-----●-----| |-- || || | |__| __ | |pRY| |CX | --| |-----------| |---------- || ||

```

Docker

  • You can run Kyulacs.jl out of the box inside the official Julia Docker container:

``console $ docker run --rm -it julia:1.8.3 _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _ | | | | || | | | (| | | Version 1.8.3 (2022-11-14) / |_'|||_'| | Official https://julialang.org/ release |_/ |

julia> using Pkg julia> pkg"registry add General https://github.com/AtelierArith/Gallery.git" julia> Pkg.add("Conda") # Install Conda.jl julia> using Conda julia> Conda.pipinterop(true) julia> Conda.pip("install", "qulacs") julia> Conda.pip("install", "qulacsvis") julia> using Kyulacs: Observable, QuantumCircuit, QuantumState julia> using Kyulacs.Gate: CNOT, Y, merge julia> state = QuantumState(3) julia> seed = 0 # set random seed julia> state.setHaarrandomstate(seed) julia> circuit = QuantumCircuit(3) julia> circuit.addXgate(0) julia> mergedgate = merge(CNOT(0, 1), Y(1)) julia> circuit.addgate(mergedgate) julia> circuit.addRXgate(1, 0.5) julia> circuit.updatequantumstate(state) julia> observable = Observable(3) julia> observable.addoperator(2.0, "X 2 Y 1 Z 0") julia> observable.addoperator(-3.0, "Z 2") julia> value = observable.getexpectation_value(state) ```

Appendix

Docker

console $ git clone https://github.com/AtelierArith/Kyulacs.jl.git $ cd Kyulacs.jl $ make && make test $ make build-gpu && make test-gpu # for gpu version

Blog post

Sponsorship

If you want to see more of our work, consider sponsoring us via Github sponsors.

Owner

  • Name: AtelierArith
  • Login: AtelierArith
  • Kind: organization
  • Email: contact@atelier-arith.jp
  • Location: Japan

Enhance "Math meets Art"

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: 'Kyulacs.jl: Julia interface for Qulacs'
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - name: AtelierArith
    city: Sendai
    country: JP
    post-code: 980-0004
    email: s.terasaki@atelier-arith.jp
    date-start: '2021-04-01'
    website: 'https://github.com/AtelierArith'
repository-code: 'https://github.com/AtelierArith/Kyulacs.jl'
url: 'https://github.com/AtelierArith/Kyulacs.jl'
abstract: 'Kyulacs.jl: Julia interface for Qulacs.'
keywords:
  - Quantum Computing
  - Azarashi
  - Julia
  - Qulacs
license: MIT
commit: 093ee1aaa1341446bb7a31734e5c0e98b71f12a6
version: v0.1.0
date-released: '2024-02-05'

GitHub Events

Total
Last Year

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 105
  • Total Committers: 2
  • Avg Commits per committer: 52.5
  • Development Distribution Score (DDS): 0.019
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Satoshi Terasaki t****h@g****m 103
CompatHelper Julia c****y@j****g 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 6
  • Total pull requests: 56
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 1 day
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 1.83
  • Average comments per pull request: 0.3
  • Merged pull requests: 52
  • Bot issues: 0
  • Bot pull requests: 4
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • terasakisatoshi (4)
Pull Request Authors
  • terasakisatoshi (31)
  • github-actions[bot] (2)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

.github/workflows/CI.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • julia-actions/cache v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-docdeploy v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
Dockerfile docker
  • julia 1.8.3 build
docker-compose.yml docker
  • kyulacsjl latest
.github/workflows/CompatHelper.yml actions