qiskit-community / qiskit-alt

High-performance Qiskit features backed by Julia. A Python front end to algorithms using Pauli and Fermionic operators implemented in Julia.
Apache License 2.0
13 stars 2 forks source link
qiskit-alt

qiskit_alt

qiskit_alt

This Python package uses a backend written in Julia to implement high performance features for standard Qiskit. This package is a proof of concept with little high-level code.

Installing and managing Julia and its packages is automated. So you don't need to learn anything about Julia to get started.

Table of contents

Installation and Configuration Notes

Basic

shell> pip install qiskit_alt

See julia_project for more options.

More installation details

Compilation

[1]: import qiskit_alt

In [2]: qiskit_alt.project.ensure_init(use_sys_image=False)

In [3]: qiskit_alt.project.compile()

Compilation takes about four minutes. The new Julia system image will be found the next time you import qiskit_alt. Note that we disabled possibly loading a previously-compiled system image before compiling a new one. This avoids some possible stability issues.

Using qiskit_alt

This is a very brief introduction.

import qiskit_alt; import julia; from julia import PkgName. After this, all functions and symbols in PkgName are available. You can do, for example

In [1]: import qiskit_alt

In [2]: qiskit_alt.project.ensure_init()

In [3]: julia = qiskit_alt.project.julia

In [4]: julia.Main.cosd(90)
Out[4]: 0.0

In [5]: QuantumOps = qiskit_alt.project.simple_import("QuantumOps")

In [6]: pauli_sum = QuantumOps.rand_op_sum(QuantumOps.Pauli, 3, 4); pauli_sum
Out[6]:
<PyCall.jlwrap 4x3 QuantumOps.PauliSum{Vector{Vector{QuantumOps.Paulis.Pauli}}, Vector{Complex{Int64}}}:
IIZ * (1 + 0im)
XYI * (1 + 0im)
YIX * (1 + 0im)
ZIZ * (1 + 0im)>

In the last example above, PauliSum is a Julia object. The PauliSum can be converted to a Qiskit SparsePauliOp like this.

In [7]: from qiskit_alt.pauli_operators import PauliSum_to_SparsePauliOp

In [8]: PauliSum_to_SparsePauliOp(pauli_sum)
Out[8]:
SparsePauliOp(['ZII', 'IYX', 'XIY', 'ZIZ'],
              coeffs=[1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])

Introduction

The highlights thus far are in benchmark code, which is presented in the demonstration notebooks. There is one demonstration notebook using pyjulia and another demonstration notebook using juliacall.

The main application-level demonstration is computing a qubit Hamiltonian as a qiskit.quantum_info.SparsePauliOp from a Python list specifiying the molecule geometry in the same format as that used by qiskit_nature.

You might want to skip to installation instructions

Demonstration

Managing Julia packages

Julia Packages

Testing

The test folder is mostly out of date.

Testing installation with docker

See the readme.