-
Notifications
You must be signed in to change notification settings - Fork 57
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
Advanced tutorial on quantum simulation #33
Conversation
Pull Request Test Coverage Report for Build 3175685706
💛 - Coveralls |
The notebook is too large to view in GitHub so I won't be able to provide comments in-line. Just a few comments for now:
|
def compute_H(tau, tau_d, num_sites, defect_locs):
'''
Compute 1D spinless tight-binding Hamiltonian with "defective" interactions on specificed edges
Args:
tau - float; strength of hopping term between all sites except at the defect edge(s)
tau_d - float; strength of hopping term at defect edge(s)
num_sites - int; number of lattice sites in the 1D chain
defect_locs - list or array of ints; index location(s) of defect edge(s). Indexed such that the left most edge is at position 0 and the rightmost is 4
Returns:
H - SummedOp; the Hamiltonian
'''
H = 0
for i in range(num_sites-1):
if (i in defect_locs):
H += -tau_d/2 * ((I^(num_sites-i-2))^(X^X)^(I^i))
H += -tau_d/2 * ((I^(num_sites-i-2))^(Y^Y)^(I^i))
else:
H += -tau/2 * ((I^(num_sites-i-2))^(X^X)^(I^i))
H += -tau/2 * ((I^(num_sites-i-2))^(Y^Y)^(I^i))
return H Wouldn't it be more appropriate and pedagogical to construct the original fermionic Hamiltonian using Qiskit Nature and then map it to a qubit Hamiltonian using the Jordan-Wigner transform in Qiskit Nature? |
The listed typos have been corrected. I scanned over the notebook again but didn't find any others. Thanks for the qiskit nature suggestion. We added it, and kept the Opflow method because 1) it's good to be familiar with how to do this both ways and 2) the opflow method supports Parameters, but the FermionicOp object does not currently support Parameters. |
Ah ok that makes sense, I hadn't thought of the Parameters issue. Please state explicitly in the notebook that the reason we use OpFlow at all is that Nature does not yet support Parameters. Then, add a TODO in a comment saying to update the notebook once Qiskit Nature supports Parameters. The tests are failing because
|
Also ran black styling on notebook and included tqdm in requirements file
Made the changes and committed :) Edit: |
There is now an issue at Qiskit Nature for Parameter support: qiskit-community/qiskit-nature#828. Please reference this issue in the TODO that I asked you to add. |
replaced depreciated ignis measurement error mit with mthree; updated the rzx transpiler pass to be compatible with latest qiskit version; formatted print statements; and corrected typos
Committed with latest changes: using mthree for measurement mitigation now, updated TODO, fixed a couple typos, formatted print statements, updated Rzx pulse scaling Transpiler pass for lastest qiskit version (0.38), and reformatted the notebook using black. |
@ajrazander It seems like the notebook should still run if you use an instance of FakeLagos instead of the real one. Could you test that? If it works, then you should comment out the code that instantiates a real backend, and use a fake backend instead. That way, we can actually test the notebook and can satisfy the CI. |
Using FakeLagos gives dramatically better results compared to the real backend. The plots look quite different. I'd like the plots to display the data from the real backend, not simulated data. What's the best way to do this? |
Unfortunately we don't currently have a good way to retrieve real data and still test the notebook. You can include instructions in the notebook for swapping out the simulator for a real backend, and reference your paper for the real data. |
As a side note, the noise models in Qiskit Terra should be made more realistic. If you'd like, you can open an issue at Terra with a simple example showing the discrepancy. |
Done and done Qiskit/qiskit#8786 |
docs/tutorial_quantum_sim/index.rst
Outdated
of the experiment were implemented, collects experimental data, analyzes data, and generates plots. | ||
|
||
.. _arXiv:2209.02795: https://arxiv.org/abs/2209.02795 | ||
.. _tutorial: qsim-tight-binding-model.ipynb |
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 looks like the link is written incorrectly. Please build the docs locally and make sure they look correct.
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've updated the index.rst files, and the building is doing better than before, but now it's timing out. I get this output:
.
.
.
Notebook error:
CellTimeoutError in tutorial_quantum_sim/qsim-tight-binding-model.ipynb:
A cell timed out while it was being executed, after 180 seconds.
The message was: Cell execution timed out.
Here is a preview of the cell contents:
-------------------
['# Evaulate all circuits over all time points and take the mean', '', '# Compute parameterized circuit over a range of trotter steps', 'trotter_steps_array = np.arange(1, 13)', '']
...
[' # Calculate average fidelity for a given trotter step', ' qc_rzx_fid_ests.append(np.mean(rzx_fids))', '', ' # Calculate average duration for a given trotter step', ' qc_rzx_dur_ests.append(np.mean(qc_dur))']
-------------------
Task was destroyed but it is pending!
task: <Task pending name='Task-453' coro=<NotebookClient._async_poll_output_msg() running at /Users/ajrasmusson/Documents/GitHub/qiskit-research/.tox/docs/lib/python3.8/site-packages/nbclient/client.py:812> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fe8b209b730>()]>>
ERROR: InvocationError for command /Users/ajrasmusson/Documents/GitHub/qiskit-research/.tox/docs/bin/sphinx-build -b html -W docs/ docs/_build/html (exited with code 2)
______________________________________________________ summary ______________________________________________________
ERROR: docs: commands failed
I'm not sure what the error here is exactly. It seems like the tox -edocs is trying to run the notebook, but one of the cells is taking longer then 180 seconds?
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.
Please push your changes and I will investigate increasing the time limit. I'm wondering though, could you take a look at the long-running cell and think about whether there is a reasonable way to make it execute faster?
Docs built successfully!
Please revert the unrelated changes to the protein folding notebook. |
This reverts commit a092126.
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.
@ajrazander is this ready is merge?
Yes, I don't have any other edits :) |
This PR includes an advanced tutorial on quantum simulation methods with the aim of demonstrating advanced topics in quantum simulation and error mitigation to newcomers.