Giter VIP home page Giter VIP logo

snowflurrysdk / snowflurry.jl Goto Github PK

View Code? Open in Web Editor NEW
46.0 6.0 4.0 2.82 MB

Snowflurry is an open source Julia-based software library for implementing quantum circuits, and then running them on quantum computers and quantum simulators. The project is sponsored by Anyon Systems, Inc. See https://snowflurrySDK.github.io/Snowflurry.jl/dev for the latest documentation.

Home Page: https://snowflurry.dev

License: Apache License 2.0

Julia 99.59% Shell 0.41%
quantum-computing quantum-algorithms quantum-mechanics quantum julia julia-language julia-package julialang

snowflurry.jl's Introduction

Snowflurry

Snowflurry.jl

CI tests codecov

Snowflurry is an open source Julia-based software library for implementing quantum circuits, and then running them on quantum computers and quantum simulators.

Installation

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.

Installing Julia

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.

Installing Snowflurry.jl package

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.

Installing SnowflurryPlots.jl package

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")

Getting Started

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 $\left|0\right\rangle$. Our circuit is, therefore, in state $\left|00\right\rangle$. The qubit ordering convention used is qubit number 1 on the left, with each following qubit to the right of it. We now proceed by adding gates to our circuit.

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 $\left|00\right\rangle$ and $\left|11\right\rangle$ states.

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.

Roadmap

See what we have planned by looking at the Snowflurry Github Project.

Snowflurry Contributors Community

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.

Alpha Disclaimer

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.

snowflurry.jl's People

Contributors

alireza-najafi avatar annelophaneufanyon avatar caffeine-storm avatar fsosarey avatar npoirie1 avatar plerouxanyon avatar ps-pat avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

snowflurry.jl's Issues

Refactor circuit into an interface

Overview

The implementation of Circuit should not be public. There will only be one circuit type, and it does not make sense to make an AbstractCircuit, but we can still only work with a well-defined interface. This will decouple the public interface from the implementation allowing us to make changes as we require.

Sub-tasks

Add AbstractGate and AbstractOperator

Our recent work on performance has shown that we need a better gate and operator abstraction for code maintainability.

We will test out our idea on a Phased gate. It is a parameterized gate which has a diagonal operator.

This issue will track the refactor.

Basic transpiler

Overview

To run arbitrary circuits on Anyons hardware, we need a basic transpiler to transpile circuits to a native gate set and then map the circuit to the connected hardware.

Objectives

  • Support the native gate set of Anyon's machine (Rxy, Rz, ISwap)
  • Place qubits (and optionally add swaps) on a line device.

Tasks

Making releases

Hi,
Can you create actual releases, with a tag and a version number ? "main" is not a release.

I suggest adopting Semantic Versioning https://semver.org/

Thanks

simulate_shots does not correctly handle complex values

The amplitudes computed in the simulate_shots function are incorrect when kets have nonzero imaginary terms.

For instance, the samples in the following example should be "0" instead of "1":

julia> circuit = QuantumCircuit(qubit_count=1, bit_count=0);

julia> push_gate!(circuit, sigma_x(1));

julia> push_gate!(circuit, phase(1));

julia> push_gate!(circuit, sigma_x(1));

julia> push_gate!(circuit, phase(1))
Quantum Circuit Object:
   id: 52530f1c-b6d9-11ed-0fca-b9527064440e 
   qubit_count: 1 
   bit_count: 0 
q[1]:──X────S────X────S──
                         



julia> shots = simulate_shots(circuit, 5)
5-element Vector{String}:
 "1"
 "1"
 "1"
 "1"
 "1"

Add randomized benchmarking

Overview

Add randomized benchmarking experiments.

Depends on

Disclosure

We plan on implementing this feature, but it is not an immediate priority. Please add an +1 emoji to this issue if you want to have this feature in Snowflake.

Add QPU interface

The interface will abstract away details of the underlying quantum computer so that experiments do not have to depend on a concrete device.

Add Anyon Quantum Computer Client

A low-level interface to Anyon's quantum computer

The client will be able to submit jobs, get the job status, and get job results

Implement Efficient CNOT to ISwap transpilation

Overview

To efficiently compile CNot gates to ISwap we need to convert the CNot gate to Cnot-Swap-Swap and then convert Cnot-Swap to ISwap.

See https://arxiv.org/abs/quant-ph/0209035 for details

Requirements

Add convert CNot to CNot-Swap-Swap transpiler
Add Cnot-Swap to ISwap transpiler

Disclosure

We do yet have a concrete plan to implement this feature. Please add an +1 emoji to this issue if you want to have this feature in Snowflake.

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.