Predefined Quantum Circuits

The submodule QuantumSavory.CircuitZoo provides reusable common quantum circuits.

What CircuitZoo Is For

CircuitZoo collects local quantum routines that appear often in communication and networking models, such as swapping, purification, and fusion.

These are not full protocols. They do not wait on messages, schedule retries, or manage resources over time. They are callable circuit objects that operate on already chosen register slots.

That distinction matters:

  • use CircuitZoo when you want reusable quantum logic;
  • use ProtocolZoo when you want reusable discrete-event control logic.

Common Usage Pattern

Most entries are small callable structs.

circuit = Purify3to1(:Z, :Y)
success = circuit(a[1], b[1], a[2], a[3], b[2], b[3])

This style is useful because a protocol can depend on a circuit by intent instead of re-implementing the same gate pattern inline.

Typical Families

The current CircuitZoo mainly covers:

  • entanglement swapping,
  • purification routines,
  • graph-state fusion, and
  • related node-local subcircuits.

The autodocs below are the exact API reference.

Autogenerated API list for QuantumSavory.CircuitZoo

QuantumSavory.CircuitZoo.FusionType
struct Fusion <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

Performs the type-I fusion operation between two registers. The registers are assumed to be in the same fridge.

source
QuantumSavory.CircuitZoo.Purify2to1Type
struct Purify2to1 <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

  • leaveout: A symbol specifying which of the three Pauli errors to leave undetectable.

A simple purification circuit sacrificing a Bell pair to produce another. The circuit is parameterized by a single leaveout symbol argument which specifies which of the three possible Pauli errors are to be left undetected. A simple purificaiton circuit is not capable of detecting all errors.

If an error was detected, the circuit returns false and the state is reset. If no error was detected, the circuit returns true.

The sacrificial qubits are removed from the register.

julia> a = Register(2)
       b = Register(2)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell);

julia> Purify2to1(:X)(a[1], b[1], a[2], b[2])
true

julia> observable((a[1], b[1]), projector(bell))
1.0

However, an error might have occurred on the initial state. If the error is detectable, the Purify2to1 circuit will return false and the state will be reset.

julia> a = Register(2)
       b = Register(2)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell)
       apply!(a[1], Z);

julia> Purify2to1(:X)(a[1], b[1], a[2], b[2])
false

julia> a
Register  with 2 slots: [ Qubit | Qubit ]
  Slots:
    nothing
    nothing

In some cases the error might not be detectable. In that case, the Purify2to1 circuit does return true, but as you can see below, the state is not what we would expect from a successful purification.

julia> a = Register(2)
       b = Register(2)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell)
       apply!(a[1], X);

julia> Purify2to1(:X)(a[1], b[1], a[2], b[2])
true

julia> observable((a[1], b[1]), projector(bell))
0.0

See also: Purify2to1Node, Purify3to1, PurifyExpedient, PurifyStringent

source
QuantumSavory.CircuitZoo.Purify2to1NodeType
struct Purify2to1Node <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

  • leaveout: A symbol specifying which of the three Pauli errors to leave undetectable.

A purification circuit sacrificing 2 Bell qubits to produce another qubit. The circuit is parameterized by a single leaveout symbol argument which specifies which of the three possible Pauli errors are to be left undetected. A simple purificaiton circuit is not capable of detecting all errors.

This is only "half" of the full purification circuit - the local gates to be applied at a network node. For a complete purification circuit, you need to apply this circuit to the remote node as well. Alternatively, you can use the complete Purifiy2to1](@ref) circuit.

This circuit returns the measurements result (as an integer index among the possible basis states).

julia> a = Register(2)
       b = Register(2)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell);

julia> Purify2to1Node(:X)(a[1:2]...) == Purify2to1Node(:X)(b[1:2]...)
true
source
QuantumSavory.CircuitZoo.Purify3to1Type
struct Purify3to1 <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

  • leaveout1: The error to be fixed twice

  • leaveout2

A purification circuit sacrificing a Bell pair to produce another. The circuit is parameterized by a leaveout1, and a leaveout2 symbol argument which specifies the leaveout of each of the two purification subcircuits This purificaiton circuit is capable of detecting all errors.

If an error was detected, the circuit returns false and the state is reset. If no error was detected, the circuit returns true.

The sacrificial qubits are removed from the register.

julia> a = Register(3)
       b = Register(3)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell)
       initialize!((a[3], b[3]), bell);

