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
1answer
136 views

HHL - the result is correct for one matrix but wrong for another one

I tried to run HHL algorithm in new version of Qiskit (0.29). Firstly I tried to solve a diagonal system 4x4 with matrix [[1,0,0,0],[0,2,0,0],[0,0,3,0],[0,0,0,4]] ...
4
votes
2answers
323 views

Cannot get a provider from IBMQ

My code is: from qiskit import IBMQ IBMQ.load_account() provider = IBMQ.get_provider('ibm-q') qcomp = provider.get_backend('ibmq_16_melbourne') but ...
2
votes
1answer
142 views

Simulating OpenQASM 2.0 in Qiskit?

I'm just getting started with OpenQASM, but I'm feeling a bit confused. Is there a way to run the .qasm file I've written in Qiskit (i.e. in Python), or is OpenQasm ...
6
votes
0answers
144 views

AWS Braket Backend for Qiskit?

Is there a working AWS Braket backend provider for Qiskit 0.29 that can be used with the MinimumEigenOptimizer interface? The qiskit-aws-braket-provider package is unfortunately not working.
1
vote
1answer
111 views

Does anyone have some references on EigenGate used in Google's cirq framework?

I am trying to understand the code below but can not find any references other than the code itself. https://github.com/quantumlib/Cirq/blob/v0.11.1/cirq-core/cirq/ops/eigen_gate.py I am not clear ...
1
vote
1answer
70 views

Can I extract information from a single shot efficiently?

I'm running a quantum simulation and want to obtain some information from a single shot of an experiment. Here's part of the code I'm working on: ...
1
vote
1answer
105 views

QAOA Optimization

I want to use historical data for 5 stocks from YahooFinance and then calculate mean vector and covariance matrice, so I can optimize them with QAOA. Anyone know what is wrong with this code:
0
votes
0answers
43 views
0
votes
1answer
46 views

Initialization time for StatevectorSimulator Qiskit

I have a question about initializing a quantum circuit to a custom state using Qiskit's StatevectorSimulator(). My naive understanding is that eventually, the ...
2
votes
1answer
111 views

Python shorthand for tensor product (Kronecker product)

When using numpy or tensorflow in Python, we can simply write C = A @ B for matrix ...
2
votes
2answers
159 views

IBM Quantum: Are ibmq_5_yorktown and ibmqx2 different devices?

When I run provider.backends(), ibmqx2 is listed as an available backend, but is not listed on the IBMQ systems page. This file ...
1
vote
1answer
75 views

Define customized excitation for the unitary coupled-cluster (UCC) algorithm in qiskit

I encountered the issue that when defining my customized excitation list in the UCC algorithm, there was only one parameter. How to fix this so that the algorithm assign one parameter for each ...
2
votes
1answer
191 views

Keep receiving Error - AttributeError: 'QuantumCircuit' object has no attribute 'save_statevector'

I am attempting to code a feed-forward simulation of a QECC in Qiskit. Qiskit (to my knowledge) does not directly support feed-forward simulation, so I attempted a work-around. I call the simulator ...
1
vote
1answer
62 views

Defining native gate dictionary in pyGSTi

In pyGSTi in order to construct Randomized Benchmarking circuits, we first need to define a pspec object that contains information about the number of qubits, basis ...
4
votes
3answers
211 views

Software tools to train quantum circuits with parameters

