Questions tagged [programming]

For any questions whose answer is expected to require code or programming notions. For questions about a specific framework (e.g. qiskit or cirq) please also include a more specific tag.

Filter by
Sorted by
Tagged with
3
votes
2answers
342 views

How many shots should one take to get a reliable estimate in a quantum program?

When testing my quantum programs, I wonder how many shots I must take to get a specific accuracy. Are there any papers that you can recommend that analyze this?
2
votes
1answer
682 views

Question About How Qiskit Reset Gate Affects Other Entangled Qubits

I am trying to understand how the reset gate in Qiskit affects qubits its entangled with. Consider the following circuit with qubits $q_0$ and $q_1$: Where circuit240 takes $|0\rangle$ to $a|0\rangle ...
2
votes
2answers
240 views

Unit testing for quantum programs?

Does unit testing on real quantum computers make sense as any observation in the quantum system can cause the system to loose its superposition state?
11
votes
1answer
447 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
2answers
302 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 ...
8
votes
1answer
2k views

Can I remove gates from a QuantumCircuit?

Suppose I want to implement run several circuits one after another, but they are constructed in a similar fashion. I could reinstantiate a QuantumCircuit for each ...
7
votes
3answers
884 views

How do you send an array of qubits to an operation in Q#?

I have the following operation in my .qs files: operation myOp(qubits: Qubit[]) : () { // uses elements from the qubit array } How do I send an ...
7
votes
1answer
834 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.
6
votes
1answer
253 views

How efficient is Qiskit's unitary decomposition?

In Qiskit's extension package we have the UnitaryGate module that you can initialize using a unitary matrix and then add it to your circuit. How efficiently is this ...
6
votes
1answer
2k 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 ...
6
votes
1answer
497 views

Custom gates on IBM Q

I realized that QASM supports custom gates. However, when I tried to create the gate, transpiling error appeared both on simulator and real quantum processor. I suspect that IBM has not implemented ...
6
votes
3answers
953 views

What is the location of the Qiskit config file?

I'm trying to follow the instructions here https://qiskit.org/documentation/getting_started.html. It says The default backend for qiskit.visualization.circuit_drawer() or QuantumCircuit.draw() is ...
5
votes
1answer
1k views

How to make circuit for n-control Z gate( i.e $C^3Z$ )?

I am trying to make circuit for $C^3Z$ gate I have seen a circuit for $C^2Z$ or $CCZ$ gate made by using $CCX$ gate so is there any way to make circuit for $C^3Z$ in this similar manner( i.e by using $...
4
votes
2answers
298 views

How to repeat circuit efficiently and reliably in IBM Qiskit?

I'm having a problem in IBM Qiskit with my qubit identities switching places during transpilation. I've been told by developers on the Qiskit slack server that there's currently no built-in way to fix ...
4
votes
1answer
610 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:...
4
votes
1answer
309 views

Calculating the ground states of an Ising Hamiltonian on a real quantum computer

I have followed this tutorial and based on it, I've written the following function in qiskit, which can explicitly calculate the ground states of a transverse-field Ising Hamiltonian. ...
4
votes
1answer
114 views

Simulating flag qubits and conditional branches using Stim

In a quantum error correcting code using flag qubits, it's common to have flag measurements that tell you it's necessary to do some extra measurements for safety. So, for example, I want to say: ...
4
votes
1answer
430 views

How to find a common eigenstate of commuting operators?

I have multiple different operators in matrix form and I need to find their common eigenstates. The challenge is that the common eigenstate is in a superposition of multiple states and isn't just a ...
4
votes
2answers
314 views

Preparing Bell state $(1/\sqrt{2}) (|01\rangle + |10\rangle)$ in Qiskit

I'm working through the Qiskit textbook right now, and wanted to complete part 1 of exercise 3.4, which asks me to use qiskit to produce the Bell state: $$\frac{|01\rangle + |10\rangle}{\sqrt{2}}$$ ...
3
votes
1answer
815 views

Import from qiskit-aqua error

I try to use Quantum SVM kernel algorithm: multiclass classifier extension. This is my code section with imports ...
3
votes
1answer
589 views

What is the difference between Qiskit execute and the IBMQJobManager?

I was researching how to submit multiple pulse schedules/circuits in the same job and came across 2 methods: Executing Experiments with qiskit.execute and ...
3
votes
1answer
209 views

Qiskit installation

I'm trying to get started with Qiskit but the installation process has been horrendous and the official instructions are unusable. The latest python doesnt work with the install instructions at: https:...
3
votes
3answers
711 views

How can I create an arbitrary superposition state of two qubits in Qiskit?

I am trying to produce any arbitrary superposition state of two qubits, for example $a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$, such that $a^2 + b^2 + c^2 + d^2 = 1$ . How can I do that ...
2
votes
1answer
77 views

How can I print out the probability of a certain state in histogram?

This is a simulation I did in my program. I'm hoping to print out the probability of the state $|0001\rangle$ (which is $0.052$), and store this number in a letter (a). How can I do this? Thanks!!
2
votes
1answer
92 views

How do Hadamard and CNOT gates work on Qiskit SDK? Why is the output reversed?

Here is the code that I have been using on IBM Q Experience (should be the latest version of Qiskit). From my understanding it seems like the outputs of Hadamard and CNOT gates are reversed in a 2-...
2
votes
1answer
104 views

What is the convention of indices for the one and two-body integrals in qiskit

I was able to calculate the one and two-body integrals for the H2 with the following code ...
2
votes
1answer
96 views

How to use Initial States in Qiskits QAOA?

The class QAOA from qiskit: https://qiskit.org/documentation/stubs/qiskit.aqua.algorithms.QAOA.html has the parameter initial_state from the type InitialState. https://qiskit.org/documentation/apidoc/...
2
votes
2answers
159 views

qiskit: IQFT acting on subsystem of reversed-ordered qubits state

I have a state psi as an ndarray of shape (2 ** 3,) s.t. psi[0]= amplitude of 000 ...
2
votes
1answer
149 views

Is it possible to implement c_if statement based on a measurement in a single specified classical bit in qiskit?

I'm trying to write a 1-bit teleportation error correction code and there is one part in it where I need to add a gate that's dependent on a measurement from earlier in the circuit. The measurement ...
1
vote
1answer
102 views

Why is local qasm simulation taking so long for VQE?

I've successfully run the $LiH$ VQE simulation detailed in Simulating Molecules using VQE using the statevector_simulator, however when attempting to run the same ...
1
vote
0answers
261 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
531 views

Finding minimum with Grover

I am a beginner in quantum computing. I have already computed the sat quantum solver with Grover search and then, I would like to compute the "minimum search" of Dür and Hoyer. My question is: Is it ...
0
votes
0answers
33 views

How to perform multi-class classification with qiskit's VQC?

I am following the tutorial given in qiskit's website Neural Network Classifier and Regressor. In the first part, classification, the third section refers to qiskit's VQC library. Everything works ...
0
votes
1answer
96 views

Does Qiskit transpiler execute multiple circuits in parallel? [closed]

I have something to ask about Qiskit's transpiler. Before that, please check this document. ...
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 ...
8
votes
2answers
189 views

How does one obtain amplitude information in Q#?

Is it possible to obtain amplitude information (in lexicographic ordering) for a particular qubit register in Q#? For example, in the following code: ...
7
votes
3answers
682 views

Qubit Connectivity of IBM Quantum Computer

When simulating a quantum circuit using the qiskit qasm_simulator, the qubits that you assign to the quantum circuit may be ...
6
votes
2answers
490 views

How do we code the matrix for a controlled operation knowing the control qubit, the target qubit and the $2\times 2$ unitary?

Having n qubits, I want to have the unitary described a controlled operation. Say for example you get as input a unitary, an index for a controlled qubit and another for a target. How would you code ...
5
votes
1answer
84 views

CERTIFICATE_VERIFY_FAILED after updating Python when trying to access results in IBM QE

I had a question earlier about the Numpy DeprecationWarning flooding issue. I just updated the Python in my regular jupyter notebook and have trouble running the following cell: ...
5
votes
1answer
153 views

How to read the unitary matrix of a quantum circuit in ProjectQ?

I would like to read the unitary matrix of a quantum circuit in ProjectQ. Is there any way to do it?
4
votes
3answers
4k views

Overview of Cirq, qiskit, q#, ibmq(circuit board), other [closed]

What is the difference between these frameworks or languages? What are the pros and cons of each of these? Do you know any similar framework/platform/language that gives some more advantages?
4
votes
1answer
79 views

Measure $\langle \hat{X}\rangle$ and $\langle \hat{Y}\rangle$ from counts

I'm confused about how I can measure $\langle \hat{X}\rangle$ and $\langle \hat{Y}\rangle$ using counts. Here's my code for X: x-basis: ...
4
votes
1answer
897 views

How to set a starting state in cirq?

I'm learning how to use the cirq library. Every time I set up a circuit the starting state of the qubits is $|0000..0\rangle$. Is there any way to make the starting state different? I'm thinking of ...
4
votes
2answers
2k 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: ...
4
votes
1answer
221 views

Defining a custom parametric gate in Qiskit in terms of standard gates?

Here it is explained how to define a custom non-parametric gate in Qiskit. How do I define a new parametric gate? For example, I want to have the $CCR_y$ gate defined as in order to use it as ...
4
votes
1answer
88 views

Filtering a set of results obtained from job manager

I've already generated a filter for readout error mitigation: ...
3
votes
1answer
202 views

Can I access device specifications of IBMQ paying devices?

I need to perform some tests for my thesis in real quantum computers, however, I only have access to IBM's free quantum devices (the maximum number of qubits I can use is 15, in ...
3
votes
2answers
92 views

Why "job_manager" did not submit some of the jobs?

I tried to submit around 2000 circuits with "job_manager", and it turns out that some jobs are not submitted. Please see the code and error message below. I understand that we can submit max ...
3
votes
2answers
214 views

Qiskit: count the type of gates on the qubit with the largest number of gates in a multi-qubit circuit

I would like to know the number and type of all the gates on the wire/qubit with the largest operations in a quantum circuit with multiple qubits. Is there any inbuilt functionality, or what is the ...
3
votes
2answers
771 views

How to initialize a qubit with a custom state in Qiskit Composer

I'm trying to initialize a qubit with a custom state in IBM's Qiskit Composer. I wrote the code in the Qiskit Lab and obtained the QASM code as shown below ...