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

📝 Documentation for Search Space Limitation Feature #280

Closed
wants to merge 10 commits into from
126 changes: 126 additions & 0 deletions docs/source/LimitingSearchSpace.ipynb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new file is linked nowhere in the documentation. As such, it is not accessible in the documentation.

Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# Limiting the Search Space\n",
"\n",
"Many quantum computing architectures limit the pairs of qubits that two-qubit operations can be applied to.\n",
"This is commonly described by a device's *coupling map*.\n",
"To further speed up the mapping process, there are several ways to limit the pairs of qubits that need to be considered, in ways of limiting the whole search space for the exact mapping problem.\n",
"\n",
"Consider the following circuit."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from qiskit import QuantumCircuit\n",
"\n",
"qc = QuantumCircuit(4)\n",
"qc.h(0)\n",
"qc.cx(0, 1)\n",
"qc.cx(0, 2)\n",
"qc.cx(0, 3)\n",
"\n",
"qc.barrier()\n",
"\n",
"qc.t(0)\n",
"qc.t(1)\n",
"qc.t(2)\n",
"qc.t(3)\n",
"\n",
"qc.barrier()\n",
"\n",
"qc.cx(0, 3)\n",
"qc.cx(0, 2)\n",
"qc.cx(0, 1)\n",
"\n",
"qc.measure_all()\n",
"\n",
"qc.draw(output=\"mpl\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"Now assume this circuit shall be mapped to a $4$-qubit architecture defined by the following coupling map:\n",
"\n",
"![Linear 4-qubit Architecture](images/linear_arch.svg)\n",
"\n",
"In *QMAP* this architecture can be manually defined as described in the Mapping section.\n",
"\n",
Comment on lines +10 to +59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is, more or less, duplicate code from the Mapping notebook.
This page should provide some context on the search space limitation, what the implications are, etc.
It should at least cover both methods from the paper and contrast them against the non-limited version. Should be fairly easy to show the runtime difference on some small examples.
Most importantly, I would have imagined an example circuit and/or architecture, where a real difference can be seen for the different approaches.

Furthermore, it would make sense to reference the paper near the top of this page to set the scene for what's to come.

"Instead we look now at the cayley graph, especially the reduced cayley graph that can be generated from the series of swaps possible on an architecture.\n",
"\n",
"![Reduced Cayley graph](images/cayley.png)\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image has not been added to the repository. Furthermore, please use vector graphics wherever possible.
The original file is a PDF anyway. So that should be straight-forward.

This tutorial-like page should also contain the original un-limited Cayley graph. I believe you could just replicate the example from the paper (with some minor modifications).

"\n",
"Instead of considering all possible SWAP-configurations in the Cayley, only those that are not greyed out need to be considered. \n",
"\n",
"Using the search space limitations is as simple as:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from mqt import qmap\n",
"\n",
"arch = qmap.Architecture(\n",
" 4,\n",
" {\n",
" (0, 1),\n",
" (1, 0),\n",
" (1, 2),\n",
" (2, 1),\n",
" (2, 3),\n",
" (3, 2),\n",
" },\n",
")\n",
"qc_mapped, res = qmap.compile(\n",
" qc, arch, method=\"exact\", post_mapping_optimizations=False, swap_reduction=\"coupling_limit\"\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be mentioned somewhere, that this is actually the default setting being used (since it is guaranteed to preserve optimality).

")\n",
"\n",
"qc_mapped.draw(output=\"mpl\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"This limits the number of SWAPs based on the selected subgraph of the architecture.\n",
"\n",
"Check out the [reference documentation](library/Mapping.rst) for more information."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected that link to point to the SwapReduction settings reference documentation and not the general mapper page.

]
}
],
"metadata": {
"kernelspec": {
"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"
}
},
"nbformat": 4,
"nbformat_minor": 0
}