I want to play with the following problem. Given a unitary $U$ with parameters $\theta$ I want to optimize these parameters to make $U$ match some target unitary $V$, i.e. to find $\operatorname{...
2
votes
1answer
122 views

Encoding Numeric data as a quantum circuit in TFQ

I am working on a dataset where I have 6 input features that are numbers in the range of 1 - 1000 that need to be encoded as a quantum circuit. I am using TensorFlow Quantum for my research. While I ...
2
votes
0answers
106 views

Applying projectors with mid-circuit measurements

I am trying to apply a non-unitary projector (see image) to my two-qubit quantum circuit using mid-circuit measurements. $$ \begin{pmatrix} 0 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 &...
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: ...
0
votes
1answer
38 views

Apply a custom gate to qubits in separate quantum registers

Let there be a custom gate (simply called gate that takes $N$ qubits as input. Also, let $A$ of those qubits be in first_register...
0
votes
1answer
53 views

Cirq QAOA Tasks returns "iteration over a 0-d array" error

I'm trying to understand how to use Recirq for QAOA, and I tried to run the notebook for tasks: https://quantumai.google/cirq/experiments/qaoa/tasks. But it gives a "iteration over a 0-d array&...
1
vote
1answer
36 views

Print runtime of an optimizer

I want to find the runtime of my program, i.e. the time it is in the quantum computer without queue time. However, I am using an optimizer so the code is a little different. ...
2
votes
2answers
482 views

Is it true that the way we must program Quantum Computers is through Total functions only, if so why?

I have read that the way we must program Quantum Computers is through Total functions only. Why is this the case? Is it because quantum circuits are less forgiving in terms of logical errors? Could ...
0
votes
1answer
37 views

How to use backend.run() with a constant pulse shape in order to get the results of a measurement?

I have formed a constant pulse and then I ran a measurement on the pulse. Now, I want to run a job to access the results of the measurement. Attached is a picture of the pulse and measurement. Now, at ...
0
votes
1answer
40 views

How to re-order logical qubit location into desired state?

Now, I'm studying about qubit mapping. When the mapping is done, the logical qubit will be randomly mapped to physical qubit. But I want to move the logical qubit location into desired state. For ...
1
vote
1answer
64 views

Integer factorization using Shor's Alorithm

I have question about Shor's algorithm, from I know it's for factorize an integer and can factorize big number with ease. I using Qiskit to try make a simple factorization program (with local ...
1
vote
0answers
43 views

Transform Fermionic operators to quantum circuit in qiskit

I am trying to realize a modified version of the UCCSD algorithm, which consists of combining multiple fermionic opeators to form a unitary tranformation U to act ...
1
vote
1answer
38 views

How to re-ordering physical qubit location into desired one?

Suppose original quantum circuit have 4 qubits and some quantum operation. Also suppose the result of original quantum circuit state is '1100'. Then apply qubit mapping then mapping state is like ...
2
votes
2answers
111 views

How to Implement a noisy identity gate on qiskit?

I can successfully implement the U gate (single qubit) on qiskit, but when I am trying for the identity operation it is not showing any differences with the ideal one .
1
vote
1answer
44 views

Matplotlib graphs are being duplicated each time

Simple UI question. I have installed qiskit according to the instruction and try to implement some basic operations. I have the issue that anything I plot appears twice. I am not sure why this is ...
-6
votes
2answers
52 views

How does one even get started in Quantum Computing, specifically building qApps? [closed]

I want to build a quantum application, qApp if you will; how does one go about figuring out the right use-case and best framework to turn to, to start building these things? Quantum REPL? How do I ...
1
vote
1answer
47 views

Job ids retrieval from ID. Big set of jobs

I'm in the need of running a lot of jobs in the IBM backends. If one likes to run in parallel two jobs (say, with two different parameters), I have seen in the Jobs ...
1
vote
1answer
52 views

Pack Header Error when using QAOAProgram [closed]

I want to use QAOAProgram from Qiskit in the following way: ...
0
votes
0answers
22 views

How would you measure an X gate with qiskit.pulse.builder.measure?

I am using this link: https://qiskit.org/documentation/stubs/qiskit.pulse.builder.measure.html for reference. How would you use the measure command in order for an X gate to be measured within the ...
1
vote
0answers
57 views

Thoughts in coding large and repetitive/non-repetitive quantum circuits?

Just out of curiosity, are there advances or directions on how to write a program (e.g. in qiskit) for a large number of qubits? Assuming that the number of gates ...
1
vote
1answer
48 views

About qiskit's error mitigation

In qiskit, the error correction using least squares is apparently in qiskit-ignis/qiskit/ignis/mitigation/measurement/filters.py, source code from github and reads: ...
0
votes
1answer
70 views

How to perform a plot histogram for a circuit?

I have created a circuit and I don't know how to plot a histogram. I tried to plot a histogram but it gives me output for 0000 case only, how to get to know the probability for all of the cases. The ...
1
vote
0answers
37 views

How do you verify the output of an X Gate within the Pulse gates framework?

I have found out how to create an X gate for a constant pulse within the Pulse gates framework found on this link: https://qiskit.org/documentation/tutorials/circuits_advanced/05_pulse_gates.html My ...
2
votes
1answer
100 views

"503: Server Unavailable. Your server appears to be down. Try restarting it from the hub". Help

This message is popping continuously for 2 days in my IBM Quantum lab. I have tried logging out and in again, restarting the browser, changing the internet connection, and changing the device but this ...
2
votes
1answer
72 views

Trouble when implement a self designed gradient in qiskit

everyone! I have trouble when implement a self-designed gradient to the VQE algorithm. The following code will pop the 'ListOp' object is not callable exception to the last line of the code when ...
1
vote
2answers
201 views

How to build a QAOA Ansatz

I saw there is a qiskit package called "QAOAAnsatz" https://qiskit.org/documentation/stubs/qiskit.circuit.library.QAOAAnsatz.html. But I didn't find out any tutorial related, so I have no ...
1
vote
1answer
72 views

Measuring the accuracy of a circuit output?

I have created a circuit and got the output which matches the truth table but, I'm not understanding the measuring the circuit output in terms of the probabilities, power or error. This is the circuit ...
1
vote
2answers
121 views

How do you map an X gate to a constant pulse?

I was wondering how to map an X gate to a constant pulse shape. This https://qiskit.org/documentation/tutorials/circuits_advanced/05_pulse_gates.html is the link that I am working off. It shows an ...
0
votes
1answer
95 views

Which Qiskit Aer ideal quantum circuit simulator to use when aer_simulator is no longer available?

Some Qiskit tutorials have aer_simulator in the code and I have noticed that this simulator is no longer available. ...
1
vote
2answers
107 views

Random accuracy using VQC and Iris dataset

Using the same seed (seed_simulator and seed_transpiler) I get different accuracy when running it several times. In Aqua library (from qiskit.aqua.algorithms import VQC) I solved it adding ...
1
vote
1answer
124 views

How to download from IBM Quantum lab folder of data .txt files all at once?

I have a script in the IBM Quantum lab which runs several jobs and stores the result of each job as a .txt file in a results folder. All I want to do is to download the folder of files. I cannot ...
0
votes
0answers
41 views

How does Qiskit's VQE encode binary digits into a solution from a given Hamiltonian?

So far I have been working with the VQE on different Hamiltonians that happened to have degeneracies, that is there were always at least two different global minima, because the Hamiltonians I was ...
1
vote
3answers
208 views

How to convert the output column vector or matrix into bra ket notation using python?

When using qiskit, we normally get the output inform of column vectors or matrix. But is it possible to convert then into bra ket notation using some python code? Can someone help me with this?
1
vote
1answer
59 views

Custom labelling of randomly generated unitaries in Qiskit

I'm writing a program in Qiskit involving the generation of Haar-random unitaries. Is there a way to label each unitary such that the label appears instead of 'unitary' when I draw the circuit? ...
1
vote
1answer
44 views

Qiskit: rounding with get_statevector does not work?

I am trying to follow some tutorials for Qiskit and came to the point where I wanted to get some statevector containing $1/\sqrt{2}$ with the following line of code: ...

1 2 3
4
5
25