Giter Club home page Giter Club logo

qiskit-community-tutorials's Introduction

Qiskit Community Tutorials

License

Welcome to the Qiskit community tutorials!

In this repository, we've put together a collection of awesome community-contributed Jupyter notebooks that leverage the features of Qiskit in education and applications. Feel free to navigate this repository, to Fork this repo, or to open the Binder image.

Contents

Learn from the community how to write your first quantum program.

Learn quantum computing by having fun. How is there a better way!

Learn about and how to program quantum circuits using Qiskit Terra.

Learn about textbook quantum algorithms, like Deutsch-Jozsa, Grover, and Shor using Qiskit Terra.

Learn how to develop the fundamentals of quantum applications using Qiskit Aqua

6 Awards

Learn from the great contributions to the IBM Q Awards

Contribution Guidelines

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

We use GitHub issues for tracking requests and bugs. Please use our slack for discussion and simple questions. To join our Slack community, use the link. For questions that are more suited for a forum, we use the Qiskit tag in the Stack Exchange.

Authors and Citation

Qiskit Community 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-community-tutorials's People

Contributors

1ucian0 avatar anupamaray avatar attp avatar chunfuchen avatar dcmckayibm avatar hnorlen avatar hushaohan avatar janlahmann avatar jaygambetta avatar jwoehr avatar lukasszz avatar manoelmarques avatar merav-aharoni avatar mrossinek avatar mtreinish avatar muneerqu avatar nbronn avatar nkanazawa1989 avatar nonhermitian avatar omarcostahamido avatar pdc-quantum avatar pemmaras avatar quantumjim avatar qubeat avatar rfclambert avatar rraymondhp avatar shellygarion avatar vectorbolt avatar woodsp-ibm 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

qiskit-community-tutorials's Issues

Module not found

#Import the game!

import sys

sys.path.append('game_engines')

from q_tic_tac_toe import Board


ModuleNotFoundError Traceback (most recent call last)
in
2 import sys
3 sys.path.append('game_engines')
----> 4 from q_tic_tac_toe import Board

ModuleNotFoundError: No module named 'q_tic_tac_toe'

community/Cryptography can be improved

I was looking at the tutorial in community to create a random number (uniform law), and found the one in Cryptography.

What is the expected behavior?

I think it should have more explainations in text, and I think the readme is wrong (it says that a circuit with n Hadamard is the same as rolling a n-face dice, but shouldn't it be 2**n-face dice?). Plus, it uses the statevector simulator, with no option of using the real hardware, even though the IBMQ account is set up in the beggining (it is not used, as well as the transpiler, so we could delete these unused imports). Even for simulation I suggest to use quasm_simulator for the backend and do multiple shots instead of recreating the same circuit each time we want a new random number (in the tutorial, 40 numbers are generated, and each time the circuit is rebuilt, because they are executed on the statevector_simulator).

So the improvements I suggest, to make it a better tutorial are: more text to explain what's going on, an option to use the real hardware for real randomness (it will work because it's only a Hadamard on every qubits), replace the statevector_simulator by the qasm_simulator and add a nbr_of_random_numbers parameters, in order to do all the generation in one execution on the circuit and a cleanup of unused imports and commented prints.

I hope it doesn't sound too harsh, I find it already great, but I think it can easily be improved to be more clear and versatile :)

It's clearly not a urgent job though, and I can help with it if needed!

Proposal of new game

Hi,

We have recently proposed a game that can be played on a quantum computer here: QuantumPoker (incuding jupyter notebooks).
We would like to contribute this game to your games section as well. If you think this is a good idea, please tell us what we should do.

Kind regards,
Franz

deprecation issue

Hello good sir,
some of the libraries and qiskit aqua under machine_learning/qsvm.ipynb file have all be deprecated, i was wondering if you could update or modify the code base, or provide me with alternative way to implement the qsvm.

When I run using IBM Quantum computer, there is a warning msg and no output result

