Code Monkey home page Code Monkey logo

qiskit-tutorials's Introduction

Qiskit Tutorials

License

⚠️ This repository is archived: The content in this repository was moved to other locations. If you have issues or PR, please submit them to their new location.

Contents

Welcome to the Qiskit Tutorials!

In this repository, we've put together a collection of Jupyter notebooks aimed at teaching people who want to use Qiskit for writing quantum computing programs, and executing them on one of several backends (online quantum processors, online simulators, and local simulators). The online quantum processors are the IBM Quantum systems.

For our community-contributed tutorials, please check out the qiskit-community-tutorials repository.

Contribution Guidelines

If you'd like to contribute to Qiskit Tutorials, please take a look at our contribution guidelines. This project adheres to Qiskit's code of conduct. By participating you are expected to uphold this code.

Tutorial limitations

Because the tutorials are executed as part of the build process, and eventually turned into RST documentation, there are several limitations to be aware of:

  1. There is currently a three minute per cell execution time limit. Cells that go over this limit will raise an exception.

  2. Tutorials cannot make calls to the IBM Quantum Experience, e.g. no IBMQ.load_account().

  3. It is important to maintain strict header compliance. All notebooks should start with, and contain only one, top level (h1) header:

    # I am a top level header
    

    Additionally, the nesting of headers should make sense:

    # I am a top level header
    
    ## I am a secondary header
    
    ### I am a tertiary header
    
    ## I am another secondary header
    
    ## I am another secondary header
    
  4. All math equations expressed using $$ ... $$ need to be surrounded on top and bottom by white space.

  5. In order for a tutorial to show up in the Qiskit documentation, after successful merging, an additional PR needs to be made in the Qiskit meta-repo to trigger the rebuilding of the documentation.

Adding a gallery image

To add a gallery image to a notebook, select a cell with an output image and add nbsphinx-thumbnail as a cell tag. To see the cell tags go to: View -> Cell Toolbar -> Tags in the notebook menu. Adding gallery images from images not generated inside of the notebooks themselves should be avoided if possible as this gets messy in the present build system.

Building documentation

In addition to serving up standalone notebooks, this repository also includes the infrastructure needed to build the tutorials into HTML documentation using Sphinx.

We use Tox, which you will need to install globally (e.g. using pipx).

  1. Fork and clone the forked repository.
  2. tox -e docs

Sometimes Sphinx's caching can get in a bad state. First, try running tox -e docs-clean, which will remove Sphinx's cache. If you are still having issues, try running tox -e docs -r. -r tells Tox to reinstall the dependencies.

Authors and Citation

Qiskit Tutorials is the work of many people who contribute to the project at different levels. If you use Qiskit, please cite as per the included BibTeX file.

License

Apache License 2.0

qiskit-tutorials's People

Contributors

1ucian0 avatar abbycross avatar ajavadia avatar attp avatar cryoris avatar danpuzzuoli avatar dcmckayibm avatar diego-plan9 avatar divshacker avatar huangjunye avatar jaygambetta avatar lcapelluto avatar manoelmarques avatar mrossinek avatar mtreinish avatar muneerqu avatar ng-glen avatar nonhermitian avatar omarcostahamido avatar pdc-quantum avatar pedrorrivero avatar quantumjim avatar rraymondhp avatar sathayen avatar shellygarion avatar sooluthomas avatar stefan-woerner avatar t-imamichi avatar taalexander avatar yaelbh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qiskit-tutorials's Issues

symbolic link to qiskit tools not working under Windows

Expected Behavior

A symbolic link is in place in qiskit-sdk-py after moving tools into the folder qiskit.

Current Behavior

When checking out qiskit-sdk-py under Windows the symbolic link is being converted into a textfile. Hence I get a NotFoundError when loading any tools.

Possible Solution

Add "qiskit." to tools import statements.

Steps to Reproduce (for bugs)

  1. checkout qiskit-sdk-py under Windows
  2. try running Jupyter notebooks that are importing tools from qiskit-sdk-py

Your Environment

  • Operating System and version: Windows 7

How to use classical "if" control

