Questions tagged [qiskit]

Quantum Software Development Kit for writing quantum computing experiments, programs, and applications. If appropriate, also use the [programming] tag.

Filter by
Sorted by
Tagged with
19
votes
3answers
5k views

How can I implement an n-bit Toffoli gate?

I want to create a Toffoli gate controlled by n qubits, and implement it in QISKit. Can this be done? If so, how?
10
votes
5answers
4k views

How do I build a gate from a matrix on Qiskit?

I'm creating a gate for a project and need to test if it has the same results as the original circuit in a simulator, how do I build this gate on Qiskit? It's a 3 qubit gate, 8x8 matrix: $$ \frac{1}{...
7
votes
1answer
1k views

What are theta, phi and lambda in cu1(theta, ctl, tgt) and cu3(theta, phi, lam, ctl, tgt)? What are the rotation matrices being used?

I was reading the documentation for qiskit.QuantumCircuit and came across the functions cu1(theta, ctl, tgt) and ...
3
votes
2answers
483 views

Given a state $|\phi\rangle=\frac{1}{\sqrt{2}}(|0\rangle+e^{i\theta}|1\rangle)$, how do I know the angle $\theta$?

Question1. If there is a state $|\phi\rangle=\frac{1}{\sqrt{2}}(|0\rangle+e^{i\theta}|1\rangle)$, and I want to know the angle $\theta$. What kind of measurement should I do? Could somebody give me ...
3
votes
2answers
369 views

Big Endian vs. Little Endian in Qiskit

I've noticed that Q# favors Little Endian. Meaning that most operations are designed for this type of encoding. Is is it the same with Qiskit?
1
vote
1answer
321 views

Evaluating expectation values of operators in Qiskit

I'm wondering how in Qiskit one can calculate the expectation value of an operator given as a WeightedPauli (or, at least, of a single ...
7
votes
1answer
3k views

How to create an arbitrary state in QISKit for a local_qasm_simulator?

I would like to play with a quantum circuit local_qasm_simulator in QISKit, but I do not want to implement a separate quantum circuit that would prepare an initial ...
3
votes
2answers
560 views

How to decompose this two-qubit unitary matrix to the standard gate set?

I have read some of the other decomposition questions here however still don't understand how to do it manually. The matrix I wish to decompose is the following for 2 qubits: $M=\frac{1}{\sqrt2}\...
3
votes
1answer
246 views

How to use external .csv data file in quantum support vector machine qiskit python code?

I am new to python programming and Qiskit. I would like to ask can we use sklearn for adding external .csv data file before Qiskit libraries, or without sklearn, we can do or is there any other Qiskit ...
7
votes
1answer
388 views

SWAP gate(s) in the $R(\lambda^{-1})$ step of the HHL circuit for $4\times 4$ systems

Context: On the 5th page of the paper Quantum circuit design for solving linear systems of equations (Cao et al, 2012) there's this circuit: Schematic: A brief schematic of what's actually ...
2
votes
2answers
211 views

Mitigating the noise in a quantum circuit

I'm using Qiskit and I have a Quantum Circuit (say, circuit) that gives reasonable results when using the simulator, namely ...
1
vote
2answers
63 views

quantum random number generator implementation in quantum lab

How can I generate and print a 32 bit sequence of 0s and 1s in Qiskit or IBM Q experience quantum lab using quantum random number generator implementation?
7
votes
3answers
3k views

How to quickly calculate the custom U3 gate parameters $\theta, \phi$ and $\lambda$ for any unitary?

In IBM Qiskit and Quantum Experience, the custom U3 gate is defined as $$ U(\theta, \phi, \lambda) = \begin{pmatrix} \cos\left(\frac{\theta}{2}\right) & -e^{...
8
votes
1answer
2k views

What is a “barrier” in Qiskit circuits?

I just started studying IBM Qiskit, and cannot find details about the barrier method on the QuantumCircuit class. It is shown in the circuit drawing, but I never heard about it after reading quantum ...
9
votes
3answers
506 views

Does conditional gate collapse controller's superposition?

I've created a simple circuit in Q-Kit to understand conditional gates and outputted states on each step: In the beginning there is clear 00 state, which is the input The first qubit is passed ...
5
votes
2answers
344 views

Checking value of variable using quantum approach

A beginner question after watching few videos. Say, var=a; var can be either of two values, ...
3
votes
1answer
313 views

How good is basic_device_noise_model() simulating the noise in the quantum computer?

Is there any paper or article about the performance of the noise model using basic_device_noise_model()? For example, like the noise model in the code below. ...
9
votes
2answers
1k views

Quantum algorithm for linear systems of equations (HHL09): Step 2 - Preparation of the initial states $|\Psi_0\rangle$ and $|b\rangle$

This is a continuation of Quantum algorithm for linear systems of equations (HHL09): Step 2 - What is $|\Psi_0\rangle$? In the paper: Quantum algorithm for linear systems of equations (Harrow, ...
8
votes
2answers
212 views

Construct Controlled-$G^{\dagger}$ from known Controlled-$G$

Let there be a known a scheme (quantum circuit) of Controlled-G, where unitary gate G has G$^†$ such that G≠G$^†$ and GG$^†$=I (for example S and S$^†$, T and T$^†$, V and V$^†$, but not Pauli and H ...
7
votes
2answers
384 views

Why do we need a Classical Register for carrying out Quantum Computations?

I've just started to mess about with QISKit on Python and one thing is confusing me a fair bit. Given that we are building Quantum Circuits what is the need for a classical register ? Is it because ...
6
votes
1answer
1k views

How would one implement a quantum equivalent of a while loop in IBM QISkit?

I'm writing a simple multiplication algorithm that uses the Quantum Fourier Transform to repetitively add a number (the multiplicand) to itself and decrements another number (the multiplier). The ...
5
votes
1answer
1k views

Get result measurement into a circuit with Qiskit

I'm trying to implement the three qubit bit flip code in Qiskit. Therefore, I need to get the result of a measure of two ancilla qubits, to deduce which gate I need to use do recover my logical qubit....
4
votes
2answers
185 views

How to implement the CCH gate in quantum computers available in clouds?

How to implement CCH gate in quantum computers available in clouds? If there is not any gate directly available for it, what are the possible ways to represent CCH?
2
votes
1answer
642 views

How to implement if statement based on measurement results in qiskit?

I tried to implement three qubit bit flip code in qiskit and need to get the result of measurements and then apply recovery quantum operations conditioned on the measurement results. The following is ...
1
vote
1answer
83 views

Are $\mathrm{cRz}$ with angle $\pi$ and $\mathrm{cZ}$ equal on the IBM Quantum Experience?

I was trying to implement the 2-qubit Grover algorithm without the auxiliary bit. Before finding the gate symbol for the controlled $\mathrm{Z}$, I worked with the controlled $\mathrm{Rz}$. The gate ...
1
vote
1answer
89 views

$\lambda$ parameter for U3 gate in qiskit Bloch sphere visualisation

It is easy to see how $\theta$ (rotation from the positive z-axis) and $\varphi$ (rotation from the positive z-axis) affect the initial state of the qubit when looking at the Bloch sphere but I have ...
9
votes
1answer
333 views

Submitting jobs to IBM devices without Python

Qiskit can be used to submit jobs to IBM devices using Python (or Swift and JavaScript). But what if I want to use a different language? For example, suppose I have a specific circuit I want to run. ...
8
votes
1answer
2k views

Visualization of Quantum Circuits when using IBM QISKit

I have followed the installation steps, regarding QISKit working environment. For circuit visualization, I've installed latex as in addition to poppler to convert from PDF to images. Afterwards, I ...
6
votes
1answer
449 views

What is the purpose of the TDG gate in QISKit?

The QISKIT documentation doesn't explain what a TDG gate does and I can't find it anywhere else online.
5
votes
1answer
287 views

Getting a layout for qubits in Qiskit

I'm trying to use Qiskit's built in transpiler passes to do the following. I would like to take a quantum circuit and allocate the logical qubits to physical qubits. The tutorial doesn't really ...
4
votes
2answers
1k views

Comparing run times on IBM Quantum Experience

I have run this program - ...
4
votes
1answer
486 views

How can noise on a device be simulated using measured noise parameters?

The real devices used as backends for Qiskit have calibration data that quantifies errors ($T_1$ and $T_2$, gate fidelities, etc). This can be accessed by, for example ...
4
votes
3answers
426 views

Access results from an experiment without having to run the script again

I have ran an experiment in one of the IBM processors and the work has finished. However, I can not obtain the data as histograms or counts in the qiskit notebook because the experiment was concluded ...
3
votes
2answers
121 views

How to measure in the bell basis?

The question is quite straightforward, I have some two qubit state and I want to measure it in the Bell basis. This question answers me partly, but I still have some doubts because, I thought that ...
3
votes
1answer
345 views

Implementing a complex circuit for a Szegedy quantum walk in qiskit

Problem definition I'm implementing a quantum circuit in qiskit for a Szegedy quantum walk, (reference, Fig 21.). It uses two registers of dimension $N$ ($N=3$) each one. The challenges I'm facing are:...
3
votes
2answers
106 views

Making custom gate in Qiskit?

I have been trying to make a gate in qiskit in terms of the basic gates, but I keep on getting an error when I apply it to a circuit. This is my gate: ...
3
votes
2answers
390 views

Why won't Qiskit ccx gate accept registers?

In Qiskit, they have the concept of a Toffoli gate (ccx). However, the following code throws an error: ...
3
votes
3answers
316 views

How can we construct a square root of NOT gate in Qiskit and IBMQ circuit composer using universal gates?

I have tried it with decomposing controlled S then conjugating with H gate. But I want to construct it using a minimum number of gates.
3
votes
1answer
171 views

How does the cnx gate work in Qiskit (Python)?

Could somebody explain the cnx operator, and how it operates on its qubit parameters to flip the target qubit in Qiskit (Python)?
3
votes
1answer
225 views

Qiskit in Julia language?

Is it possible to use Qiskit in Julia language? Or is there any wrapper that can be used to call the package from Julia language?
2
votes
1answer
33 views

Specifying qubits to achieve measurement error mitigation on Qiskit

I'm learning how to do error mitigation on Qiskit as my experiment result differs from the simulated result. I read the tutorial here, but I have some questions about it. If I have understood it ...
2
votes
2answers
87 views

Qiskit error on get_backend()

Im trying to use IBM quantum machine instead of qiskit aer simulator with the following command: backend = IBMQ.get_backend('ibmq_16_melbourne', 'ibm-q') It's ...
1
vote
0answers
253 views

Decomposition of an arbitrary gate using given matrix in Qiskit

If I have an arbitrary non-unitary matrix of say $$ U = \begin{pmatrix} 1.5 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1.6 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ \end{...
1
vote
0answers
55 views

Regarding quantum support vector machine using qiskit [duplicate]

I would like to ask, how can I add my own .csv data file to run a quantum support vector machine using qiskit ? I don't want to use already existing datasets in sklearn, scikit-learn library.
1
vote
1answer
285 views

How to run the Qiskit Aer simulator without noise?

I know that the Qasm Simulator execute quantum circuits with presence of noise, even if I do not specify the model of noise in options for that backend. But how can I execute the circuits without ...
1
vote
1answer
28 views

Qiskit visualizations module not installed but qiskit package installed. Why?

I am trying to set up my qiskit environment but I seem to have run in trouble that I have no idea how to solve. I have installed the qiskit packages as can be seen by running ...
1
vote
2answers
169 views

How can the state $\lvert0\rangle+M^{-1/2}\sum_{j=1}^M\lvert j\rangle$ be generated?

I was wondering if anybody to help me to generate the following state. It would be preferable if you use only Hadamard, CNOT and T-gates, on $\lceil\log_2(M+1)\rceil$ qubits: $$|\psi\rangle = \frac{1}{...
1
vote
2answers
839 views

Cannot load account with Qiskit

I just got started with Qiskit. When I tried to save my account with the API token from IBMQ website, I got the error: ...
1
vote
0answers
132 views

A question about qiskit's WeightedPauliOperator.evolve method for IPEA (IQPE) implementation

I'm doing an implementation/tutorial of the iterative phase estimation algorithm (IPEA) and have a problem. My Hamiltonian is a diagonal matrix $H = \begin{pmatrix} E_1 & 0 \\ 0 & E_2\end{...
1
vote
1answer
63 views

How to create a qubit in arbitrary state in qiskit

A QuantumCircuit() command creates a qubit with zero state always. I've seen some instructions about using Arbitrary Initialization but it is not accessible and ...