Codercise I15.3 Quantum Teleportation

Hello!

I’m trying to write the rotate_and_controls function following the circuit diagram. I believe that I am applying the correct operations, but I’m still getting an error when I execute it. I’m supposed to implemented the two gates that perform the “change of basis” and then the two control gates inside the orange “measurement” block.

def rotate_and_controls():
    ##################
    # YOUR CODE HERE #
    ##################

    # PERFORM THE BASIS ROTATION
    qml.CNOT(wires=[0, 1])
    qml.Hadamard(wires=0)

    # PERFORM THE CONTROLLED OPERATIONS

    qml.CNOT(wires=[1, 2])  # 
    
   # Z = H X H
    qml.Hadamard(wires=2)
    qml.CNOT(wires=[0, 2])
    qml.Hadamard(wires=2)

Incorrect: Your measurement circuit is not applying the correct operations.

Am I expected to measure and return something here?
Am I missing an obvious mistake?
Not sure what to ask, I’m just confused :sweat_smile:

Thanks for your help!

Hi @Brais,

You might find it easier to use the CZ PennyLane operator.

I hope this helps!

1 Like

Thank you! This has worked.
I was coming with the “I14 mindset” of creating my own controlled gates… (-:

It’s a head-scratcher why HXH didn’t work, though.

Hi @Brais, you caught a bug here where the grader only accepted the exact answer we expected. Now that we’re aware of this we can think of a new way to grade the answer which accepts decompositions too.