I was trying the teleportation circuit, which requires control using classical registers. The code is the following:
`include "qelib1.inc";
qreg q[5];
creg c0[1];
creg c1[1];
creg c2[1];

h q[0];
t q[0];
h q[0];
cx q[0],q[1];
h q[0];
measure q[0] -> c0[0];
measure q[1] -> c1[0];
if (c0==1)
x q[2];
if (c1==1)
z q[2];
measure q[2] -> c2[0];
`
And I got error:

Error in line 14: Operations are disabled

Which refers to the "if" operation. How should I use a classical register to control a quantum gate?

Explain the concept of equivalence up to global phase

The initialize() in the tutorial does not produce the exact state as desired vector, but it only gives one that is equivalence up to global phase.
https://nbviewer.jupyter.org/github/QISKit/qiskit-tutorial/blob/master/reference/tools/quantum_gates_and_linear_algebra.ipynb#Arbitrary-initialization

Description

I think it is good to mention about the equivalence up to global phase here also (in addition to a single qubit case mentioned before).

Your Environment

  • QISKit version: 0.5.3
  • Python version: 3.6.x

ImportError: cannot import name 'Energy_Estimate_Exact' in Quantum Optimization Notebook

Import error when running the first code block:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-69ab0bbfce01> in <module>()
     25 # import optimization tools
     26 from tools.apps.optimization import trial_circuit_ry, SPSA_optimization, SPSA_calibration
---> 27 from tools.apps.optimization import Energy_Estimate, make_Hamiltonian, Energy_Estimate_Exact
     28 from tools.qi.pauli import Pauli

ImportError: cannot import name 'Energy_Estimate_Exact'

Function missing from https://github.com/QISKit/qiskit-sdk-py/blob/master/tools/apps/optimization.py

Suggestion on managing API and URL via environment vars for real devices

Hey just started this tutorial, love that you are putting this together. One suggestion for the introduction when it comes to the real device configuration - have the users put their API key and the URL into environment variables instead of into local Python files. This removes the risk of people accidentally committing to public repos and exposing their keys.

The following would be changed:

  1. README - in section 4 instruct the user to setup an IBMAPI and IBMURL environment variable e.g. in their .bash_profile or similar using export statements.
  2. In the Introduction - Getting Started notebook change the imports to remove Qconfig and instead import os.
  3. In the Introduction - Getting Started notebook change the "Real Devices" section to get the environment variables instead e.g.
qp.set_api(os.getenv("IBMAPI"), os.getenv("IBMURL"))

ImportError: No module named 'Qconfig'

Description

Trying to run this code in the Jupyter notebook superposition_and_entanglement:

import sys
if sys.version_info < (3,5):
    raise Exception('Please use Python version 3.5 or greater.')
    
from qiskit import QuantumProgram
import Qconfig

Gives the following error:

ImportErrorTraceback (most recent call last)
<ipython-input-2-770624e829f1> in <module>()
      5 
      6 from qiskit import QuantumProgram
----> 7 import Qconfig

ImportError: No module named 'Qconfig'

Already added these code following the Readme before the cell where the error occurs:

!conda create -y -n QISKitenv python=3 pip scipy
!source activate QISKitenv
!pip install qiskit
APItoken = '<hidden>'
config = {'url': 'https://quantumexperience.ng.bluemix.net/api'}

if 'APItoken' not in locals():
    raise Exception('Please set up your access token. See Qconfig.py.')
!conda install -y jupyter 

The first two code cells run successfully, however the last one gives me a permission-denied error to write:

CondaIOError: Missing write permissions in: /usr/local/src/conda3_runtime/4.1.1
#
# You don't appear to have the necessary permissions to install packages
# into the install area '/usr/local/src/conda3_runtime/4.1.1'.
# However you can clone this environment into your home directory and
# then make changes to it.
# This may be done using the command:
#
# $ conda create -n my_root --clone="/usr/local/src/conda3_runtime/4.1.1"

And Qconfig is still not found.

Your Environment

  • Tutorial branch (stable/master): master, getting_started.ipynb, superposition_and_entanglement.ipynb, entanglement_revisited.ipynb
  • QISKit SDK version: Unknown at the moment, probably most recent as it was just downloaded
  • Python version: 3.5

Update Backends in tutorial

Hello, I'd like to update the notebook working_with_backends.ipynb with the latest backends.

What's the first step for me to make this contribution? Create my own branch?

Unreadable Notebook: qiskit-tutorial-master/1_introduction/getting_started.ipynb

