Skip to content

Commit

Permalink
moved tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMTO committed Apr 11, 2024
1 parent e237425 commit 3e9270a
Show file tree
Hide file tree
Showing 6 changed files with 1,597 additions and 0 deletions.
Binary file added MQT Tutorial/2d_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added MQT Tutorial/2dqed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,309 changes: 1,309 additions & 0 deletions MQT Tutorial/MQT Qudits Tutorial.ipynb

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions MQT Tutorial/MQT Qudits in Short.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "69b78731",
"metadata": {},
"source": [
"# MQT Qudits 🌌\n",
"*Discover a New Dimension in Quantum Computing*\n",
"\n",
"Embark on a journey with MQT Qudits, a cutting-edge toolkit for Mixed-Dimensional Quantum Computing.\n",
"\n",
"<br>\n",
"<p>Delve into the realm of mixed-dimensional quantum computing with NeQST—a project funded by the European Union and developed at the <a href=\"https://www.cda.cit.tum.de/\" target=\"_blank\">Chair for Design Automation</a> at the Technical University of Munich, as part of the <a href=\"https://www.cda.cit.tum.de/research/quantum/mqt/\" target=\"_blank\">Munich Quantum Toolkit</a>.</p> Our team is focused on creating design automation methods and software for quDit-based systems. Explore our Jupyter file to discover the initial tools and contributions we've made to advance Quantum Information Processing for Science and Technology.\n",
"<img src=\"foot.png\" alt=\"Logo 1\" width=\"400\"/> \n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "b95c4040",
"metadata": {},
"source": [
"# User Inputs 💻\n",
"\n",
"🚀 **New QASM Extension:**\n",
"Dive into a language meticulously designed to express quantum algorithms and circuits. MQT extends the openQASM 2.0 grammar, effortlessly adapting to registers that feature a harmonious mix of qudits and qubits in diverse combinations. \n",
"\n",
"🐍 **Python Interface** \n",
"\n",
"Constructing and manipulating quantum programs becomes a breeze with Python. You have the flexibility to:\n",
"\n",
"1. **Initialize Quantum Circuits:** Start by creating your quantum circuits effortlessly.\n",
"\n",
"2. **Create Quantum Registers:** Build dedicated quantum registers tailored to your needs.\n",
"\n",
"3. **Compose Circuits:** Seamlessly bring together your quantum registers, forming a unified and powerful circuit.\n",
"\n",
"4. **Apply Operations:** Easily apply a variety of qudit operations, without worrying about the right representation. \n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "7bc57c87",
"metadata": {},
"source": [
"<img src=\"2dqed.png\" alt=\"2dqed.png\" width=\"350\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac47688d",
"metadata": {},
"outputs": [],
"source": [
"from mqt.qudits.qudit_circuits.circuit import QuantumCircuit"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f0157fd8",
"metadata": {},
"outputs": [],
"source": [
"qasm = \"\"\"\n",
" DITQASM 2.0;\n",
" \n",
" qreg fields [3][5,5,5];\n",
" qreg matter [2][2,2];\n",
" \n",
" h fields[2] ctl matter[0] matter[1] [0,0];\n",
" cx fields[2], matter[0];\n",
" cx fields[2], matter[1];\n",
" rxy (0, 1, pi, pi/2) fields[2];\n",
" \n",
" measure q[0] -> meas[0];\n",
" measure q[1] -> meas[1];\n",
" measure q[2] -> meas[2];\n",
" \"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3c421902",
"metadata": {},
"outputs": [],
"source": [
"circuit = QuantumCircuit()\n",
"circuit.from_qasm(qasm)\n",
"\n",
"print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")"
]
},
{
"cell_type": "markdown",
"id": "fdd6eef4",
"metadata": {},
"source": [
"##### Let's construct a quantum circuit from scratch.\n",
"<br>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "468735a3",
"metadata": {},
"outputs": [],
"source": [
"from mqt.qudits.qudit_circuits.components.registers.quantum_register import QuantumRegister\n",
"\n",
"\n",
"circuit = QuantumCircuit()\n",
"\n",
"field_reg = QuantumRegister(\"fields\", 1, [3])\n",
"ancilla_reg = QuantumRegister(\"ancillas\", 1, [3])\n",
"\n",
"circuit.append(field_reg)\n",
"circuit.append(ancilla_reg)\n",
"\n",
"h = circuit.h(field_reg[0])\n",
"csum = circuit.csum([field_reg[0], ancilla_reg[0]])\n",
"\n",
"print(h.to_matrix())\n",
"print(f\"\\n Number of operations: {len(circuit.instructions)}, \\n Number of qudits in the circuit: {circuit.num_qudits}\")"
]
},
{
"cell_type": "markdown",
"id": "53329ff9",
"metadata": {},
"source": [
"\n",
"##### It is possible to export the code and share your program in a QASM file.\n",
"<br>"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "32658fe9",
"metadata": {},
"outputs": [],
"source": [
"print(circuit.to_qasm())"
]
},
{
"cell_type": "markdown",
"id": "3a6b2672",
"metadata": {},
"source": [
"# Simulation 🚀\n",
"\n",
"After crafting your quantum circuit with precision, take it for a spin using two distinct engines, each flaunting its unique set of data structures.\n",
"\n",
"- **External Tensor-Network Simulator:** Delve into the quantum realm with a robust external tensor-network simulator.\n",
"\n",
"- **MiSiM (C++-Powered):** Unleash the power of decision-diagram-based simulation with MiSiM, seamlessly interfaced with Python for a fluid and efficient experience. 🌐💡"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d2a8eb0",
"metadata": {},
"outputs": [],
"source": [
"from mqt.qudits.simulation.provider.qudit_provider import MQTQuditProvider\n",
"\n",
"\n",
"provider = MQTQuditProvider()\n",
"provider.backends(\"sim\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5b16d935",
"metadata": {},
"outputs": [],
"source": [
"from mqt.qudits.visualisation.plot_information import plot_counts, plot_state\n",
"\n",
"backend = provider.get_backend(\"tnsim\")\n",
"\n",
"job = backend.run(circuit)\n",
"result = job.result()\n",
"\n",
"state_vector = result.get_state_vector()\n",
"\n",
"plot_state(state_vector, circuit)"
]
},
{
"cell_type": "markdown",
"id": "cc320e6b",
"metadata": {},
"source": [
"# Compilation ⚙️\n",
"\n",
"Emulate the features of the best experimental laboratories in your compilation process. Leverage modern compiler passes to customize optimization, gate decomposition, and noise-aware strategies, creating compiled circuits that closely resemble the challenges and advantages of cutting-edge quantum hardware.\n",
"\n",
"Customize, compile, and push the boundaries of quantum algorithms with a tailored approach to quantum compilation. 🛠️🔧🚀\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd61551f",
"metadata": {},
"outputs": [],
"source": [
"from mqt.qudits.compiler.dit_manager import QuditManager\n",
"\n",
"backend_ion = provider.get_backend(\"faketraps2trits\", shots=1000)\n",
"\n",
"qudit_compiler = QuditManager()\n",
"\n",
"passes = [\"LocQRPass\"]\n",
"\n",
"compiled_circuit_qr = qudit_compiler.compile(backend_ion, circuit, passes)\n",
"\n",
"print(\n",
" f\"\\n Number of operations: {len(compiled_circuit_qr.instructions)}, \\n Number of qudits in the circuit: {compiled_circuit_qr.num_qudits}\"\n",
")"
]
},
{
"cell_type": "markdown",
"id": "21a11514",
"metadata": {},
"source": [
"### Extending Simulation with Noise Model Integration\n",
"\n",
"Introduce realism into your simulations by incorporating a noise model. Simulate the effects of environmental factors and imperfections, bringing your quantum algorithms closer to real-world scenarios."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a7fa4150",
"metadata": {},
"outputs": [],
"source": [
"job = backend_ion.run(compiled_circuit_qr)\n",
"result = job.result()\n",
"counts = result.get_counts()\n",
"\n",
"plot_counts(counts, compiled_circuit_qr)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "91b7145d",
"metadata": {},
"outputs": [],
"source": []
}
],
"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"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added MQT Tutorial/MQT slide.pdf
Binary file not shown.
Binary file added MQT Tutorial/foot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3e9270a

Please sign in to comment.