-
Notifications
You must be signed in to change notification settings - Fork 141
first pass at quick start page #4041
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
base: main
Are you sure you want to change the base?
Changes from all commits
8c3da1e
f0126ce
42cf423
ecd74f4
a284eff
582cfd2
baf1b78
9c625f3
391c75c
9580b2d
28fb093
1bf7191
16a1733
83b75d2
3e3048d
3ba2a49
25e7de8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,262 @@ | ||||||
{ | ||||||
"cells": [ | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "2e2023d1", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"# Quick start" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "a82fbaaa", | ||||||
"metadata": { | ||||||
"tags": [ | ||||||
"version-info" | ||||||
] | ||||||
}, | ||||||
"source": [] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "7bbbdb4b", | ||||||
"metadata": { | ||||||
"jp-MarkdownHeadingCollapsed": true | ||||||
}, | ||||||
"source": [ | ||||||
"Build your first quantum circuit in under two minutes, on your local environment - no sign-in or API key necessary.\n", | ||||||
"\n", | ||||||
"<Admonition type=\"note\" title=\"New to Python and virtual environments?\">\n", | ||||||
"\n", | ||||||
"* It is recommended to use a Python virtual environment.\n", | ||||||
"\n", | ||||||
"<details>\n", | ||||||
"<summary>Click to expand for more information about **Python**.</summary>\n", | ||||||
"\n", | ||||||
"- To install Python, first check the \"Programming Language\" section on the [Qiskit PyPI project page](https://pypi.org/project/qiskit/) to determine which Python versions are supported by the most recent release. For download instructions, see the [Python Beginners Guide.](https://wiki.python.org/moin/BeginnersGuide/Download)\n", | ||||||
"\n", | ||||||
"<Admonition type = \"note\">\n", | ||||||
"These instructions use the standard Python distribution from [pypi.org](https://pypi.org/). However, you can use other Python distributions, such as [Anaconda](https://docs.anaconda.com/anaconda/) or [miniconda](https://docs.anaconda.com/miniconda/), along with other dependency management workflows like [Poetry](https://python-poetry.org/docs/).\n", | ||||||
"</Admonition>\n", | ||||||
"</details>\n", | ||||||
"\n", | ||||||
" <details>\n", | ||||||
" <summary>\n", | ||||||
" Click to expand for more information on **virtual environments**.\n", | ||||||
" </summary>\n", | ||||||
" - Use [Python virtual environments](https://docs.python.org/3.10/tutorial/venv.html) to separate Qiskit from other applications.\n", | ||||||
" A Python virtual environment is an isolated space to work with Python for a specific purpose — so you can install whatever packages you wish, and set up libraries, dependencies, and so on, without affecting the \"base\" Python environment on your machine.\n", | ||||||
"\n", | ||||||
" One important advantage of a virtual environment is that if your Python environment becomes corrupted somewhere along the way, you can easily delete the virtual environment and start over!\n", | ||||||
"\n", | ||||||
" Choose a preferred location in which to store information about your virtual environments. Typically they're stored in a directory named `.venv` within each project directory you're working in.\n", | ||||||
"\n", | ||||||
" To work in your virtual environment, navigate to your project directory and create a minimal environment with only Python installed in it.\n", | ||||||
"\n", | ||||||
" <OperatingSystemTabs>\n", | ||||||
" <TabItem value=\"mac\" label=\"macOS\">\n", | ||||||
" ```shell\n", | ||||||
" python3 -m venv .venv\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
"\n", | ||||||
" <TabItem value=\"linux\" label=\"Linux\">\n", | ||||||
" ```shell\n", | ||||||
" python3 -m venv .venv\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
"\n", | ||||||
" <TabItem value=\"win\" label=\"Windows\">\n", | ||||||
" ```text\n", | ||||||
" python -m venv .venv\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
" </OperatingSystemTabs>\n", | ||||||
"\n", | ||||||
" Next, activate your new environment.\n", | ||||||
"\n", | ||||||
" <OperatingSystemTabs>\n", | ||||||
" <TabItem value=\"mac\" label=\"macOS\">\n", | ||||||
" ```shell\n", | ||||||
" source .venv/bin/activate\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
"\n", | ||||||
" <TabItem value=\"linux\" label=\"Linux\">\n", | ||||||
" ```shell\n", | ||||||
" source .venv/bin/activate\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
"\n", | ||||||
" <TabItem value=\"win\" label=\"Windows\">\n", | ||||||
" If using PowerShell:\n", | ||||||
"\n", | ||||||
" ```text\n", | ||||||
" .venv\\Scripts\\Activate.ps1\n", | ||||||
" ```\n", | ||||||
" If using Git Bash:\n", | ||||||
"\n", | ||||||
" ```text\n", | ||||||
" source .venv/scripts/activate\n", | ||||||
" ```\n", | ||||||
" If using command prompt:\n", | ||||||
"\n", | ||||||
" ```text\n", | ||||||
" .venv\\Scripts\\activate\n", | ||||||
" ```\n", | ||||||
" </TabItem>\n", | ||||||
" </OperatingSystemTabs>\n", | ||||||
" </details>\n", | ||||||
"\n", | ||||||
"</Admonition>\n", | ||||||
"\n", | ||||||
"\n", | ||||||
"## 1. Install Qiskit\n", | ||||||
"\n", | ||||||
"Run the following command in your terminal to install the Qiskit and Qiskit Aer (local simulation) packages, as well as the Qiskit visualization module.\n", | ||||||
"\n", | ||||||
"```shell\n", | ||||||
"pip install qiskit qiskit-aer qiskit[visualization]\n", | ||||||
"\n", | ||||||
"# On a zsh terminal, use this line instead:\n", | ||||||
"# pip install qiskit qiskit-aer 'qiskit[visualization]'\n", | ||||||
"```" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "c8da788c", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"## 2. Build your circuit\n", | ||||||
"\n", | ||||||
"Open a Python environment, then run this code, which builds a Bell state (two entangled qubits)." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": null, | ||||||
"id": "86784142", | ||||||
"metadata": {}, | ||||||
"outputs": [ | ||||||
{ | ||||||
"name": "stdout", | ||||||
"output_type": "stream", | ||||||
"text": [ | ||||||
"{'00': 505, '11': 519}\n" | ||||||
] | ||||||
} | ||||||
], | ||||||
"source": [ | ||||||
"from qiskit import QuantumCircuit\n", | ||||||
"from qiskit.transpiler import generate_preset_pass_manager\n", | ||||||
"from qiskit_aer import AerSimulator\n", | ||||||
"\n", | ||||||
"qc = QuantumCircuit(2)\n", | ||||||
"qc.h(0)\n", | ||||||
"qc.cx(0, 1)\n", | ||||||
"qc.measure_all()\n", | ||||||
"\n", | ||||||
"sim = AerSimulator()\n", | ||||||
"pass_manager = generate_preset_pass_manager()\n", | ||||||
"\n", | ||||||
"transpiled = pass_manager.run(qc)\n", | ||||||
"\n", | ||||||
"result = sim.run(transpiled, shots=1024).result()\n", | ||||||
"print(result.get_counts())" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "9a3180c2-56d7-4224-91fa-13d8cb87d93d", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"The expected output is a near-even split between '00' and '11'." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to explain how to interpret the output? Where the 505 and 519 came from and what they mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went back and forth on this. I agree that this gives no explanation or context, which I'm naturally uncomfortable with - but in trying to capture the intention of a quick-start, I'm letting this be a teaser to spark interest (we should of course link out to learn more, but not explain on this page). |
||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "a110ac90", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"## Visualize your results\n", | ||||||
"\n", | ||||||
"To get a histogram of your results, add the following code to your program." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "code", | ||||||
"execution_count": null, | ||||||
"id": "dc4ff012", | ||||||
"metadata": {}, | ||||||
"outputs": [ | ||||||
{ | ||||||
"data": { | ||||||
"text/plain": [ | ||||||
"<Image src=\"/docs/images/guides/quick-start/extracted-outputs/dc4ff012-0.avif\" alt=\"Output of the previous code cell\" />" | ||||||
] | ||||||
}, | ||||||
"execution_count": 10, | ||||||
"metadata": {}, | ||||||
"output_type": "execute_result" | ||||||
} | ||||||
], | ||||||
"source": [ | ||||||
"from qiskit.visualization import plot_histogram\n", | ||||||
"\n", | ||||||
"counts = result.get_counts()\n", | ||||||
"plot_histogram(counts)\n", | ||||||
"# Include the next line if you are not using Python in a Jupyter notebook\n", | ||||||
"# plt.show()" | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "738d4fc4-29c9-46ab-9879-3365e2149d04", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"This result is a signature of quantum entanglement.\n", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's more complex than this, right, and has to do with correlation? Again, I think we can't reasonably explain these things in a quick-start guide without weighing it down, and should link out instead. Where to link out to is a bigger question - our learning materials, or some quick and dirty definition of entanglement? |
||||||
"\n", | ||||||
"Try changing the code to see how it affects the results. For example, add a third qubit by replacing `qc.cx(0, 1)` with `qc.cx(1, 2)`, or include a bit-flip by adding `qc.x(1)`." | ||||||
] | ||||||
}, | ||||||
{ | ||||||
"cell_type": "markdown", | ||||||
"id": "b6062a16", | ||||||
"metadata": {}, | ||||||
"source": [ | ||||||
"## Next steps\n", | ||||||
"\n", | ||||||
"<Admonition type=\"tip\" title=\"Recommendations\">\n", | ||||||
"- Run a circuit on real quantum hardware in the [Hello world](/docs/tutorials/hello-world) tutorial.\n", | ||||||
"- Browse the [IBM Quantum Platform documentation](/docs).\n", | ||||||
"- Learn how to apply quantum computing to common use cases in [tutorials.](/docs/tutorials)\n", | ||||||
"</Admonition>" | ||||||
] | ||||||
} | ||||||
], | ||||||
"metadata": { | ||||||
"description": "Build and visualize a quantum circuit in under two minutes, no sign-in or API key necessary.", | ||||||
"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", | ||||||
"version": "3" | ||||||
}, | ||||||
"title": "Quick start" | ||||||
}, | ||||||
"nbformat": 4, | ||||||
"nbformat_minor": 5 | ||||||
} |
Uh oh!
There was an error while loading. Please reload this page.