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

Added a tutorial for simulating Ising 1-D chain using mitiq with cirq… #2002

Merged

Conversation

farzadkianvash
Copy link
Contributor

@farzadkianvash farzadkianvash commented Sep 8, 2023

This pull request Added a tutorial for simulating Ising 1-D chain using mitiq with cirq interface base on https://arxiv.org/pdf/2103.12680.pdf
This pull request solves Issue #1799

Description


License

  • I license this contribution under the terms of the GNU GPL, version 3 and grant Unitary Fund the right to provide additional permissions as described in section 7 of the GNU GPL, version 3.

Before opening the PR, please ensure you have completed the following where appropriate.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello @farzadkianvash, thank you for submitting a PR to Mitiq! We will respond as soon as possible, and if you have any questions in the meantime, you can ask us on the Unitary Fund Discord.

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (4493368) 98.30% compared to head (31036c3) 98.30%.

❗ Current head 31036c3 differs from pull request most recent head f30d8ef. Consider uploading reports for the commit f30d8ef to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2002   +/-   ##
=======================================
  Coverage   98.30%   98.30%           
=======================================
  Files          87       87           
  Lines        4118     4118           
=======================================
  Hits         4048     4048           
  Misses         70       70           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@purva-thakre
Copy link
Collaborator

@farzadkianvash You might need to add this file to examples.md to be able to see the docs build output on RTD. Right now it is unlisted.

Something like ZNE with Cirq: 1D Ising Simulation in the linked file.

https://github.com/unitaryfund/mitiq/blob/master/docs/source/examples/examples.md

@farzadkianvash
Copy link
Contributor Author

@purva-thakre Thank you for the comment, I changed the examples.md file as you suggested.

@nathanshammah nathanshammah linked an issue Sep 13, 2023 that may be closed by this pull request
6 tasks
@nathanshammah nathanshammah added this to the 0.30.0 milestone Sep 13, 2023
@Misty-W Misty-W self-requested a review September 13, 2023 17:34
Copy link
Contributor

@Misty-W Misty-W left a comment

Choose a reason for hiding this comment

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

Off to a good start, @farzadkianvash! Seems like the major pieces are in place.

My main comment is that the notebook appears not to have run successfully on Read the Docs, and I see errors in the docs build in CI.

I'm happy to help with troubleshooting. I recommend you begin by attempting to build the docs locally and checking the error messages.

@@ -20,6 +20,7 @@ ZNE with Cirq: Solving MaxCut with QAOA <maxcut-demo.md>
ZNE with Cirq: Hamiltonian simulation with Pauli gates<hamiltonians.md>
ZNE with Cirq: Energy of molecular Hydrogen <molecular_hydrogen.md>
ZNE with Cirq: Noise scaling methods <scaling.md>
ZNE with Cirq: 1D Ising Simulation <quantum_simulatio_1D_ising.md>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ZNE with Cirq: 1D Ising Simulation <quantum_simulatio_1D_ising.md>
ZNE with Cirq: 1D Ising Simulation <quantum_simulation_1d_ising.md>

Copy link
Contributor Author

@farzadkianvash farzadkianvash Sep 15, 2023

Choose a reason for hiding this comment

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

Thank you for the comment, I just realized that the correct name of the file is <quantum_simulation_1D_ising.md> with the capital "D", while in your suggestion you the name of the file is written as <quantum_simulation_1d_ising.md>.

I don't know if python is case sensitive. In case it is, could you please add another comment suggesting an edit with the correct name, so I don't need to update the pull request from my computer and don't mess up with other changes?

docs/source/examples/quantum_simulatio_1D_ising.md Outdated Show resolved Hide resolved
docs/source/examples/quantum_simulatio_1D_ising.md Outdated Show resolved Hide resolved
farzadkianvash and others added 4 commits September 15, 2023 14:53
corrected a mistake in the example.md file

Co-authored-by: Misty Wahl <82074193+Misty-W@users.noreply.github.com>
removed the part for installing Mitiq

Co-authored-by: Misty Wahl <82074193+Misty-W@users.noreply.github.com>
updating some comments.

Co-authored-by: Misty Wahl <82074193+Misty-W@users.noreply.github.com>
@nathanshammah
Copy link
Member

Could suppress the warnings with a code snippet like:

import warnings
warnings.filterwarnings('ignore')

Copy link
Member

@nathanshammah nathanshammah left a comment

Choose a reason for hiding this comment

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

In these lines, and elsewhere, can you please remove the metadata (related to "colab" information) from the code blocks? E.g., :id:.

The error seems to be just linkchecks, reebuilding just to make sure.

Please add yourself to the AUTHORS file and tick the License agree here.

Copy link
Member

@nathanshammah nathanshammah left a comment

Choose a reason for hiding this comment

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

More comments.




+++ {"id": "81aa4c72"}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+++ {"id": "81aa4c72"}

\end{equation}
which is a product of different unitary operators. Finally, one can express each of these unitary operators as a gate sequence of single-qubit gates or two-qubit gates that are subsequently applied.

+++ {"id": "Z4U83K3WjCMv"}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+++ {"id": "Z4U83K3WjCMv"}

warnings.filterwarnings('ignore')
```

+++ {"id": "478f5fc8"}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
+++ {"id": "478f5fc8"}

To start with coding, we define function "trotter_evolution_H" which is $U(\Delta t)$

```{code-cell}
:id: a6d68546
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:id: a6d68546

Copy link
Member

Choose a reason for hiding this comment

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

These are just examples, there are more in the file.


+++ {"id": "81aa4c72"}

In this tutorial, we employ ZNE, CDR, and VNCDR mitigation techniques to address errors in the simulation of the 1-D Transverse-Longitudinal Ising model using Mitiq. It is important to note that the results presented here are not original, but rather an attempt to reproduce some of the findings outlined in the paper available at https://arxiv.org/pdf/2103.12680.pdf.
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add this reference to the refs.bib file (e.g., saving it as Sopena_2023_Quantum) and reference to it using:

{cite}`Sopena_2023_Quantum`

docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
Comment on lines +270 to +272
# Generate the fitted curve
x_fit = np.linspace(0, n_dt*Jdt, 300)
y_fit = sigma_z_t(x_fit, *popt)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great to have the ideal value plotted, with a line showing it. It could be done running the simulation on an ideal simulator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean to do exact trotterized results? since I do not know how to simulate that Hamiltonian other than trattorization. I used two different names "exact" and "trotterized", I should use the same name for them, something like "exact trotterization".

let me know if this is what you are suggesting.

docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
Copy link
Member

@nathanshammah nathanshammah left a comment

Choose a reason for hiding this comment

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

Thanks @farzadkianvash, looks good to me!

@andreamari
Copy link
Member

Thanks @farzadkianvash! I think you forgot to add the thumbnail in the example gallery. Thanks for addressing all the rest.

@nathanshammah
Copy link
Member

tests passed!

docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
docs/source/examples/examples.md Outdated Show resolved Hide resolved
docs/source/examples/quantum_simulation_1d_ising.md Outdated Show resolved Hide resolved
@nathanshammah nathanshammah merged commit c069a38 into unitaryfund:master Oct 6, 2023
17 of 18 checks passed
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.

Add a tutorial on quantum simulation
5 participants