-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
407 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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,168 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "bbc3afcf", | ||
"metadata": { | ||
"cq.autogen": "title_cell" | ||
}, | ||
"source": [ | ||
"# Rz Rotation via Phase Gradient" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e6ca3000", | ||
"metadata": { | ||
"cq.autogen": "top_imports" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register\n", | ||
"from qualtran import QBit, QInt, QUInt, QAny\n", | ||
"from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma\n", | ||
"from typing import *\n", | ||
"import numpy as np\n", | ||
"import sympy\n", | ||
"import cirq" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4d0db53e", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.bloq_doc.md" | ||
}, | ||
"source": [ | ||
"## `RzViaPhaseGradient`\n", | ||
"Apply a controlled-Rz using a phase gradient state.\n", | ||
"\n", | ||
"Implements the following unitary action:\n", | ||
"\n", | ||
"$$\n", | ||
" |\\psi\\rangle \\otimes |x\\rangle \\mapsto \\text{Rz}(4 \\pi x) |\\psi\\rangle \\otimes |x\\rangle\n", | ||
"$$\n", | ||
"\n", | ||
"for every state $|\\psi\\rangle$ and every $x$, or equivalently\n", | ||
"\n", | ||
"$$\n", | ||
" |b\\rangle|x\\rangle \\mapsto |b\\rangle e^{- (-1)^b i x/2} |x\\rangle\n", | ||
"$$\n", | ||
"\n", | ||
"for every $b \\in \\{0, 1\\}$ and every $x$.\n", | ||
"\n", | ||
"To apply an $\\text{Rz}(\\theta) = e^{-i Z \\theta/2}$, the angle register $x$ should store $\\theta/(4\\pi)$.\n", | ||
"\n", | ||
"#### Parameters\n", | ||
" - `angle_dtype`: Data type for the `angle_data` register.\n", | ||
" - `phasegrad_dtype`: Data type for the phase gradient register. \n", | ||
"\n", | ||
"#### Registers\n", | ||
" - `q`: The qubit to apply Rz on.\n", | ||
" - `angle`: The rotation angle in radians.\n", | ||
" - `phase_grad`: The phase gradient register of sufficient width. \n", | ||
"\n", | ||
"#### References\n", | ||
" - [Compilation of Fault-Tolerant Quantum Heuristics for Combinatorial Optimization](https://arxiv.org/abs/2007.07391). Section II-C: Oracles for phasing by cost function. Appendix A: Addition for controlled rotations.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "88ae8ba0", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.bloq_doc.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.bloqs.rotations import RzViaPhaseGradient" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "f3d5ab59", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.example_instances.md" | ||
}, | ||
"source": [ | ||
"### Example Instances" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "16a874c9", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.rz_via_phase_gradient" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran import QFxp\n", | ||
"\n", | ||
"rz_via_phase_gradient = RzViaPhaseGradient(angle_dtype=QFxp(4, 4), phasegrad_dtype=QFxp(4, 4))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ca4ac4bc", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.graphical_signature.md" | ||
}, | ||
"source": [ | ||
"#### Graphical Signature" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "92d7b03c", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.graphical_signature.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.drawing import show_bloqs\n", | ||
"show_bloqs([rz_via_phase_gradient],\n", | ||
" ['`rz_via_phase_gradient`'])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "03999011", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.call_graph.md" | ||
}, | ||
"source": [ | ||
"### Call Graph" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d0cc79d3", | ||
"metadata": { | ||
"cq.autogen": "RzViaPhaseGradient.call_graph.py" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from qualtran.resource_counting.generalizers import ignore_split_join\n", | ||
"rz_via_phase_gradient_g, rz_via_phase_gradient_sigma = rz_via_phase_gradient.call_graph(max_depth=1, generalizer=ignore_split_join)\n", | ||
"show_call_graph(rz_via_phase_gradient_g)\n", | ||
"show_counts_sigma(rz_via_phase_gradient_sigma)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.