On http://localhost:8888/notebooks/qiskit-tutorial-master/index.ipynb#section1

Link
Getting started with QISKit SDK - how to use QISKit SDK.

Obtained
Unreadable Notebook: /home/nnelson/environments/qiskit-tutorial-master/1_introduction/getting_started.ipynb NotJSONError('Notebook does not appear to be JSON: '\ufeff{\n "cells": [\n {\n "cell_typ...',)

New installation from instructions at
From https://github.com/QISKit/qiskit-sdk-py/blob/master/doc/install.rst

Using tutorial
https://github.com/QISKit/qiskit-tutorial/archive/master.zip

From python3 environment
pip install qiskit

Python 3.5.2

Xubuntu 16.04.3 LTS

The next link in section 1 works.
Understanding the different backends - how to get information about the connected backends.

jupyter --version
4.4.0

Running Algorithm on ibmqx5 DAG Circuit error

Description

I am trying to run the Grover's algorithm, it worked nicely on the local qasm simulator but when i change the backend on ibmqx5 i got the following error:
qiskit.dagcircuit._dagcircuiterror.DAGCircuitError: 'inequivalent gate definitions for cx'
and again when i changed the backend to ibmq_qasm_simulator i get the following error:
qiskit._resulterror.ResultError: DEVICE_NOT_FOUND: Device not found.
i have placed circuit.barrier(qr) in front of the oracle, diffusion as well as in measurement. and also i had changed the time out to 300
Thank you!!

Your Environment

  • QISKit version: 0.4.9
  • Python version:3.5

Error message while running Maxcut in ibmqx5 - 16 qubit from classical_optimization in application examples

Description

While trying to run simple Maxcut (for 4 qubits) with ibmqx5, get the following error:

WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. The qasm has no measures.","code":"QASM_NOT_VALID","statusCode":400}}

The same notebook runs ok with the simulator (local_qasm_simulator). I ran the classical_optimization example in 4_applications folder.

Your Environment

  • Tutorial branch (stable/master): Master
  • QISKit SDK version: 0.4.8
  • Python version: 3.5.3

Set more credits (or no credit spend) for reviewers of the tutorials

Description

To review tutorials, the reviewers must test the experiments on real devices many times. They need more credits to do that. Either give them more credits or identify them so they do not need to spend credits for testing.

Your Environment

  • Tutorial branch (stable/master):
  • QISKit SDK version:
  • Python version:

Error in notebook "quantum_emoticon": unable to get counts

Description

These are the steps I followed to get the error:

  1. Clone repo: git clone https://github.com/QISKit/qiskit-tutorial.git (commit 37faf8b)
  2. cd qiskit-tutorial/
  3. Create file: vi 0_hello_world/Qconfig.py:
APItoken = 'XXX...XXX'
config = {'url': 'https://quantumexperience.ng.bluemix.net/api'}

if 'APItoken' not in locals():
    raise Exception('Please set up your access token. See Qconfig.py.')
  1. pip install -r requirements.txt
  2. jupyter notebook index.ipynb
  3. Go to notebook "Quantum Emoticon"
  4. Run first piece of code to produce the measures and get the counts

I got the following errors:

WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=XXX...XXX: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}
WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=XXX...XXX: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}
WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=XXX...XXX: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}
WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=XXX...XXX: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}
WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=XXX...XXX: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}

And this trace:

ResultError                               Traceback (most recent call last)
<ipython-input-1-72b078066956> in <module>()
     31 # run and get results
     32 results = qp.execute(["smiley_writer"], backend='ibmqx5', shots=1024)
---> 33 stats = results.get_counts("smiley_writer")

