Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds two qubit functions #70

Closed

Conversation

purva-thakre
Copy link
Contributor

@purva-thakre purva-thakre commented Jul 6, 2021

Circuit of Two-Level Unitaries Example

The output of the function is a tuple of the gate dictionary and two-level gates in order. The gate labels are arbitrary numbered U's which will hopefully change when a two-level unitary gate is added.

np.set_printoptions(precision=3)
two_qubit = rand_unitary(4,dims=[[2,2],[2,2]])

# Output from the function
dict_and_gate_list = decompose_two_qubit_to_two_level_unitary(two_qubit)

# appending the user_gates attribute to the quantum circuit of interest
quantum_circuit = QubitCircuit(2,reverse_states=False )
user_gates_from_output = dict_and_gate_list[0]
quantum_circuit.user_gates = user_gates_from_output

# add gates to the circuit and get circuit diagram
quantum_circuit.add_gates(dict_and_gate_list[-1])
quantum_circuit.png

download

# Comparison to the input
calculatedu = quantum_circuit.compute_unitary()
print(average_gate_fidelity(calculatedu,two_qubit))

@purva-thakre purva-thakre marked this pull request as draft July 6, 2021 12:02
@purva-thakre
Copy link
Contributor Author

purva-thakre commented Jul 12, 2021

The single qubit functions in this branch have not been updated with the feedback from last week (July 6). Those changes are in the single qubit functions branch.

return(user_gates, gate_list)


def decompose_two_qubit_to_CNOT_and_single_qubit_gates(input_gate):
Copy link
Contributor Author

@purva-thakre purva-thakre Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output of this function is not what it is expected to be. For this reason, all of the smaller gates for U6,...,U1 have been defined separately. A for loop will be created for this once the output matches exactly to the input. In addition, all the two qubit decomposition methods will be made private after a general two qubit decomposition function isalso be added - provides choice for circuit output.

Need to recalculate the target and control qubits because they were different from what was expected for the two level circuit output function. The output of the two level output matches exactly to the input with new values for controls and targets.

Just because I know the correct control and targets does not imply how the controls and targets for CNOT and Pauli X of each gate should be corrected.

The hope is to check and compare my calculations with the targets and controls from gray code function's output.

Tentative new values for the target/controls - cnot_gates_2_qubits.pdf

)


def _decompose_to_two_level_arrays(input_gate):
Copy link
Contributor Author

@purva-thakre purva-thakre Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function will be discarded after a general function decomposing a n qubit gate to two level arrays is defined.

The plan is to iterate over the row and column indices in a for loop to avoid manually defining indices for the decomposition.

return(array_list)


def decompose_two_qubit_to_two_level_unitary(input_gate):
Copy link
Contributor Author

@purva-thakre purva-thakre Jul 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. Once a general method for decomposition to two level unitaries exists, this function will be discarded.

Defined here for convenience of checking the output of a two qubit gate.

@purva-thakre
Copy link
Contributor Author

Closing this for now because git rebase is causing issues with conflicts. Will open a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants