-
Notifications
You must be signed in to change notification settings - Fork 21
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
CS269Q Tomography Debugger Project #137
Conversation
Project was done for Stanford's CS269Q class. Full detail of changes are available in this PDF: |
Hi @mikh3x4, at first glance this is awesome! I'll start looking over the code more carefully tomorrow. The other thing to mention is Kyle is about to merge in changes which mark a major refactor of the repo. So we might want to wait till that is done. |
|
||
# if no pauli_num is specified use the maximum | ||
if pauli_num==None: | ||
pauli_num=len(Qubits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pauli_num=len(Qubits) | |
pauli_num=len(qubits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good.
The comments below are pretty minor.
d = 2 ** qubit_num | ||
pauli_list = [] | ||
expectation_list = [] | ||
y = np.zeros((m,1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m
-> pauli_num
|
||
mu = 4 * pauli_num / np.sqrt(1000 * pauli_num) | ||
|
||
for i in range(m): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
range(pauli_num)
expectation_list.append(e) | ||
|
||
x = cp.Variable((d,d),complex = True) | ||
A = cp.vstack([cp.trace(cp.matmul(pauli_list[i], x)) * np.sqrt(d / m) for i in range(m)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np.sqrt(d / m)
-> np.sqrt(d / pauli_num)
range(m)
-> range(pauli_num)
d = 2 ** qubit_num | ||
pauli_list = [] | ||
expectation_list = [] | ||
y = np.zeros((m,1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there might be a typo as the variable m
seems to be undefined.
Maybe should be pauli_num
.
I'll point out below the places where m should be replaced with pauli_num
x = cp.Variable((d,d),complex = True) | ||
A = cp.vstack([cp.trace(cp.matmul(pauli_list[i], x)) * np.sqrt(d / m) for i in range(m)]) | ||
|
||
#Minimize trace norm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might also be nice to point out (in the comment) that the equation below is Eqn. (4) and Eqn. (35) from [FLAMMIA]
#A[i] = e * scale_factor | ||
pauli_list.append(p_tensor) | ||
expectation_list.append(e) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a comment about the objective and constraint in terms of Eqn (3) and (34) in [FLAMMIA]
def compressed_sensing_state_estimate(results: List[ExperimentResult], | ||
qubits: List[int]) -> np.ndarray: | ||
""" | ||
Estimate a quantum state using compressed sensing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Estimate a quantum state using compressed sensing, i.e. by constrained trace minimization (a.k.a. the matrix Dantzig selector).
expectation_list = [] | ||
y = np.zeros((m,1)) | ||
|
||
mu = 4 * pauli_num / np.sqrt(1000 * pauli_num) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could be moved down to line 251, i.e. just before you use it.
Also maybe put a comment in the code telling the reader to look at section V. A of [FLAMMIA] for more information
I tried to push the updated code to your branch and I could not. So I did not want to loose all the work done on that branch and made the changes and PR here #166. The Git history is still there so everyone can see that you did the work :) In light of that I will close this PR. |
State tomography involves measuring a quantum state repeatedly in the bases given by$\rho$ . In this project we set out to create a debugging tool to perform state tomography. This project had two parts. The first was constructing a debuggin interface. We decided that our debugger would take the form of a function that could be called on a program and a list of qubits, and would then run tomography algorithms and output a density matrix. The second was choosing an appropriate advanced algorithm to perform state tomography. Since both linear inversion and MLE had already been implemented in the forest benchmarking tomography file (and since Bayesian estimates are apparently "formidable" for quantum states!), we decided to go with matrix completion/compressed sensing methods.
itertools.product(['X', 'Y', 'Z], repeat=n_qubits)
. From these measurements, we can reconstruct a density matrix