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

Deprecate MultiControlPauli #1492

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qualtran/bloqs/mcmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
from qualtran.bloqs.mcmt.and_bloq import And, MultiAnd
from qualtran.bloqs.mcmt.controlled_via_and import ControlledViaAnd
from qualtran.bloqs.mcmt.ctrl_spec_and import CtrlSpecAnd
from qualtran.bloqs.mcmt.multi_control_pauli import MultiControlPauli, MultiControlX, MultiControlZ
from qualtran.bloqs.mcmt.multi_control_pauli import MultiControlX, MultiControlZ
from qualtran.bloqs.mcmt.multi_target_cnot import MultiTargetCNOT
106 changes: 43 additions & 63 deletions qualtran/bloqs/mcmt/multi_control_multi_target_pauli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "5c75973b",
"id": "8533d106",
"metadata": {
"cq.autogen": "title_cell"
},
Expand All @@ -13,7 +13,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c0d3d2b2",
"id": "b5831fa4",
"metadata": {
"cq.autogen": "top_imports"
},
Expand All @@ -30,7 +30,7 @@
},
{
"cell_type": "markdown",
"id": "ac237fd0",
"id": "b85b5ac2",
"metadata": {
"cq.autogen": "MultiTargetCNOT.bloq_doc.md"
},
Expand All @@ -48,7 +48,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a9e53831",
"id": "387c77c3",
"metadata": {
"cq.autogen": "MultiTargetCNOT.bloq_doc.py"
},
Expand All @@ -59,7 +59,7 @@
},
{
"cell_type": "markdown",
"id": "70036306",
"id": "cb66ffb6",
"metadata": {
"cq.autogen": "MultiTargetCNOT.example_instances.md"
},
Expand All @@ -70,7 +70,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "40a9ec07",
"id": "e4d9154a",
"metadata": {
"cq.autogen": "MultiTargetCNOT.c_multi_not_symb"
},
Expand All @@ -83,7 +83,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ecddf931",
"id": "ca47c43a",
"metadata": {
"cq.autogen": "MultiTargetCNOT.c_multi_not"
},
Expand All @@ -94,7 +94,7 @@
},
{
"cell_type": "markdown",
"id": "251ca68a",
"id": "a44ef0b1",
"metadata": {
"cq.autogen": "MultiTargetCNOT.graphical_signature.md"
},
Expand All @@ -105,7 +105,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bff75a03",
"id": "baafd2bf",
"metadata": {
"cq.autogen": "MultiTargetCNOT.graphical_signature.py"
},
Expand All @@ -118,7 +118,7 @@
},
{
"cell_type": "markdown",
"id": "bd425677",
"id": "60bc96ef",
"metadata": {
"cq.autogen": "MultiTargetCNOT.call_graph.md"
},
Expand All @@ -129,7 +129,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a0082f8f",
"id": "59e8162e",
"metadata": {
"cq.autogen": "MultiTargetCNOT.call_graph.py"
},
Expand All @@ -141,57 +141,46 @@
"show_counts_sigma(c_multi_not_symb_sigma)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5457e35b",
"metadata": {},
"outputs": [],
"source": [
"from qualtran.drawing import get_musical_score_data, draw_musical_score\n",
"\n",
"draw_musical_score(get_musical_score_data(c_multi_not.decompose_bloq()))"
]
},
{
"cell_type": "markdown",
"id": "aba024ec",
"id": "2de64cfb",
"metadata": {
"cq.autogen": "MultiControlPauli.bloq_doc.md"
"cq.autogen": "MultiControlX.bloq_doc.md"
},
"source": [
"## `MultiControlPauli`\n",
"Implements multi-control, single-target C^{n}P gate.\n",
"## `MultiControlX`\n",
"Implements multi-control, single-target X gate.\n",
"\n",
"Implements $C^{n}P = (1 - |1^{n}><1^{n}|) I + |1^{n}><1^{n}| P^{n}$ using $n-1$\n",
"clean ancillas using a multi-controlled `AND` gate. Uses the Toffoli ladder\n",
"construction described in \"n−2 Ancilla Bits\" section of Ref[1] but uses an\n",
"$\\text{AND} / \\text{AND}^\\dagger$ ladder instead for computing / uncomputing\n",
"using clean ancillas instead of the Toffoli ladder. The measurement based\n",
"uncomputation of $\\text{AND}$ does not consume any magic states and thus has\n",
"better constant factors.\n",
"Reduces multiple controls to a single control using an `And` ladder.\n",
"See class `ControlledViaAnd` for details on construction.\n",
"\n",
"#### References\n",
" - [Constructing Large Controlled Nots](https://algassert.com/circuits/2015/06/05/Constructing-Large-Controlled-Nots.html). \n"
"Alternatively, one can directly use `XGate().controlled(CtrlSpec(cvs=cvs))`\n",
"\n",
"#### Parameters\n",
" - `cvs`: a tuple of `n` control bits, or a `HasLength(n)` to control by `n` 1s. \n",
"\n",
"#### Registers\n",
" - `controls`: control register of type `QBit` and shape `(n,)`.\n",
" - `target`: single qubit target register.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bf4f6c5a",
"id": "9b43be2a",
"metadata": {
"cq.autogen": "MultiControlPauli.bloq_doc.py"
"cq.autogen": "MultiControlX.bloq_doc.py"
},
"outputs": [],
"source": [
"from qualtran.bloqs.mcmt import MultiControlPauli"
"from qualtran.bloqs.mcmt import MultiControlX"
]
},
{
"cell_type": "markdown",
"id": "a3deef58",
"id": "f9fbb578",
"metadata": {
"cq.autogen": "MultiControlPauli.example_instances.md"
"cq.autogen": "MultiControlX.example_instances.md"
},
"source": [
"### Example Instances"
Expand All @@ -200,20 +189,20 @@
{
"cell_type": "code",
"execution_count": null,
"id": "610dfdf5",
"id": "050b0f8d",
"metadata": {
"cq.autogen": "MultiControlPauli.ccpauli"
"cq.autogen": "MultiControlX.ccpauli"
},
"outputs": [],
"source": [
"ccpauli = MultiControlPauli(cvs=(1, 0, 1, 0, 1), target_gate=cirq.X)"
"ccpauli = MultiControlX(cvs=(1, 0, 1, 0, 1))"
]
},
{
"cell_type": "markdown",
"id": "29045880",
"id": "ccf7ef61",
"metadata": {
"cq.autogen": "MultiControlPauli.graphical_signature.md"
"cq.autogen": "MultiControlX.graphical_signature.md"
},
"source": [
"#### Graphical Signature"
Expand All @@ -222,9 +211,9 @@
{
"cell_type": "code",
"execution_count": null,
"id": "df830018",
"id": "4fb51559",
"metadata": {
"cq.autogen": "MultiControlPauli.graphical_signature.py"
"cq.autogen": "MultiControlX.graphical_signature.py"
},
"outputs": [],
"source": [
Expand All @@ -235,9 +224,9 @@
},
{
"cell_type": "markdown",
"id": "6849b86b",
"id": "358ff8ae",
"metadata": {
"cq.autogen": "MultiControlPauli.call_graph.md"
"cq.autogen": "MultiControlX.call_graph.md"
},
"source": [
"### Call Graph"
Expand All @@ -246,9 +235,9 @@
{
"cell_type": "code",
"execution_count": null,
"id": "dd1f8a53",
"id": "216d9bdf",
"metadata": {
"cq.autogen": "MultiControlPauli.call_graph.py"
"cq.autogen": "MultiControlX.call_graph.py"
},
"outputs": [],
"source": [
Expand All @@ -261,21 +250,12 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"name": "python"
}
},
"nbformat": 4,
Expand Down
Loading