Skip to main content

Simulator for Quantum Networks and Channels

Project description

Simulator for quantum networks and channels

SQUANCH (Simulator for QUAntum Networks and CHannels) is an open-source Python framework for creating performant and parallelized simulations of distributed quantum information processing. Although it can be used as a general-purpose quantum computing simulation library, SQUANCH is designed specifically for simulating quantum networks, acting as a sort of "quantum playground" to test ideas for quantum networking protocols. The package includes flexible modules that allow you to easily design and simulate complex multi-party quantum networks, extensible classes for implementing quantum and classical error models for testing error correction protocols, and a multi-threaded framework for manipulating quantum information in a performant manner.

SQUANCH is developed as part of the Intelligent Quantum Networks and Technologies (INQNET) program, a collaboration between AT&T and the California Institute of Technology.

Documentation

Documentation for this package is available at the documentation website or as a pdf manual. You can also view the presentation given at the 2017 INQNET Symposium here.

Installation

You can install SQUANCH directly using the Python package manager pip:

pip install squanch

If you don't have pip, you can get it using easy_install pip.

Demonstrations

Demonstrations of various quantum protocols can be found in the demos folder and in the documentation:

As a simple example to put in this readme, let's consider a simulation of a transmission of classical data via quantum superdense coding. In this scenario, we have three agents, Alice, Bob, and Charlie. Charlie will distribute Bell pairs between Alice and Bob, then Alice will send data to Bob by encoding two bits in the Pauli-X and -Z operations for each of her photons. Bob receives Alice's photons and disentangles them to reconstruct her information, as shown in the following diagram.

Simulating complex scenarios with multiple agents like this one is what SQUANCH is designed to do. The quantum states of large numbers of particles can be efficiently dealt with using QStream objects, and the behavior of each agent can be defined by extending the built-in Agent class. The entire simulation runs in parallel in separate processes for each agent. The code necessary to simulate this scenario is given below.

import numpy as np
import matplotlib.image as image
import matplotlib.pyplot as plt
from squanch import *

# Alice sends information to Bob via superdense coding
class Alice(Agent):
    def run(self):
        for _ in self.stream:
            bit1 = self.data.pop(0)
            bit2 = self.data.pop(0)
            q = self.qrecv(charlie)
            if q is not None:
                if bit2 == 1: X(q)
                if bit1 == 1: Z(q)
            self.qsend(bob, q)

# Bob receives Alice's transmissions and reconstructs her information
class Bob(Agent):
    def run(self):
        bits = []
        for _ in self.stream:
            a = self.qrecv(alice)
            c = self.qrecv(charlie)
            if a is not None and c is not None:
                CNOT(a, c)
                H(a)
                bits.extend([a.measure(), c.measure()])
            else:
                bits.extend([0,0])
        self.output(bits)

# Charlie distributes Bell pairs between Alice and Bob
class Charlie(Agent):
    def run(self):
        for qsys in self.stream:
            a, b = qsys.qubits
            H(a)
            CNOT(a, b)
            self.qsend(alice, a)
            self.qsend(bob, b)

# Load an image and serialize it to a bitstream
img = image.imread("/docs/source/img/foundryLogo.bmp")
bits = list(np.unpackbits(img))

# Allocate a shared Hilbert space and output object to pass to agents
mem = Agent.shared_hilbert_space(2, int(len(bits) / 2))
out = Agent.shared_output()

# Make agent instances and connect them over simulated fiber optic lines
alice = Alice(mem, out, data = bits)
bob = Bob(mem, out)
charlie = Charlie(mem, out)
alice.qconnect(bob, FiberOpticQChannel, length = 1.0)
charlie.qconnect(alice, FiberOpticQChannel, length = 0.5)
charlie.qconnect(bob, FiberOpticQChannel, length = 0.5)

# Run the simulation and display what Bob receives
Simulation(alice, bob).run()
received_img = np.reshape(np.packbits(out["Bob"]), img.shape)
plt.imshow(received_img)

Alice transmitting an image to Bob over 1km simulated fiber optic cable.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SQUANCH-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SQUANCH-1.0.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file SQUANCH-1.0.0.tar.gz.

File metadata

  • Download URL: SQUANCH-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for SQUANCH-1.0.0.tar.gz
Algorithm Hash digest
SHA256 87a09d717e18a9122202191c3513aa10b1a39fd9010e372099be2b3de38f98f9
MD5 866753915f1690df255dc1ba92d0e1c8
BLAKE2b-256 b4c9d7f5ef1cf31fab446371ef73c22e6117a48a566b946cc8433a3a3bc58a87

See more details on using hashes here.

File details

Details for the file SQUANCH-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for SQUANCH-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4c729ce8dfa35dd6b826f8964a3e351b7296136487d0ec0a906dccd6760b719
MD5 cd6272baf339bd869e09e84477000bf8
BLAKE2b-256 5d3dda3279bc70f72a47a3c6685a7d715eefe16f7eb31822d60005fda6eed4e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page