Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Oct 9, 2023
1 parent 6fad4a7 commit 86e6a33
Showing 1 changed file with 30 additions and 39 deletions.
69 changes: 30 additions & 39 deletions docs/google/pyle_gates.ipynb → docs/google/internal_gates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"id": "dVkNQc0WSIwk"
},
"source": [
"# Pyle Gates in Cirq"
"# Google Internal Gates in Cirq"
]
},
{
Expand All @@ -48,39 +48,31 @@
"source": [
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://quantumai.google/cirq/google/pyle_gates>\"><img src=\"https://quantumai.google/site-assets/images/buttons/quantumai_logo_1x.png\" />View on QuantumAI</a>\n",
" <a target=\"_blank\" href=\"https://quantumai.google/cirq/google/internal_gates>\"><img src=\"https://quantumai.google/site-assets/images/buttons/quantumai_logo_1x.png\" />View on QuantumAI</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/quantumlib/Cirq/blob/master/docs/google/pyle_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/colab_logo_1x.png\" />Run in Google Colab</a>\n",
" <a target=\"_blank\" href=\"https://colab.research.google.com/github/quantumlib/Cirq/blob/master/docs/google/internal_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/colab_logo_1x.png\" />Run in Google Colab</a>\n",
" </td>\n",
" <td>\n",
" <a target=\"_blank\" href=\"https://github.com/quantumlib/Cirq/blob/master/docs/google/pyle_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/github_logo_1x.png\" />View source on GitHub</a>\n",
" <a target=\"_blank\" href=\"https://github.com/quantumlib/Cirq/blob/master/docs/google/internal_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/github_logo_1x.png\" />View source on GitHub</a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://storage.googleapis.com/tensorflow_docs/Cirq/docs/google/pyle_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/download_icon_1x.png\" />Download notebook</a>\n",
" <a href=\"https://storage.googleapis.com/tensorflow_docs/Cirq/docs/google/internal_gates.ipynb\"><img src=\"https://quantumai.google/site-assets/images/buttons/download_icon_1x.png\" />Download notebook</a>\n",
" </td>\n",
"</table>"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 5,
"metadata": {
"id": "bd9529db1c0b"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"installing cirq...\n",
"installed cirq.\n"
]
}
],
"outputs": [],
"source": [
"try:\n",
" import cirq\n",
" import cirq_google\n",
"except ImportError:\n",
" print(\"installing cirq...\")\n",
" !pip install --quiet cirq\n",
Expand All @@ -93,70 +85,70 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Pyle has a wealth of gates that don't exist or have equivalents in Cirq. `cirq_google.InternalGate` allows the creation of Cirq circuits that contain place holder operations that will get translated to the correct Pyle gate during the Cirq $\n",
"rightarrow$ Pyle conversion."
"Google has a wealth of gates implemented internally that don't exist or have equivalents in Cirq. `cirq_google.InternalGate` allows the creation of Cirq circuits that contain place holder operations that will get translated to the correct internal gate."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## InternalGate to PyleGate\n",
"Instances of [cirq_google.InternalGate](https://github.com/quantumlib/Cirq/blob/61d967112ba23cc839b0e922bd42878024a3e738/cirq-google/cirq_google/ops/internal_gate.py#L20) act as placeholder objects for pyle gates. During translation, the correct pyle gate is identified through the `gate_module` and `gate_name` properties. Then an instance of that gate is created using the `kwargs` arguments passed to the `InternalGate` constructor.\n",
"\n",
"**Note:** Currently translation is supported into subclasses of `PyleGate` only. "
"## InternalGate\n",
"Instances of [cirq_google.InternalGate](https://github.com/quantumlib/Cirq/blob/61d967112ba23cc839b0e922bd42878024a3e738/cirq-google/cirq_google/ops/internal_gate.py#L20) act as placeholder objects for google internal gates. During translation, the correct gate is identified through the `gate_module` and `gate_name` properties. Then an instance of that gate is created using the `kwargs` arguments passed to the `InternalGate` constructor."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"cirq_google.InternalGate(gate_name=\"CouplerDelayZ\", gate_module=\"pyle.cirqtools.pyle_gates\", num_qubits=2, delay=4.0, zpa=0, zpl=0)"
"cirq_google.InternalGate(gate_name=\"GATE_NAMPE\", gate_module=\"GATE_MODULE\", num_qubits=2, )"
]
},
"execution_count": 2,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"coupler = cirq_google.InternalGate(\n",
" gate_module='pyle.cirqtools.pyle_gates', # Module of class. \n",
" gate_name='CouplerDelayZ', # Class name.\n",
"internal_gate_args = {\n",
" # Arguments to be passed to the constructor of the internal gate.\n",
"}\n",
"internal_gate = cirq_google.InternalGate(\n",
" gate_module='GATE_MODULE', # Module of class. \n",
" gate_name='GATE_NAMPE', # Class name.\n",
" num_qubits=2, # Number of qubits that the gate acts on.\n",
" delay=4.0, zpa=0, zpl=0) # Arguments to pass to the constructor of pyle.cirqtools.pyle_gates.CouplerDelayZ\n",
"coupler"
" **internal_gate_args)\n",
"internal_gate"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"overflow: auto; white-space: pre;\">0: ───pyle.cirqtools.pyle_gates.CouplerDelayZ(delay=4.0, zpa=0, zpl=0)───\n",
"<pre style=\"overflow: auto; white-space: pre;\">0: ───GATE_MODULE.GATE_NAMPE()───\n",
"\n",
"1: ───#2─────────────────────────────────────────────────────────────────</pre>"
"1: ───#2─────────────────────────</pre>"
],
"text/plain": [
"0: ───pyle.cirqtools.pyle_gates.CouplerDelayZ(delay=4.0, zpa=0, zpl=0)───\n",
"0: ───GATE_MODULE.GATE_NAMPE()───\n",
"\n",
"1: ───#2─────────────────────────────────────────────────────────────────"
"1: ───#2─────────────────────────"
]
},
"execution_count": 3,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cirq.Circuit(coupler(*cirq.LineQubit.range(2)))"
"cirq.Circuit(internal_gate(*cirq.LineQubit.range(2)))"
]
},
{
Expand All @@ -166,8 +158,7 @@
"## Notes\n",
"1. InternalGate is serializable.\n",
"1. Values of `kwargs` must be serializable as [api.v2.ArgValue](https://github.com/quantumlib/Cirq/blob/61d967112ba23cc839b0e922bd42878024a3e738/cirq-google/cirq_google/api/v2/program.proto#L281)\n",
"1. If a value is not serializable as `api.v2.ArgValue` (e.g. a value with unit) then the translator will need to updated to know what to do for that gate. \n",
" For example for the delay `delay` parameter of `CouplerDelayZ`, the translator will expect a float which it will convert into nanoseconds (i.e. the coupler created above has `delay=4ns`). "
"1. If a value is not serializable as `api.v2.ArgValue` (e.g. a value with unit) then the translator will need to updated to know what to do for that gate."
]
}
],
Expand Down

0 comments on commit 86e6a33

Please sign in to comment.