Skip to content

Wrong QASM output for Teleportation circuit #28

@vadym-kl

Description

@vadym-kl

The code below

// Prepares (|00> + |11>)/Sqrt(2) given input qubits are both |0>
module PrepareEntangledPair( qbit a, qbit b ) {
    H(a);
    CNOT(a,b);
}

// Un-prepares (|00> + |11>)/Sqrt(2) given input qubits are both |0>
module PrepareEntangledPairAdjoint( qbit a, qbit b ) {
    CNOT(a,b);
    H(a);
}

module Teleport( qbit msg, qbit here, qbit there ) {
    PrepareEntangledPair(here,there);
    PrepareEntangledPairAdjoint(msg,here);
    if( MeasZ(msg) ) { Z(there); }
    if( MeasZ(here) ) { X(there); }
}

int main() {
    // We assume that newly allocated qubits are in |0> state
    qbit q[3];

    // Set the first qubit to |+>
    PrepX(q[0], 0);
    Teleport(q[0],q[1],q[2]);
    
    // Measure third qubit in X basis
    if( MeasX(q[2]) ) { return 1; } else { return 0; }
}

Produces the following QASM file :

qubit q0
qubit q1
qubit q2
PrepX q0
H q1
CNOT q1,q2
CNOT q0,q1
H q0
MeasZ q0
Z q2
MeasZ q1
X q2
MeasX q2

The QASM was obtained by running scaffold.sh -f teleport.scaffold on epiqc/scaffcc Docker image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions