qiskit-community / qiskit-community-tutorials Goto Github PK
View Code? Open in Web Editor NEWA collection of Jupyter notebooks developed by the community showing how to use Qiskit
License: Apache License 2.0
A collection of Jupyter notebooks developed by the community showing how to use Qiskit
License: Apache License 2.0
I'm getting error "Invalid param type <class 'complex'> for gate initialize_dg." when running the notebook with inverse=True
This link is broken from index.md:
Superposition
quantum tic tac toe
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.
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
#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
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.
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
The game should automatically start the interactive RISE interface.
This is needed to play the game interactively.
add rise to environment.yml
URL of QISKit Community Tutorial (https://github.com/Qiskit/qiskit-tutorials/tree/master/community/games) broken in Quantum-Coin-Game.ipynb
-> update it to https://github.com/Qiskit/qiskit-community-tutorials/tree/master/games
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.
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?
I was looking at the tutorial in community to create a random number (uniform law), and found the one in Cryptography.
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!
plot_histogram(result.get_counts(circuit))
as per the representation the result of writing above code should give the graph in probability but, I am getting values in counts.
The link to see more detailed examples of generating random variates from various distributions using Qiskit aqua in the readme file of https://github.com/qiskit-community/qiskit-community-tutorials/tree/master/Cryptography is broken
Code from here not sure what happened when I tried to run it thanks for the help!
`import math
from qiskit import Aer, IBMQ
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit, execute
from qiskit.providers.ibmq import least_busy
from qiskit.tools.jupyter import *
from qiskit.tools.visualization import plot_histogram
provider = IBMQ.load_account()`
`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())
backend = Aer.get_backend("qasm_simulator")
simulate = execute(qft3, backend=backend, shots=1024).result()
simulate.get_counts()`
Qubit chevron experiment is removed from qiskit-iqx-tutorials because the tutorial should consist of minimal set of experiments. see the discussion in Qiskit/qiskit-tutorials#780.
The removed experiment is still worth to show the capability of OpenPulse, and it should be transferred to the community tutorial.
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)
@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
. 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:
Most of the links on index.ipynb are dead.
In the coin game notebook, the following URL is mentioned, which is outdated:
https://github.com/Qiskit/qiskit-tutorials/tree/master/community/games
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
.
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!
Many files on the qiskit terra algorithms section https://github.com/qiskit-community/qiskit-community-tutorials/blob/master/algorithms/index.ipynb like Deutsch-Josza have this problem
https://render.githubusercontent.com/view/deutsch_jozsa.ipynb which is dead but they do open up when clicked directly. I think this behavior is also making people conclude that many of ipynb links are broken.
When starting games/Quantum-Coin-Game.ipynb in Binder it fails to build the Binder image.
(also for index.ipynb)
adjust pip Version in environment.yml (Qiskit 0.13.0 and above need pip version 19)
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())`
#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'
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.
Please provide arXiv link https://arxiv.org/pdf/1303.3557.pdf or APS link https://journals.aps.org/pra/abstract/10.1103/PhysRevA.87.062318 instead of current link which appear to be broken in the quantum walk tutorial notebook.
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
No module named 'qiskit.ml'
This repo contains Qiskit tutorials from the broad Qiskit community. However, without clear ownership and maintenance, it has slowly fallen behind in terms of PR reviews and issues.
Before archiving it, let's see if there is critical mass among the community members who have been contributing in the last few years: @pemmaras @aakif-akhtar @cpossel @AriaKilmorev
If you 🫵 would like to maintain it, please leave a comment with your contact info or contact me on Slack! You have time until the end of August 2024.
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.