Please all, I made an account on IBM and got my API key. Then I tried to run a code on google Collab using IBM real quantum computer:
I attached below the two methods I used, but the same warning message appears with no any result output of code, just a warning msg in all training phase.

Here are the two methods I used
try:
qiskit.IBMQ.enable_account("MY IBM saved key")
except:
pass

backend = qiskit.IBMQ.get_provider().get_backend("ibmq_qasm_simulator")
#else:

Second method is
IBMQ.save_account('MY IBM saved key')
IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
provider.backends()
backend = provider.get_backend('ibmq_qasm_simulator')

The warning message appears without any result for executing the code is

image

Why is the output of the simulation 111 instead of 001 considering input states are all 0?

Code from here not sure what happened when I tried to run it thanks for the help!

`import math

importing Qiskit

from qiskit import Aer, IBMQ
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit.providers.ibmq import least_busy

useful additional packages

from qiskit.tools.jupyter import *
from qiskit.tools.visualization import plot_histogram
provider = IBMQ.load_account()`

qft

`def input_state(circ, q, n):
"""n-qubit input state for QFT that produces output 1."""
for j in range(n):
circ.h(q[j])
circ.u1(math.pi/float(2**(j)), q[j]).inverse()

def qft(circ, q, n):
"""n-qubit QFT on q in circ."""
for j in range(n):
for k in range(j):
circ.cu1(math.pi/float(2**(j-k)), q[j], q[k])
circ.h(q[j]) q = QuantumRegister(3)
c = ClassicalRegister(3)
qft3 = QuantumCircuit(q, c)

input_state(qft3, q, 3)
qft(qft3, q, 3)
for i in range(3):
qft3.measure(q[i], c[i])
print(qft3.qasm())

run on local simulator

backend = Aer.get_backend("qasm_simulator")

simulate = execute(qft3, backend=backend, shots=1024).result()
simulate.get_counts()`

Incorrect output for QFT

This code was taken from here I changed some import statements because they were outdated and now the qft is returning 111 instead of 001 for inputs of all 0's. The output for qft3.quasm reads:
OPENQASM 2.0; include "qelib1.inc"; qreg q0[3]; creg c0[3]; h q0[0]; u1(3.14159265358979) q0[0]; h q0[1]; u1(1.57079632679490) q0[1]; h q0[2]; u1(0.785398163397448) q0[2]; h q0[0]; cu1(1.57079632679490) q0[1],q0[0]; h q0[1]; cu1(0.785398163397448) q0[2],q0[0]; cu1(1.57079632679490) q0[2],q0[1]; h q0[2]; measure q0[0] -> c0[0]; measure q0[1] -> c0[1]; measure q0[2] -> c0[2];
As oppose to the original:
OPENQASM 2.0; include "qelib1.inc"; qreg q0[3]; creg c0[3]; h q0[0]; u1(-3.14159265358979) q0[0]; h q0[1]; u1(-1.57079632679490) q0[1]; h q0[2]; u1(-0.785398163397448) q0[2]; h q0[0]; cu1(1.57079632679490) q0[1],q0[0]; h q0[1]; cu1(0.785398163397448) q0[2],q0[0]; cu1(1.57079632679490) q0[2],q0[1]; h q0[2]; measure q0[0] -> c0[0]; measure q0[1] -> c0[1]; measure q0[2] -> c0[2];
I believe the problem is here but I cant seem to solve it, if anyone could help that would be great, thanks!

`import math

# importing Qiskit
from qiskit import Aer, IBMQ
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit.providers.ibmq import least_busy

# useful additional packages 
from qiskit.tools.jupyter import *
from qiskit.tools.visualization import plot_histogram
provider = IBMQ.load_account()`


  # """n-qubit input state for QFT that produces output 1."""
`def input_state(circ, q, n):
    for j in range(n):
        circ.h(q[j])
        circ.u1(math.pi/float(2**(j)), q[j]).inverse()

def qft(circ, q, n):
  # """n-qubit QFT on q in circ."""
    for j in range(n):
        for k in range(j):
            circ.cu1(math.pi/float(2**(j-k)), q[j], q[k])
        circ.h(q[j])`