julia> Purify3to1(:Z, :Y)(a[1], b[1], a[2], a[3], b[2], b[3])
true
source
QuantumSavory.CircuitZoo.Purify3to1NodeType
struct Purify3to1Node <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

  • leaveout1: The error to be fixed twice

  • leaveout2

A purification circuit sacrificing 2 Bell qubits to produce another. The circuit is parameterized by a leaveout1, and a leaveout2 symbol argument which specifies the leaveout of each of the two purification subcircuits This purificaiton circuit is capable of detecting all errors.

This circuit returns the array of measurements made.

This circuit is the same as the Purifiy3to1 one but it works on individual qubits (i.e. only one qubit of a pair)

This algorithm is detailed in (Fujii and Yamamoto, 2009)

julia> a = Register(3)
       b = Register(3)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       initialize!((a[1], b[1]), bell)
       initialize!((a[2], b[2]), bell)
       initialize!((a[3], b[3]), bell);

julia> Purify3to1Node(:Z, :Y)(a[1], a[2], a[3]) == Purify3to1Node(:Z, :Y)(b[1], b[2], b[3])
true
source
QuantumSavory.CircuitZoo.PurifyExpedientType
struct PurifyExpedient <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

The EXPEDIENT purification circuit. It is composed of a head and a body. The head is repeated twice and the body is also repeating twice

The difference between it and the STRINGENT circuit is that the body is shorter.

If an error was detected, the circuit returns false and the state is reset. If no error was detected, the circuit returns true.

This circuit is detailed in (Naomi H. Nickerson and Benjamin, 2013)

The sacrificial qubits are removed from the register.

julia> r = Register(22)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       for i in 1:11
           initialize!(r[(2*i-1):(2*i)], bell)
       end;

julia> PurifyExpedient()(r[1], r[2], r[3:2:21]..., r[4:2:22]...)
true

See also: PurifyExpedientNode, PurifyStringent

source
QuantumSavory.CircuitZoo.PurifyExpedientNodeType
struct PurifyExpedientNode <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

The EXPEDIENT purification circuit (only the local half, executed on a single network node).

This returns the array of measurements made by the circuit.

This circuit is detailed in (Naomi H. Nickerson and Benjamin, 2013).

julia> r = Register(22)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       for i in 1:11
           initialize!(r[(2*i-1):(2*i)], bell)
       end;

julia> PurifyExpedientNode()(r[1], r[3:2:21]...) == PurifyExpedientNode()(r[2], r[4:2:22]...)
true
source
QuantumSavory.CircuitZoo.PurifyStringentType
struct PurifyStringent <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

The STRINGENT purification circuit. It is composed of a "head" and a "body". The head is repeated twice and the body is also repeating twice

This algorithm is detailed in (Stefan Krastanov and Jiang, 2019)

If an error was detected, the circuit returns false and the state is reset. If no error was detected, the circuit returns true.

This circuit is detailed in (Naomi H. Nickerson and Benjamin, 2013).

The sacrificial qubits are removed from the register.

julia> r = Register(26)
       bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2
       for i in 1:13
            initialize!(r[(2*i-1):(2*i)], bell)
       end;

julia> PurifyStringent()(r[1], r[2], r[3:2:25]..., r[4:2:26]...)
true

See also: PurifyStringentNode, PurifyExpedient

source
QuantumSavory.CircuitZoo.SDDecodeType
struct SDDecode <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

The circuit for Superdense Coding to decode the 2 (classical) bit message using the entangled bell pair stored in the registers regA and regB after Alice's encoding of the first qubit. Returns a Tuple of the decoded message.

julia> regA = Register(1); regB = Register(1);

julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2);

julia> message = (1, 1);

julia> SDEncode()(regA[1], message);

julia> SDDecode()(regA[1], regB[1])
(1, 1)

See also SDEncode

source
QuantumSavory.CircuitZoo.SDEncodeType
struct SDEncode <: QuantumSavory.CircuitZoo.AbstractCircuit

Fields:

The circuit for Superdense Coding to encode the 2 (classical) bit message to its corresponding Bell pair representation. It takes as argumes a single qubit register containing Alice's half of the entangled Bell pair and the 2 bit message Alice intends to send to Bob.

julia> regA = Register(1); regB = Register(1);

julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2);

julia> message = (1, 1);

julia> SDEncode()(regA[1], message);

See also SDDecode

source