~/anaconda3/envs/QISKitenv/lib/python3.6/site-packages/qiskit/_result.py in get_counts(self, name)
    231         """
    232         try:
--> 233             return self.get_data(name)['counts']
    234         except KeyError:
    235             raise QISKitError('No counts for circuit "{0}"'.format(name))

~/anaconda3/envs/QISKitenv/lib/python3.6/site-packages/qiskit/_result.py in get_data(self, name)
    202             exception = self._result['result']
    203             if isinstance(exception, BaseException):
--> 204                 raise exception
    205             else:
    206                 raise QISKitError(str(exception))

~/anaconda3/envs/QISKitenv/lib/python3.6/site-packages/qiskit/_jobprocessor.py in _job_done_callback(self, future)
     97     def _job_done_callback(self, future):
     98         try:
---> 99             result = future.result()
    100         except Exception as ex:  # pylint: disable=broad-except
    101             result = Result({'job_id': '0', 'status': 'ERROR',

~/anaconda3/envs/QISKitenv/lib/python3.6/concurrent/futures/_base.py in result(self, timeout)
    423                 raise CancelledError()
    424             elif self._state == FINISHED:
--> 425                 return self.__get_result()
    426 
    427             self._condition.wait(timeout)

~/anaconda3/envs/QISKitenv/lib/python3.6/concurrent/futures/_base.py in __get_result(self)
    382     def __get_result(self):
    383         if self._exception:
--> 384             raise self._exception
    385         else:
    386             return self._result

~/anaconda3/envs/QISKitenv/lib/python3.6/concurrent/futures/thread.py in run(self)
     54 
     55         try:
---> 56             result = self.fn(*self.args, **self.kwargs)
     57         except BaseException as exc:
     58             self.future.set_exception(exc)

~/anaconda3/envs/QISKitenv/lib/python3.6/site-packages/qiskit/_jobprocessor.py in run_backend(q_job)
     52                 circuit['compiled_circuit'] = compiled_circuit
     53     backend = qiskit.backends.get_backend_instance(backend_name)
---> 54     return backend.run(q_job)
     55 
     56 

~/anaconda3/envs/QISKitenv/lib/python3.6/site-packages/qiskit/backends/_qeremote.py in run(self, q_job)
     98                                    hpc=hpc)
     99         if 'error' in output:
--> 100             raise ResultError(output['error'])
    101 
    102         logger.debug('Running on remote backend %s with job id: %s',

ResultError: QASM_NOT_VALID: Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked

Your Environment

  • Tutorial branch: master
  • QISKit SDK version: QISKit-0.4.8
  • Python version: Python 3.6.4 :: Anaconda, Inc.

Problems with superposition and entanglement notebook

The current notebook of superposition_and_entanglement.ipynb does not work as desired if run on remote backends.

https://github.com/QISKit/qiskit-tutorial/blob/master/reference/qis/superposition_and_entanglement.ipynb

Description

  1. The current notebook runs ok with local simulators, but when backend=ibmqx_qasm_simulator it cannot be run anymore unless the lowest_pending_jobs() function is called.

  2. The circuit_drawer does not work (the image is misalign). Also, please provide the installation instruction of required packages for Linux, Mac, and Windows.
    misalign_drawing

Your Environment

  • QISKit version: 0.4.13
  • Python version: 3.6.2

AttributeError: module 'qiskit' has no attribute 'unroll'

when i try to import the library
from qiskit import QuantumProgram
qp = QuantumProgram()

i get pesky error

` AttributeError Traceback (most recent call last)
in ()
----> 1 from qiskit import QuantumProgram
2 qp = QuantumProgram()

~/qiskit-sdk-py/qiskit/init.py in ()
8 from ._qiskitexception import QISKitException
9 import qiskit.extensions.standard
---> 10 from ._quantumprogram import QuantumProgram

~/qiskit-sdk-py/qiskit/_quantumprogram.py in ()
39 from . import unroll
40 from . import qasm
---> 41 from . import mapper
42
43 # Local Simulator Modules

~/qiskit-sdk-py/qiskit/mapper/init.py in ()
1 from ._coupling import Coupling
----> 2 from ._mapping import swap_mapper, direction_mapper, cx_cancellation, optimize_1q_gates

~/qiskit-sdk-py/qiskit/mapper/_mapping.py in ()
28 from qiskit import QISKitException
29 from qiskit.qasm import Qasm
---> 30 import qiskit.unroll as unroll
31
32 # Notes:

AttributeError: module 'qiskit' has no attribute 'unroll' `

Help please , Thanks

Avoid using local_qasm_simulator for 10 qubits or more

Description

The local_qasm_simulator is too slow and not efficient for simulating 10 or more qubits.
The alternative is to use the new ibmqx_hpc_qasm_simulator or ibmqx_qasm_simulator.

Your Environment

  • Tutorial branch (stable/master):
  • QISKit SDK version:
  • Python version:

Gates after a measure are blocked in tutorial 0

Description

warning

WARNING:IBMQuantumExperience.IBMQuantumExperience:Got a 400 code response to https://quantumexperience.ng.bluemix.net/api/Jobs?access_token=MY_TOKEN: {"error":{"status":400,"message":"Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked","code":"QASM_NOT_VALID","statusCode":400}}

stacktrace

---------------------------------------------------------------------------
ResultError                               Traceback (most recent call last)
<ipython-input-11-a53ab98382b5> in <module>()
     31 # run and get results
     32 results = qp.execute(["smiley_writer"], backend='ibmqx5', shots=1024)
---> 33 stats = results.get_counts("smiley_writer")

/opt/conda/lib/python3.5/site-packages/qiskit/_result.py in get_counts(self, name)
    231         """
    232         try:
