Skip to content

Updating synthesis tutorial to include some visualization features #1039

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@
},
"outputs": [],
"source": [
"from classiq import *\n",
"from classiq import (\n",
" Constraints,\n",
" OptimizationParameter,\n",
" Output,\n",
" QNum,\n",
" allocate,\n",
" hadamard_transform,\n",
" qfunc,\n",
" show,\n",
" synthesize,\n",
")\n",
"\n",
"\n",
"@qfunc\n",
Expand Down Expand Up @@ -79,7 +89,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2twaSBItXmQT3lgsNKPOCSzYedO?version=0.70.0\n"
"Quantum program link: https://platform.classiq.io/circuit/2yHwgkWygipwYKH1a6n9kIugTmX?login=True&version=0.82.1\n"
]
}
],
Expand Down Expand Up @@ -150,7 +160,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Opening: https://platform.classiq.io/circuit/2twaSjGvvXFX7TCHomoiGKVTHPt?version=0.70.0\n"
"Quantum program link: https://platform.classiq.io/circuit/2yHwhU3Tiy92rpab2DZ0jFRu70p?login=True&version=0.82.1\n"
]
}
],
Expand All @@ -165,6 +175,36 @@
"The new depth and width are 47 and 9, respectively. As expected, we \"pay\" with extra depth for an implementation that uses less qubits."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualization\n",
"\n",
"When opening a quantum program using the `show` command, the visualization provides details regarding the quantum circuit's structure and performance. Key characteristics, such as gate count, qubit usage, and circuit depth, are displayed.\n",
"\n",
"The visualization is organized according to the building blocks used during the quantum program construction. These blocks represent modular components or routines in your quantum algorithm. By clicking on the \"+\" sign on a block, you can expand it to reveal the underlying quantum gates, making it easier to inspect, debug, or understand the algorithm's logic at both high and low levels.\n",
"\n",
"This can be seen in the following figure: the left panel represents a high-level view showing the quantum blocks used in the algorithm—such as `hadamard_transform` and `assign x**2 + 1`—while the right panel shows an expanded view of the `assign` block, revealing the underlying quantum gate sequence. Gates include multiple `PHASE` operations and a quantum Fourier transform block (`qft6`), offering insight into the inner workings of this computation.\n",
"\n",
"![Quantum Program Visualization](https://docs.classiq.io/resources/synthesis_tutorial.png)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Exporting and Sharing\n",
"\n",
"In addition to visualizing a quantum program, the tool provides convenient options to export the quantum circuit in multiple formats, enabling integration with other tools and workflows. Some of them are:\n",
"\n",
"- **QASM**: Allows interoperability with quantum simulators and hardware platforms.\n",
"- **LaTeX**: Produces a high-quality, pictorial representation of the circuit, ready for inclusion in LaTeX files.\n",
"- **JPEG**: Generates a graphical image of the circuit.\n",
"\n",
"To facilitate collaboration, there is a **Share** button that generates a unique link that you can send to anyone who wants to view your circuit directly in their browser — no login required.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -180,7 +220,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -194,7 +234,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down