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

Add OTOC documentation #190

Merged
merged 3 commits into from
Aug 9, 2021
Merged

Add OTOC documentation #190

merged 3 commits into from
Aug 9, 2021

Conversation

rmlarose
Copy link
Contributor

Adds a tutorial based on this example which shows how to recreate Fig 1 from the publication.

@google-cla google-cla bot added the cla: yes label Jul 27, 2021
@mpharrigan mpharrigan self-requested a review August 6, 2021 22:33
Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

I've noted the "non optional" comments, other comments should be taken under advisement

This is pretty slow, but I guess it comes with the territory. It's also rather unfortunate that we use "meaningful indexing" where you have to sortof note what the various indices mean instead of nice dataclasses, but I understand that's how the code is written and it's outside the scope of this example to change it.

"Quantum scrambling describes how interaction in a quantum system disperses local information into its many degrees of freedom. Analogous to classical chaos, scrambling manifests itself as a [butterfly effect](https://en.wikipedia.org/wiki/Butterfly_effect) wherein a local perturbation is rapidly amplified over time. The perturbation is modeled by a local operator $\\hat{O}$ (the *butterfly operator*) acting on a qubit (the *butterfly qubit*). Under a dynamical process $\\hat{U} = \\hat{U}(t)$, the butterfly operator evolves in the Heisenberg picture as\n",
"\n",
"$$\n",
"\\hat{O} (t) = \\hat{U}^\\dagger \\hat{O} \\hat{U}\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

kindof strange that $t$ doesn't appear on the rhs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No change to match with arxiv paper

"\n",
"Note that if operator entanglement is also present ($n_p \\gg 1$), $\\bar{C}(t)$ approaches $0$ for all circuits and their fluctuation vanishes as well.\n",
"\n",
"In what follows, we show how to build OTOC circuits, run them & compute $\\bar{C}$, then visualize results and detect operator spreading."
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit why do you use "&" once but "and" in other places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed & -> and

"if use_noisy_simulator or processor_id == \"\":\n",
" print(\"Using a noisy simulator.\")\n",
" sampler = cg.PhasedFSimEngineSimulator.create_with_random_gaussian_sqrt_iswap(\n",
" mean=cg.SQRT_ISWAP_PARAMETERS,\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

no such thing SQRT_ISWAP_PARAMETERS. Do you mean SQRT_ISWAP_INV_PARAMETERS

(non-optional)

Copy link
Contributor Author

@rmlarose rmlarose Aug 9, 2021

Choose a reason for hiding this comment

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

Fixed. (1st push was before Cirq 0.11 update)

},
"outputs": [],
"source": [
"if not use_noisy_simulator:\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

or processor_id == ""

[or fix it so use_noisy_simulator is True if processor_id == ""]. (non optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed so use_noisy_simulator is True if processor_id == ""

"print(\"Measurement qubit:\", qubits[0])\n",
"print(\"Butterfly qubit:\", q_b)\n",
"\n",
"print(\"\\nExample OTOC circuit:\\n\", otoc_circuits.butterfly_Y[0], sep=\"\\n\")"
Copy link
Collaborator

Choose a reason for hiding this comment

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

on my jupyter, whenever one does print(circuit) it wraps horribly and you can't tell what's going on but if you just have the last line of the cell be circuit it uses a horizontal scrollbar and I can actually read it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to just circuit instead of print(circuit)

"for i, circuits_trial in enumerate(circuit_list):\n",
" for j, circuits_cycle in enumerate(circuits_trial):\n",
" for k, circuit_otoc in enumerate(circuits_cycle):\n",
" circuit_list[i][j][k] = cg.optimized_for_sycamore(circuit_otoc, optimizer_type=\"sqrt_iswap\")"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this takes longer than expected on my machine. maybe print('.', end='') just so there's some indication of progress

Copy link
Collaborator

Choose a reason for hiding this comment

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

this actually takes quite a long time. maybe we can throw multiprocessing at it or have a real progress bar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a progress bar. Compiling is kind of a hack around #189 - ideally I think the desired behavior is that each circuit already has the right gates and no compiling is necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok thanks for the additional information

@mpharrigan
Copy link
Collaborator

should we remove the example script in favor of this notebook?

@rmlarose
Copy link
Contributor Author

rmlarose commented Aug 9, 2021

Thanks @mpharrigan! Ready for round 2.

should we remove the example script in favor of this notebook?

Probably? There's nothing in the example script that isn't in the notebook.

@mpharrigan mpharrigan merged commit 843cefa into quantumlib:master Aug 9, 2021
@mpharrigan
Copy link
Collaborator

Thanks @rmlarose

If you want to remove the example script, we can do that in a follow-up PR!

madcpf pushed a commit to madcpf/ReCirq that referenced this pull request Sep 5, 2021
* Add tutorial + index.

* Add to toc.

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

Successfully merging this pull request may close these issues.

2 participants