Snowflurry is an open source Julia-based software library for implementing quantum circuits, and then running them on quantum computers and quantum simulators.
The following installation steps are for people interested in using Snowflurry in their own applications. If you are interested in contributing, head right over to our Contributing to Snowflurry page.
Make sure your system has Julia installed. If not, download the latest version from https://julialang.org/downloads/.
We officially support the latest stable release and the latest Long-Term Support (LTS) release. Any release in-between should work (please submit a Github issue if they don't), but we only actively test against the LTS and the latest stable version.
The latest release of Snowflurry can be pulled from JuliaHub and installed with the following command:
import Pkg
Pkg.add("Snowflurry")
This adds the Snowflurry package to the current Julia Environment.
Snowflurry is under active development. To use the development version, the main
branch from Github can be installed instead using the following commands in the Julia REPL:
import Pkg
Pkg.add(url="https://github.com/SnowflurrySDK/Snowflurry.jl", rev="main")
Warning: The main branch of Snowflurry targets new internal infrastructure. Existing users should use the latest stable release instead.
Multiple visualization tools are available in the SnowflurryPlots package. After installing Snowflurry, the SnowflurryPlots package can be installed by entering the following in the Julia REPL:
import Pkg
Pkg.add(url="https://github.com/SnowflurrySDK/SnowflurryPlots.jl", rev="main")
The best way to learn Snowflurry is to use it! Let's try to make a two-qubit circuit which produces a Bell/EPR state. We'll use Snowflurry to construct and simulate the circuit then verify the produced Ket
.
The quantum circuit for generating a Bell state involves a Hadamard gate on one of the qubits followed by a CNOT gate (see here for an introduction to quantum logic gates). This circuit is shown below:
First import Snowflurry:
using Snowflurry
With Snowflurry imported, we can define our two-qubit circuit.
c = QuantumCircuit(qubit_count = 2)
print(c)
# output
Quantum Circuit Object:
qubit_count: 2
bit_count: 2
q[1]:
q[2]:
In Snowflurry, all qubits start in state
push!(c, hadamard(1))
push!(c, control_x(1, 2))
print(c)
# output
Quantum Circuit Object:
qubit_count: 2
bit_count: 2
q[1]:──H────*──
|
q[2]:───────X──
The first line adds a Hadamard gate to circuit object c
which will operate on qubit 1. The second line adds a CNOT gate (Control-X gate) with qubit 1 as the control qubit and qubit 2 as the target qubit.
Note: Unlike C++ or Python, indexing in Julia starts from "1" and not "0"!
Once we've built our circuit, we can consider if it would benefit from applying any transpilation operations. Transpilation is the process of rewriting the sequence of operations in a circuit to a new sequence. As a rule, the new sequence will yield the same quantum state as the old sequence but possibly optimizing the choice of gates used for performance, using only those gates supported by a specific hardware QPU. Since the circuit is relatively small and Snowflurry's simulator can handle all gates, we won't run any transpilation for the time being.
Next, we'll simulate our circuit to see if we've built what we expect.
ψ = simulate(c)
print(ψ)
# output
4-element Ket{ComplexF64}:
0.7071067811865475 + 0.0im
0.0 + 0.0im
0.0 + 0.0im
0.7071067811865475 + 0.0im
For those who are familar, we recognize that the resultant state is the Bell state; an equal superposition of the
Finally, we can use SnowflurryPlots to generate a histogram which shows the measurement output distribution after taking a certain number of shots, in this case 100, on a quantum computer simulator:
using SnowflurryPlots
plot_histogram(c, 100)
The script below puts all the steps above together:
using Snowflurry, SnowflurryPlots
c = QuantumCircuit(qubit_count = 2)
push!(c, hadamard(1))
push!(c, control_x(1, 2))
ψ = simulate(c)
plot_histogram(c, 100)
You can learn to execute circuits on simulated hardware by following the Virtual QPU tutorial.
For selected partners and users who have been granted access to Anyon's hardware, follow the Virtual QPU tutorial first, then check out how to run circuits on real hardware.
See what we have planned by looking at the Snowflurry Github Project.
We welcome contributions! If you are interested in contributing to this project, a good place to start is to read our How to Contribute page.
We are dedicated to cultivating an open and inclusive community to build software for near term quantum computers. Please read our Code of Conduct for the rules of engagement within our community.
Snowflurry is currently in alpha. We may change or remove parts of Snowflurry's API when making new releases.
Copyright (c) 2023 by Snowflurry Developers and Anyon Systems, Inc.