--> 233             return self.get_data(name)['counts']
    234         except KeyError:
    235             raise QISKitError('No counts for circuit "{0}"'.format(name))

/opt/conda/lib/python3.5/site-packages/qiskit/_result.py in get_data(self, name)
    202             exception = self._result['result']
    203             if isinstance(exception, BaseException):
--> 204                 raise exception
    205             else:
    206                 raise QISKitError(str(exception))

/opt/conda/lib/python3.5/site-packages/qiskit/_jobprocessor.py in _job_done_callback(self, future)
     97     def _job_done_callback(self, future):
     98         try:
---> 99             result = future.result()
    100         except Exception as ex:  # pylint: disable=broad-except
    101             result = Result({'job_id': '0', 'status': 'ERROR',

/opt/conda/lib/python3.5/concurrent/futures/_base.py in result(self, timeout)
    396                 raise CancelledError()
    397             elif self._state == FINISHED:
--> 398                 return self.__get_result()
    399 
    400             self._condition.wait(timeout)

/opt/conda/lib/python3.5/concurrent/futures/_base.py in __get_result(self)
    355     def __get_result(self):
    356         if self._exception:
--> 357             raise self._exception
    358         else:
    359             return self._result

/opt/conda/lib/python3.5/concurrent/futures/thread.py in run(self)
     53 
     54         try:
---> 55             result = self.fn(*self.args, **self.kwargs)
     56         except BaseException as e:
     57             self.future.set_exception(e)

/opt/conda/lib/python3.5/site-packages/qiskit/_jobprocessor.py in run_backend(q_job)
     52                 circuit['compiled_circuit'] = compiled_circuit
     53     backend = qiskit.backends.get_backend_instance(backend_name)
---> 54     return backend.run(q_job)
     55 
     56 

/opt/conda/lib/python3.5/site-packages/qiskit/backends/_qeremote.py in run(self, q_job)
     98                                    hpc=hpc)
     99         if 'error' in output:
--> 100             raise ResultError(output['error'])
    101 
    102         logger.debug('Running on remote backend %s with job id: %s',

ResultError: QASM_NOT_VALID: Error parsing QASM. Error parsing qasm number 0. Gates after a measure are blocked

Your Environment

Jupyter Notebook

  • Tutorial branch (stable/master):
    master
  • QISKit SDK version:
    0.4.9
  • Python version:
    Python 3

Strange error with simulators

Description

When running the following code, I got backend ... not available error.

backend = "ibmqx_hpc_qasm_simulator"
shots = 1000
results = Q_program.execute([circuitName], backend=backend, shots=shots)
answer = results.get_counts(circuitName)

plot_histogram(answer)

But when I queried the available backends, with pprint as below, I can run the code.

from pprint import pprint

pprint(Q_program.available_backends())
pprint(Q_program.get_backend_status('ibmqx_hpc_qasm_simulator'))
pprint(Q_program.get_backend_status('ibmqx_qasm_simulator'))


backend = "ibmqx_hpc_qasm_simulator"
shots = 1000
results = Q_program.execute([circuitName], backend=backend, shots=shots)
answer = results.get_counts(circuitName)

plot_histogram(answer)

Your Environment

  • IBMQuantumExperience 1.9.0
  • qiskit 0.4.12
  • python 3.6.2

reworking the tutorial so that it is easier to manage

We are going to split the tutorial into three sections.

We are going to add to a WIP PR that i will set up and if you want to help in the rework that would be great. Either you can help by commenting here or helping in the content. The names are the assigned people that are going to coordinate the different sections.

sections

  • Hello World: Since quantum computing is so new, we want to find the best Hello Quantum World program and welcome submissions here.
  • Reference: These notebooks demonstrate how to use QISKit and explore quantum information science, acting as a reference book for QISKit. They will be kept up to date with QISKit SDK updates. They are organised into various topics:
    1. Getting started with QISKit (me)
    • Getting started
    • Working with backends (including compiling and running)
    • Using different gates
    • Visualisation of quantum states
    1. Introduction to quantum information science @attp
    • Superposition and entanglement
    • Entanglement revisited
    • Quantum teleportation and superdense coding
    1. Understanding your quantum computer @dtmcclure
    • Relaxation and decoherence
    • Quantum tomography
    • Random Benchmarking # to be written
    1. Working an approximate quantum quantum computers @adcorcol
    • Variational Quantum Eigensolver
    • Small error correcting codes # to be written
    • Error mitigation # to be written
    1. Examples of quantum algorithms @rraymondhp
    • Phase estimation
    • Deutsch–Jozsa algorithm
    • Bernstein-Vazirani algorithm
    • Simon's algorithm
    • Grover's algorithm
    • Shor's algorithm
    1. Having fun with quantum computers
    • Battleships
  • Appendix This is where the rest of the tutorials are. They are not guaranteed to work with the latest version of the QISKit SDK. They are organised into various topics:
    1. Advanced QISKit features
    2. More on quantum information
    3. Further quantum algorithms and applications
    4. Everything else

Replace local_qasm_simulator with local_qiskit_simulator

Description

For local simulation of 10 qubits or more, the local_qiskit_simulator should be used.
Here is a comparison of running quantum_emoticon tutorial: local_qiskit_simulator takes 3.6 seconds vs local_qasm_simulator takes more than 1200 seconds.

import time
start_time = time.time()

backend = "local_qiskit_simulator" 
#backend = "local_qasm_simulator" 
shots_sim = 1000
results_sim = qp.execute(["smiley_writer"], backend=backend, shots = shots_sim, wait=5, timeout=300)
stats_sim = results_sim.get_counts("smiley_writer")

print("--- %s seconds ---" % (time.time() - start_time))

plot_histogram(stats_sim)

Your Environment

  • QISKit version: 0.4.13
  • Python version: 3.6
    MacBookAir MacOSX with 8GM RAM and 1.6GHz i5

Provide a way for checking the tutorials when a new qiskit version is released

Description

After some discussion spawned from #135 and the tutorials as a whole, it seems that having an easy, ideally single-shot way of checking if the tutorials are working against a new version of qiskit (or other dependencies in general) would facilitate keeping them in sync.

As a simple approach, a command that can be executed locally by a tutorial repository maintainer and clearly outputs which ones are working and which ones are not seems a good compromise. We can make use of the Python test framework for paving the way towards having a more integrated system in the future if needed.

Your Environment

  • QISKit version:
  • Python version:

Add path to Qconfig at all tutorials that import it

Description

There are many issues with tutorials cannot be run due to failure in importing Qconfig.
We need to make sure the Qconfig is installed on the path that is searched by the PYTHONPATH.

Your Environment

  • Tutorial branch (stable/master):
  • QISKit SDK version:
  • Python version:

Errors from "superposition_and_entanglement"

TypeError Traceback (most recent call last)
in ()
----> 1 plot_histogram(result.get_counts('ground'))

C:\Anaconda\Anaconda3\lib\site-packages\qiskit_quantumprogram.py in get_counts(self, name)
1298 """
1299 try:
-> 1300 return self.get_data(name)['counts']
1301 except KeyError:
1302 raise QISKitError('No counts for circuit "{0}"'.format(name))

C:\Anaconda\Anaconda3\lib\site-packages\qiskit_quantumprogram.py in get_data(self, name)
1280 for index in range(len(qobj["circuits"])):
1281 if qobj["circuits"][index]['name'] == name:
-> 1282 return self.__result['result'][index]["data"]
1283 except KeyError:
1284 raise QISKitError('No data for circuit "{0}"'.format(name))

TypeError: string indices must be integers


IndexError Traceback (most recent call last)
in ()
----> 1 plot_histogram(result.get_counts('excited'))

C:\Anaconda\Anaconda3\lib\site-packages\qiskit_quantumprogram.py in get_counts(self, name)
1298 """
1299 try:
-> 1300 return self.get_data(name)['counts']
1301 except KeyError:
1302 raise QISKitError('No counts for circuit "{0}"'.format(name))

C:\Anaconda\Anaconda3\lib\site-packages\qiskit_quantumprogram.py in get_data(self, name)
1280 for index in range(len(qobj["circuits"])):
1281 if qobj["circuits"][index]['name'] == name:
-> 1282 return self.__result['result'][index]["data"]
1283 except KeyError:
1284 raise QISKitError('No data for circuit "{0}"'.format(name))

IndexError: list index out of range

Reduce traffic to backends

In many places in the tutorial the real backend to run on is hardcoded. When many users run tutorials, this creates a problem of overloading some backends and starving others.

The problem is aggravated when one of the overloaded backends goes offline for maintenance, creating very long queues.

A potential solution is to not hardcode the backends. Rather, the tutorial codes must query the backends for availability, and also randomize the backend selection so it gets distributed across users. (In particular, often the tutorials run on 5 qubits. But they could as well run on the 16 qubit device).

Description

Your Environment

  • Tutorial branch (stable/master):
  • QISKit SDK version:
  • Python version:

Add a Binder badge

Description

You could add a Binder badge to launch the Jupyter notebooks in a cloud instance

Homepage: https://mybinder.org
Src: https://github.com/jupyterhub/binderhub
Docs: https://binderhub.readthedocs.io/en/latest/

Qiskit/qiskit#177

Your Environment

binder builds cloud containers with repo2docker.
repo2docker will install from requirements.txt and/or environment.yml
Docs: https://repo2docker.readthedocs.io/en/latest/samples.html#conda-mixed-requirements
Src: https://github.com/jupyter/repo2docker

Print the correct versions of qiskit, IBM Quantum Experience, and python version

Description

At the end of tutorials, add the following codes (or, compatible lines that do better).
The current version check just print the content of requirements.txt that might not be true anymore.

! pip list | grep "qiskit"
! pip list | grep "IBMQuantumExperience"
! python --version

Your Environment

  • QISKit version:
  • Python version:

Type error in result.get_counts()

I've run a couple of circuits on the 'ibmqx5' backend but realised that the optimisation of the circuit is probably making it give out the wrong amplitudes. I've attempted to fix this by adding a few barriers and ran it again but (3 times in a row) an error message came up and I narrowed it down to being solely due to the get_counts() method. Here's the error message:

Traceback (most recent call last):
File "mbqc-simulation.py", line 232, in
plot_histogram(result.get_counts('MBQC'))
File "/Users/TheProtonCat/anaconda/lib/python3.5/site-packages/qiskit/_quantumprogram.py", line 1300, in get_counts
return self.get_data(name)['counts']
File "/Users/TheProtonCat/anaconda/lib/python3.5/site-packages/qiskit/_quantumprogram.py", line 1282, in get_data
return self.__result['result'][index]["data"]
TypeError: string indices must be integers

Since the method worked fine before I wonder if it might be the barriers that are inducing the error. I need to run this simulation for a project so any quick fix would be very much appreciated! (note that the method fails when I use it in different ways, like extracting my own values, not just when trying to plot the histogram).

[Checking]The qubits got permuted when running with real devices

Description

There is an issue of real-devices that permute the order of qubits. This will be solved with the next release of qiskit-sdk-py. Until that release, we have to provide a workaround of fixing the qubit order.

Your Environment

  • QISKit version:
  • Python version:

'BinaryOp' object has no attribute 'sym' error

qp.compile fails

When running the getting started notebook :

backend = 'local_qasm_simulator' 
circuits = ['Circuit']  # Group of circuits to execute
qobj=qp.compile(circuits, backend) # Compile your program

I get the following error: 'BinaryOp' object has no attribute 'sym'

  • Tutorial branch (stable/master): master
  • QISKit SDK version: master version
  • Python version: 3.6

Generating Equilibrium file

Description

What is the easiest way to generate Equilibrium.txt files?

Your Environment

  • QISKit version: 0.4.12
  • Python version: Python 3.6.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.