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

CYGate #1115

Merged
merged 5 commits into from
Jul 19, 2024
Merged

CYGate #1115

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
8 changes: 8 additions & 0 deletions dev_tools/autogenerate-bloqs-notebooks-v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,14 @@
module=qualtran.bloqs.basic_gates.s_gate,
bloq_specs=[qualtran.bloqs.basic_gates.s_gate._S_GATE_DOC],
),
NotebookSpecV2(
title='Y Gate',
module=qualtran.bloqs.basic_gates.y_gate,
bloq_specs=[
qualtran.bloqs.basic_gates.y_gate._Y_GATE_DOC,
qualtran.bloqs.basic_gates.y_gate._CY_GATE_DOC,
],
),
NotebookSpecV2(
title='And',
module=qualtran.bloqs.mcmt.and_bloq,
Expand Down
1 change: 1 addition & 0 deletions docs/bloqs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Bloqs Library
basic_gates/hadamard.ipynb
basic_gates/cnot.ipynb
basic_gates/s_gate.ipynb
basic_gates/y_gate.ipynb
mcmt/and_bloq.ipynb
basic_gates/states_and_effects.ipynb
swap_network/swap_network.ipynb
Expand Down
2 changes: 1 addition & 1 deletion qualtran/bloqs/basic_gates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
from .t_gate import TGate
from .toffoli import Toffoli
from .x_basis import MinusEffect, MinusState, PlusEffect, PlusState, XGate
from .y_gate import YGate
from .y_gate import CYGate, YGate
from .z_basis import IntEffect, IntState, OneEffect, OneState, ZeroEffect, ZeroState, ZGate
221 changes: 221 additions & 0 deletions qualtran/bloqs/basic_gates/y_gate.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1f6baa88",
"metadata": {
"cq.autogen": "title_cell"
},
"source": [
"# Y Gate"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a4dd57f4",
"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": "39518f37",
"metadata": {
"cq.autogen": "YGate.bloq_doc.md"
},
"source": [
"## `YGate`\n",
"The Pauli Y gate.\n",
"\n",
"This causes a bit flip (with a complex phase): Y|0> = 1j|1>, Y|1> = -1j|0>\n",
"\n",
"#### Registers\n",
" - `q`: The qubit.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f9aa8e7",
"metadata": {
"cq.autogen": "YGate.bloq_doc.py"
},
"outputs": [],
"source": [
"from qualtran.bloqs.basic_gates import YGate"
]
},
{
"cell_type": "markdown",
"id": "f1dae24e",
"metadata": {
"cq.autogen": "YGate.example_instances.md"
},
"source": [
"### Example Instances"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c3a5a18",
"metadata": {
"cq.autogen": "YGate.y_gate"
},
"outputs": [],
"source": [
"y_gate = YGate()"
]
},
{
"cell_type": "markdown",
"id": "0bcd3fda",
"metadata": {
"cq.autogen": "YGate.graphical_signature.md"
},
"source": [
"#### Graphical Signature"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c5d7345",
"metadata": {
"cq.autogen": "YGate.graphical_signature.py"
},
"outputs": [],
"source": [
"from qualtran.drawing import show_bloqs\n",
"show_bloqs([y_gate],\n",
" ['`y_gate`'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7a1ba7bf-de51-496d-b637-9db51ed40cce",
"metadata": {},
"outputs": [],
"source": [
"show_bloq(y_gate, 'musical_score')"
]
},
{
"cell_type": "markdown",
"id": "5f68305f",
"metadata": {
"cq.autogen": "CYGate.bloq_doc.md"
},
"source": [
"## `CYGate`\n",
"A controlled Y gate.\n",
"\n",
"#### Registers\n",
" - `ctrl`: The control qubit.\n",
" - `q`: The target qubit.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8fa440cd",
"metadata": {
"cq.autogen": "CYGate.bloq_doc.py"
},
"outputs": [],
"source": [
"from qualtran.bloqs.basic_gates import CYGate"
]
},
{
"cell_type": "markdown",
"id": "6cd4b475",
"metadata": {
"cq.autogen": "CYGate.example_instances.md"
},
"source": [
"### Example Instances"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fb197f4d",
"metadata": {
"cq.autogen": "CYGate.cy_gate"
},
"outputs": [],
"source": [
"cy_gate = YGate().controlled()\n",
"assert isinstance(cy_gate, CYGate)"
]
},
{
"cell_type": "markdown",
"id": "61fdd296",
"metadata": {
"cq.autogen": "CYGate.graphical_signature.md"
},
"source": [
"#### Graphical Signature"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad2d7347",
"metadata": {
"cq.autogen": "CYGate.graphical_signature.py"
},
"outputs": [],
"source": [
"from qualtran.drawing import show_bloqs\n",
"show_bloqs([cy_gate],\n",
" ['`cy_gate`'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4242fd0b-17a0-48ad-bae9-ec146c65d810",
"metadata": {},
"outputs": [],
"source": [
"show_bloq(cy_gate, 'musical_score')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading
Loading