`q = QuantumRegister(3)
c = ClassicalRegister(3)
qft3 = QuantumCircuit(q, c)

input_state(qft3, q, 3)
qft(qft3, q, 3)
for i in range(3):
    qft3.measure(q[i], c[i])
print(qft3.qasm())`
`# run on local simulator
backend = Aer.get_backend("qasm_simulator")

simulate = execute(qft3, backend=backend, shots=1024).result()
simulate.get_counts()`
`%%qiskit_job_status

# Use the IBM Quantum Experience
backend = least_busy(IBMQ.backends(simulator=False))
shots = 1024

job_exp = execute(qft3, backend=backend, shots=shots)`
`results = job_exp.result()
plot_histogram(results.get_counts())`

Add input to QFT

Provide input method?

Hi, I am now using QISKit to realize quantum fourier transform. I run the code provided by you in this link.

The input state is set to 000 by default. Is there any methods to change the input to a different value one that can be in a superposition of selected states going in

Could you please answer my question? Thank you so much!

Replace `load_accounts` with `load_account`

Hi,

I noticed in the "Hello zero" tutorial that you use the load_accounts method of qiskit.IBMQ.

This method is deprecated and throws the following exception in qiskit-0.24.0:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'IBMQFactory' object has no attribute 'load_accounts'

Instead, load_account is used. You may want to find all instances of using load_accounts and change them to load_account.

Missing invocation of np.sin in custom_feature_map.ipynb

It seems to me the definition of custom_data_map_func in custom_feature_map.ipynb
does not correspond to the mathematical expression.

coeff = x[0] if len(x) == 1 else functools.reduce(lambda m, n: m * n, np.pi - x)

gives the default function, when it should be
coeff = x[0] if len(x) == 1 else functools.reduce(lambda m, n: m * n, np.sin(np.pi - x))

to be consistent with the text.

QuantumInstance spawns multiple jobs

Hi. I am noticing a weird behavior when submitting algorithm via QuantumInstance API.

image

This action somewhat spawns multiple jobs in sequential manner. I wonder if this is expected.

image

Ps. similar behavior is observed when submitting algorithm via QuantumInstance API to Amazon Braket.

Please advise.

Job incurred error

The code is incurring error when it has been run on ibmq_16_melbourne (as mentioned in the tutorial code).
ibmq_melbourne_16 error

However, it runs perfectly on the ibmq_qasm_simulator.
ibmq_qasm_simulator Success

No other ibmq computer is able to run the same code without error.

making a binder image

@aasfaw if you want to make a binder image from this you will need a file apt.txt with the following. I am not suggesting that you do it but this is how we made the binder image on the old tutorials and if you want to repeat it here this is the file you need.

texlive-latex-base
texlive-latex-recommended
texlive-science
texlive-latex-extra
texlive-fonts-recommended
dvipng
ghostscript
poppler-utils

IBMQ_Santiago is the default backend listed on the getting-started.ipynb, Santiago is retired

I think it would be more straightforward to put an active backend in on the getting started notebook, or even use aer_simulator. If I can get assigned to this issue, I will put in a PR changing the new default for the file to IBMQ_Manila. This one is active and should work for the purposes of getting started. However, I'm not sure if we want to direct all the traffic from the getting started page to Manila so correct me if that's wrong.
I also believe there should be an IBMQ.save_account() call with your API key in the getting-started account. I put that in the pull request as well.

Error while doing the composing quantum on Jupyter Lab

Hello all,

I am looking for this problem: ibm-q-lab-widgets could not be loaded, causing the failure of the composer.

Platform
OS: Ubuntu 22.04 LTS on WSL 1
IPython: 8.11.0
ipykernel : 6.22.0
ipywidgets: 8.0.5
jupyter_client : 7.4.1
jupyter_core : 5.3.0
jupyter_server : 1.23.6
jupyterlab : 3.6.2
nbclient: 0.7.2
nbconvert: 7.2.10
nbformat : 5.8.0
notebook: 6.5.3
qtconsole: not installed
traitlets: 5.9.0

