-
Notifications
You must be signed in to change notification settings - Fork 125
Add Circuit Generation Notebook for Discrete Time Crystal Experiments #251
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
Merged
mpharrigan
merged 19 commits into
quantumlib:master
from
augustehirth:time_crystal_circuit_generation
Aug 23, 2022
+160
−0
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f93cd08
Add Tasks for Discrete Time Crystal Experiments
augustehirth 08ef8a7
Fix import and dataclass decorators
augustehirth e5d91c7
Full removal of tasks and dataclasses
augustehirth bd8cf76
Run `black` python formatter
augustehirth edee86b
Improve docstring attribute descriptions
augustehirth 924ec20
fix 2021 copyright to 2022
augustehirth 20304c1
Add docstring newlines, add Iterator import
augustehirth 4074275
Updated test cases
augustehirth 5897f26
Fix parameter descriptions
augustehirth 2873a73
Add DTC simulation utilities for for experiments
augustehirth 9234092
Copyright addition, add type hints
augustehirth 0c27222
Merge remote-tracking branch 'mainrepo/master' into time_crystal_util…
augustehirth 67d9b31
Fix imports broken in merge
augustehirth e38c475
Add circuit generation notebook
augustehirth 066d5dc
Corrections: terminology and technical correctness
augustehirth 2f45ee7
Merge branch 'master' into time_crystal_circuit_generation
augustehirth c59a240
Improve explanations a bit
augustehirth 6eca0a5
Remove old dtcsimulation file (now dtc_simulation)
augustehirth fdf7c0e
Feedback fixes
augustehirth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
docs/time_crystals/time_crystal_circuit_generation.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| { | ||
| "cells": [ | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "id": "10a61b4d73a5" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# Copyright 2022 Google\n", | ||
| "#\n", | ||
| "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", | ||
| "# you may not use this file except in compliance with the License.\n", | ||
| "# You may obtain a copy of the License at\n", | ||
| "#\n", | ||
| "# https://www.apache.org/licenses/LICENSE-2.0\n", | ||
| "#\n", | ||
| "# Unless required by applicable law or agreed to in writing, software\n", | ||
| "# distributed under the License is distributed on an \"AS IS\" BASIS,\n", | ||
| "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", | ||
| "# See the License for the specific language governing permissions and\n", | ||
| "# limitations under the License." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": { | ||
| "id": "7763e5d20492" | ||
| }, | ||
| "source": [ | ||
| "# Time Crystal Circuit Generation\n", | ||
| "This notebook covers how Many Body Local Discrete Time Crystal circuit lists are created, from the paper: Observation of Time-Crystalline Eigenstate Order on a Quantum Processor ([Nature](https://www.nature.com/articles/s41586-021-04257-w)). \n", | ||
| "\n", | ||
| "Quantum computers and gate-based quantum circuits turn out to be well suited for crafting systems that exhibit time-crystalline behavior. Behavior is crystalline with respect to time if it has some consistent and stable pattern over time. This system's pattern must be resilient against perturbation in the same way that a space-crystalline object, like a diamond, maintains its structure (is still a diamond) if moved or heated. \n", | ||
| "\n", | ||
| "The quantum computer supplies a system of many qubits, locally connected to each other in a chain. A many-body local (MBL) system like this is critical for the existence of a time crystal. Without an MBL system, it is expected that the system's state would decay into a maximum entropy state that is incompatible with the goal of stable and consistent time structure. \n", | ||
| "\n", | ||
| "The time-crystalline behavior that the discrete time crystal (DTC) circuits demonstrate is perhaps the simplest kind of time-structured behavior, oscillation. Each circuit is built with some number of identical $U$-cycles. Time is represented by a circuit list where each circuit is ordered with increasingly many $U$-cycles; each cycle is considered a discrete time step. The eventual effect of these $U$-cycles is consistent oscillations of each qubits' polarizations. The experiments performed demonstrate that this time-crystalline oscillation behavior is stable in spite of different initial states and introduced random potentials. " | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": { | ||
| "id": "f53722cb0850" | ||
| }, | ||
| "source": [ | ||
| "## Setup" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "id": "0e4595827ec0" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "!pip install cirq --quiet\n", | ||
| "try:\n", | ||
| " import recirq\n", | ||
| "except ImportError:\n", | ||
| " !pip install --quiet git+https://github.com/quantumlib/ReCirq" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "id": "e5e4f66e8e67" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import cirq\n", | ||
| "import recirq.time_crystals as time_crystals" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": { | ||
| "id": "a12b700f009e" | ||
| }, | ||
| "source": [ | ||
| "## Circuit Construction\n", | ||
| "Each DTC circuit is created with symbolic parameters. Parameter values are supplied near run/simulation time with a `cirq.ParamResolver`, which means the circuit list needs to be generated only once for potentially many different experimental parameter configurations. \n", | ||
| "\n", | ||
| "The code below uses an IPython-specific utility to inspect the code of the key function that creates the symbolic circuit list, `recirq.time_crystals.symbolic_dtc_circuit_list()`. " | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "id": "c0f1c1475908" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "import inspect\n", | ||
| "from IPython.display import Code\n", | ||
| "\n", | ||
| "Code(inspect.getsource(time_crystals.symbolic_dtc_circuit_list), language=\"python\")" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": { | ||
| "id": "e13de6da1fc6" | ||
| }, | ||
| "source": [ | ||
| "The construction of each circuit is surprisingly succinct. \n", | ||
| "\n", | ||
| "The circuit expects the quantum computer to be in the all-zeros state, and starts with a sequence of `cirq.Y` gates conditioned on the provided `initial state` parameter, after initializing the necessary symbolic variables. \n", | ||
| "\n", | ||
| "Each $U$-cycle consists of three moments. First, a moment of `cirq.PhasedXZGate`s, with one for each qubit. Each `cirq.PhasedXZGate` takes the control parameter `g` as its X-exponent, and the random potentials necessary for many-body localization provided by `local_fields` for its Y-exponent.\n", | ||
| "\n", | ||
| "The second and third moments together both cause the oscillation behavior and compensate for the first disorder moment. The qubits are connected in a chain, and each qubit pair connection in that chain is coupled with a `cirq.PhasedFSimGate` that uses the parameters `[theta, zetas, chi, gamma, phi]`. To keep gates from overlapping on the same qubit, this chain of gates is split into the second and third moments, such that no two gates share a qubit within each moment. \n", | ||
| "\n", | ||
| "Finally, `symbolic_dtc_circuit_list()` builds and returns a list of circuits with $0,1,2,..., cycles$ many $U$-cycles in them. " | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "metadata": { | ||
| "id": "8397a5eab5f7" | ||
| }, | ||
| "outputs": [], | ||
| "source": [ | ||
| "qubits = [cirq.GridQubit(0, i) for i in range(4)]\n", | ||
| "circuit_list = time_crystals.symbolic_dtc_circuit_list(qubits, 2)\n", | ||
| "for circuit in circuit_list:\n", | ||
| " print(\"\\ncircuit of length \" + str(len(circuit)) + \"\\n\")\n", | ||
| " print(circuit)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "metadata": { | ||
| "id": "3ba0e882df83" | ||
| }, | ||
| "source": [ | ||
| "After the initial line of `cirq.Y` gates, each consecutive circuit in the list has an additional cycle of `cirq.PhasedXZGate`s, followed by the chain of `cirq.PhasedFSimGate`s on alternating qubit pairs. Each cycle of three moments becomes one time step in the later analysis of stable oscillations over time. \n", | ||
| "\n", | ||
| "The next step is to perform experiments to collect evidence of the time-crystalline behavior of the quantum state's polarizations. See the [Time Crystal Data Collection](time_crystal_data_collection) notebook for the experiments, and the [Time Crystal Data Analysis](time_crystal_data_analysis) notebook for the graphed data and results. " | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
| "colab": { | ||
| "name": "time_crystal_circuit_generation.ipynb", | ||
| "toc_visible": true | ||
| }, | ||
| "kernelspec": { | ||
| "display_name": "Python 3", | ||
| "name": "python3" | ||
| } | ||
| }, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 0 | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This seems weird to me that we are printing out the code as an output of the colab. I'll leave the decision up to you if you stil think this way is clearer, but I would consider linking to the source code with text such as "The code, which can be viewed here (link) is surprisingly succinct."
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.
My intent with printing the code was to provide a detailed example of how the circuits are constructed. Perhaps a couple step-by-step examples of each moment for a circuit of a few qubits would be a better example. I'll try this and see how it looks.
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 it's kinda neat 🤷