Skip to content

Commit

Permalink
Merge pull request #2 from daehiff/pauli_integration
Browse files Browse the repository at this point in the history
Pauli integration
  • Loading branch information
daehiff authored May 31, 2023
2 parents 06c0178 + b56272e commit 7053599
Show file tree
Hide file tree
Showing 21 changed files with 1,952 additions and 100 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ dmypy.json

.vscode
.DS_Store

20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Python 3.9 image as the base image
FROM python:3.9

# Set the working directory in the container
WORKDIR /app

# Copy the requirements to the container
COPY ./requirements.txt .

# Install the Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the source code to the container
COPY . .

# Install pauliopt
RUN python setup.py install

# Execute all the unit tests in the ./tests folder
CMD ["python", "-m", "unittest", "discover", "-s", "./tests/", "-p", "test_*.py"]
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,12 @@ pip install --upgrade pauliopt
**Step 4.** Run a few iterations of simulated annealing and look at the simplified circuit.

<img src="readme-example-4.png" width="800" title="Annealing.">

## Unit tests


To run the unit tests, install the additional requirements using our `requirements.txt` (recommended python: 3.9), then to launch then, run:

```bash
python -m unittest discover -s ./tests/ -p "test_*.py"
```
81 changes: 73 additions & 8 deletions notebooks/2. Circuits of Phase Gadgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Current working directory: C:\\Users\\Stefa\\Documents\\git\\pauliopt\n"
"Current working directory: /Users/davidwinderl/Documents/Workspaces/Workspace/pauliopt\n"
]
}
],
Expand Down Expand Up @@ -70,7 +70,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"<ipython-input-2-f5d723bf6ff2>:4: DeprecationWarning: `set_matplotlib_formats` is deprecated since IPython 7.23, directly use `matplotlib_inline.backend_inline.set_matplotlib_formats()`\n",
"/var/folders/gx/p4btzntx3q93kpwt35k29yvr0000gn/T/ipykernel_5769/4084885951.py:4: DeprecationWarning: `set_matplotlib_formats` is deprecated since IPython 7.23, directly use `matplotlib_inline.backend_inline.set_matplotlib_formats()`\n",
" set_matplotlib_formats('svg')\n"
]
}
Expand Down Expand Up @@ -210,7 +210,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"hash(gadget) = 624374175457367365\n",
"hash(gadget) = 1441341330045463407\n",
"(gadget == same_gadget) = True\n",
"(gadget == other_gadget) = False\n"
]
Expand Down Expand Up @@ -291,9 +291,73 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"image/svg+xml": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
"<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"704\" height=\"140\"><path fill=\"none\" stroke=\"black\" d=\"M 42, 50 L 662, 50\"/>\n",
"<text x=\"0\" y=\"54\" font-size=\"16\">0</text>\n",
"<text x=\"670\" y=\"54\" font-size=\"16\">0</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 42, 80 L 662, 80\"/>\n",
"<text x=\"0\" y=\"84\" font-size=\"16\">1</text>\n",
"<text x=\"670\" y=\"84\" font-size=\"16\">1</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 42, 110 L 662, 110\"/>\n",
"<text x=\"0\" y=\"114\" font-size=\"16\">2</text>\n",
"<text x=\"670\" y=\"114\" font-size=\"16\">2</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 82, 50 L 112, 35\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 82, 80 L 112, 35\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"82\" cy=\"50\" r=\"8\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"82\" cy=\"80\" r=\"8\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 112, 35 L 142, 35\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"112\" cy=\"35\" r=\"8\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"142\" cy=\"35\" r=\"8\"/>\n",
"<text x=\"158\" y=\"39\" font-size=\"16\">π/2</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 202, 50 L 232, 35\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 202, 110 L 232, 35\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"202\" cy=\"50\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"202\" cy=\"110\" r=\"8\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 232, 35 L 262, 35\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"232\" cy=\"35\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"262\" cy=\"35\" r=\"8\"/>\n",
"<text x=\"278\" y=\"39\" font-size=\"16\">π</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 322, 80 L 352, 65\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 322, 110 L 352, 65\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"322\" cy=\"80\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"322\" cy=\"110\" r=\"8\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 352, 65 L 382, 65\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"352\" cy=\"65\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"382\" cy=\"65\" r=\"8\"/>\n",
"<text x=\"398\" y=\"69\" font-size=\"16\">7π/4</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 442, 50 L 472, 35\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 442, 110 L 472, 35\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"442\" cy=\"50\" r=\"8\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"442\" cy=\"110\" r=\"8\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 472, 35 L 502, 35\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"472\" cy=\"35\" r=\"8\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"502\" cy=\"35\" r=\"8\"/>\n",
"<text x=\"518\" y=\"39\" font-size=\"16\">π/4</text>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 562, 50 L 592, 35\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 562, 80 L 592, 35\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"562\" cy=\"50\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"562\" cy=\"80\" r=\"8\"/>\n",
"<path fill=\"none\" stroke=\"black\" d=\"M 592, 35 L 622, 35\"/>\n",
"<circle fill=\"#CCFFCC\" stroke=\"black\" cx=\"592\" cy=\"35\" r=\"8\"/>\n",
"<circle fill=\"#FF8888\" stroke=\"black\" cx=\"622\" cy=\"35\" r=\"8\"/>\n",
"<text x=\"638\" y=\"39\" font-size=\"16\">π/2</text>\n",
"</svg>"
],
"text/plain": [
"<pauliopt.phase.phase_circuits.PhaseCircuit at 0x7fe4e3773d60>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from pauliopt.phase import PhaseCircuit\n",
"gadgets = [\n",
Expand All @@ -303,7 +367,8 @@
" Z(pi/4) @ {0, 2},\n",
" X(pi/2) @ {0, 1},\n",
"]\n",
"phase_circuit = PhaseCircuit(3, gadgets)"
"phase_circuit = PhaseCircuit(3, gadgets)\n",
"display(phase_circuit)"
]
},
{
Expand Down Expand Up @@ -1582,7 +1647,7 @@
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1596,7 +1661,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
4 changes: 2 additions & 2 deletions notebooks/4. Phase Circuit Optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13401,7 +13401,7 @@
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -13415,7 +13415,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.16"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 7053599

Please sign in to comment.