Error details is here:

[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class 'CircuitComposerModel' from module '@quantum/ibm-q-lab-widgets'
Error: No version of module @quantum/ibm-q-lab-widgets is registered
    at f.loadClass (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.c61b95b04e00f8487eeb.js?v=c61b95b04e00f8487eeb:1:74856)
    at f.loadModelClass (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:10729)
    at f._make_model (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:7517)
    at f.new_model (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:5137)
    at f.handle_comm_open (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/150.267f129ae5fd6a33b390.js?v=267f129ae5fd6a33b390:1:3894)
    at _handleCommOpen (http://localhost:8000/user/ admin/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.c61b95b04e00f8487eeb.js?v=c61b95b04e00f8487eeb:1:73393)
    at b._handleCommOpen (http://localhost:8000/user/ admin/static/lab/jlab_core.48a41b637653e18e773e.js?v=48a41b637653e18e773e:2:1039756)
    at async b._handleMessage (http://localhost:8000/user/ admin/static/lab/jlab_core.48a41b637653e18e773e.js?v=48a41b637653e18e773e:2:1041746)

QSVM+Image classification+ DCP errors

. I use QSVM to classify image dataset โ€ฆ I don't understand this error, How to fix it.
error display


DCPError Traceback (most recent call last)
in ()
5 svm.random_seed = 10598
6 quantum_instance = QuantumInstance(backend, shots=1024, seed_simulator=10598, seed_transpiler=10598)
----> 7 result = svm.run(quantum_instance)

9 frames
/usr/local/lib/python3.6/dist-packages/cvxpy/reductions/solvers/intermediate_chain.py in construct_intermediate_chain(problem, candidates, gp)
94 append += ("\nHowever, the problem does follow DQCP rules. "
95 "Consider calling solve() with qcp=True.")
---> 96 raise DCPError("Problem does not follow DCP rules. Specifically:\n" + append)
97
98 elif gp and not problem.is_dgp():

DCPError: Problem does not follow DCP rules. Specifically:

qiskit-aer-gpu is not working

#code
from qiskit import *
from qiskit.circuit.library import *
from qiskit_aer import *

sim = AerSimulator(method='statevector', device='GPU')

qubits = 5
depth=2
shots = 5

circuit = QuantumVolume(qubits, depth, seed=0)
circuit.measure_all()
result = execute(circuit,sim,shots=shots,seed_simulator=123).result()

print("{0} qubits Quantum Volume, Simulation Time = {1} sec".format(qubits,result.to_dict()['results'][0]['time_taken']))
counts = result.get_counts()
print(counts)
#output
RuntimeError: Simulation device "GPU" is not supported on this system
i have installed required packages and also i have nstalled cuda

Generative adversarial network for RGB image with qskit

i would like to get this code working in order to generate RGB images (64x64x3) with GAN in qskit.
I started from this code: https://qiskit.org/ecosystem/machine-learning/tutorials/04_torch_qgan.html
But this is not for images. I have problems with the generator because in the tutorial does not receive any noise as input, while I think it is necessary in GAN for images. How can I change the generator?
Is the quantum qskit circuit suitable for my purpose?

Quantum-Coin-Game.ipynb does not in interactive mode on binder

Informations

  • Qiskit version: current
  • Python version: current
  • Operating system: any

What is the current behavior?

When starting community/games/Quantum-Coin-Game.ipynb in binder it does not start the RISE interface, which is needed to play the game interactively.

Steps to reproduce the problem

start https://mybinder.org/v2/gh/qiskit/qiskit-tutorials/master?filepath=community/games/Quantum-Coin-Game.ipynb
and compare to
https://mybinder.org/v2/gh/JanLahmann/Fun-with-Quantum/master?filepath=Quantum-Coin-Game.ipynb

What is the expected behavior?

The game should automatically start the interactive RISE interface.
This is needed to play the game interactively.

Suggested solutions

add rise to environment.yml

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.