Questions tagged [programming]

For questions relating writing code to be executed on a quantum computer. For questions using or about a specific programming language, consider using also a more specific tag.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

Numerical optimization of QRAC

I need to optimize a general version of 3$\rightarrow$1 QRAC where Bob is asked to retrieve one of the XOR combinations of the bits( If ABC is the given string to Alice, then Bob would be asked to ...
1
vote
2answers
104 views

Question about a circuit from “Quantum Computing for Computer Scientists”

I am trying to implement a basic quantum computing emulator. In the chapter on Grover's algorithm, we're shown the following circuit: They demonstrate Grover's algorithm with a function $f$ that ...
2
votes
1answer
56 views

Can I teleport a string of 0s and 1s?

I have recently started with quantum computing and created a quantum teleportation circuit to transmit a qubit state from q_0 to ...
3
votes
0answers
34 views

IBMQ backends: How can I know the repetition rate and depth limits of real devices?

When trying to execute complex quantum circuits on IBMQ real devices, one can encounter a typical error (ERROR_RUNNING_JOB) with the message ...
0
votes
1answer
16 views

Why do I get the error name operator is not defined?

I checked this code multiple times, I am trying to reproduce the same code using Grover's algorithm from qiskit summerschool: ...
0
votes
1answer
18 views

IBMQ: “Credentials are already in use”

Executing the following: ...
0
votes
2answers
44 views

Creating a parameterized Operator in Qiskit

I'm trying to run a VQE for a specific custom Anzats. The Anzats is built up of an unitary matrix $U_H$, which I'm trying to created in this way: ...
1
vote
0answers
35 views

Getting Choi-matrix of a subsystem

In Qiskit, for a given QuantumCircuit object, you can computed its Choi-matrix via the corresponding Choi object, for example: <...
2
votes
2answers
26 views

Creating a resource count unit test in Q#

I want to create a unit test in Q# that runs an operation and asserts that it used at most 10 Toffoli operations. How do I do this? For example, what changes do I have to make to the code below? ...
0
votes
0answers
14 views

Correctly configuring a Q# test project in Visual Studio Code

I have some Q# code which I'm editing using visual studio code. The codebase is divided into a src/ folder and a test/ folder. ...
0
votes
1answer
50 views

Quantum Circuit to inverse the probability distribution

I'm using Qiskit and after running the circuit, as we all know, we get a count dictionary such as ...
-1
votes
0answers
25 views

Code keeps running job after job

I'm attempting to to run a electronic ground state energy calculator, when I send a job to the real quantum computer it will wait in the queue, run the job, give me a histogram (on the quantum-...
2
votes
1answer
48 views

Physical implementing random unitary

If I from qiskit.quantum_info import random_unitary and then random_unitary(2**number_of_qubits) What returns is a unitary ...
0
votes
1answer
36 views

Error while trying to execute the Quantum Circuits in IBMQ

I have been trying to execute the quantum circuit in the backend of the IBM 16 qubit Melbourne machine. I end up getting ...
0
votes
1answer
40 views

Cirq.simulate expectation value of a Hamiltonian

I want to simulate the final state of an ansatz in cirq using simulate. Now I want to calculate the expectation value of a Hamiltonian. How do I do this? I can only find simulator.run examples in cirq....
-1
votes
1answer
47 views
1
vote
0answers
25 views

How to apply a operator to qubit system on the basis of current state of system?

Suppose I have three different operators $U_1, U_2,U_3$. Now, these three operators will be applied if my current state of the system is $|\psi_0\rangle,|\psi_1\rangle $ and $|\psi_2\rangle$ ...
-1
votes
1answer
39 views

How to calculate the exponential of all elements in an input array using qiskit? [closed]

How can I perform an operation similar to Numpy.exp() in qiskit?
1
vote
1answer
33 views

Simplifying Qiskit circuit with c_if()

I'm trying to simplify the inner for loop of this implementation of the Mosca-Ekert semi-classical variant of Shor's algorithm. The inner for loop should have only linear length, but this ...
2
votes
3answers
51 views

Measurement of 1 qubit in a two qubit system

I created two qubits in IBM quantum experience and measured the second qubit without applying any gate. The result I got had a computational basis of 00 and 10. How does the measurement of the second ...
1
vote
1answer
42 views

Recording the time taken by a VQE to find ground state energy

I want to record the time that a VQE solver takes to find the ground state. At the moment I am using: ...
1
vote
0answers
65 views

State bug in IBM Quantum Experience

I run many tests with VQC and QSVM algorithms. In last times I can't get final result because some job hang on state Creating, Validating or Running. It can continue many hours and It doesn't finish. ...
1
vote
0answers
50 views

Length / transpilation issues with Grover's algorithm

I would like to discuss the discrepancies between what we see in the simulator versus what we see in the actual running of the code on any IBMQ machine for any qubits at 5 or above. I am doing a final ...
0
votes
4answers
181 views

Import Qiskit fails [closed]

I have successfully installed the Qiskit in Anaconda by using pip install qiskit. But I can't import Qiskit and get the following error. ...
1
vote
1answer
37 views

How do I check what is wrong in my full-adder code?

I am trying to solve the first question on the qiskit test which is writing a code for a full adder. So based on my research if I have $A$ q[0], $B$ ...
3
votes
2answers
333 views

How does the CX gate work?

I have a silly question as I am an absolute beginner! So as described in Qiskit: It performs the NOT operation (equivalent to applying an X gate) on the second qubit only when the first qubit is $|1\...
1
vote
1answer
24 views

Can Not Login IBM Quantum Experience! [closed]

When I click the “IBMid” for the first time, I can see the login page and input my username and password. However it return to the initial page(https://quantum-computing.ibm.com/login) and after that ...
1
vote
2answers
43 views

IBM Q - Individual Run Results

In Qiskit, is there a way to get the individual results from each shot on the IBM quantum device (instead of simply the summary statistics)? The result JSON file provides the count of all the 1024 ...
0
votes
0answers
35 views

HHL algorithm Qiskit version

...
0
votes
1answer
44 views

Parallel shots on Qiskit

I am running variational algorithms using QuasmSimulator, which means I am performing a classical optimization where the cost function is computed running a quantum circuit. Moreover, for the ...
0
votes
1answer
30 views

Produce a quantum state with its density matrix an identity matrix up to an constant

For a n-qubit quantum state $|\psi\rangle=\displaystyle\sum_{i=0}^{2^N-1}|i\rangle$, by definition it's density matrix is $|\psi\rangle\langle\psi|=\displaystyle\sum_{i,j=0}^{2^N-1}|j\rangle\langle i|$...
5
votes
2answers
52 views

Simulator-dependent implementations in Q#

I have a Q# operation: ...
1
vote
1answer
28 views

How does Qiskit Aqua commutator work?

Commutation operation is essential in quantum mechanics, but when I was trying to use the commutator of IBM qiskit I find something confusing. Here comes the problematic code. ...
3
votes
3answers
77 views

How to learn parameters in a quantum circuit, given an interference pattern?

Using cirq, I have the following quantum circuit, with three parameters: phi, alpha and beta: ...
1
vote
2answers
53 views

Qiskit programming: convert qubit to quantum register

When simulating quantum circuits in Qiskit, sometimes you need to build your own operation. And when you are doing so you would like to save the computational cost, but the QuantumCircuit object takes ...
0
votes
1answer
60 views

Is there a quantum circuit to find the maximum of two inputs?

Is there a quantum circuit (preferably on Quirk as an example) that will enable me to find the maximum from two inputs? Example input A: 11011 input B: 11100 Expected output: 11100
1
vote
2answers
59 views

Usage of Tensorflow/Keras to train Qiskit circuits

In order to explore whether it is possible to train a Qiskit Quantum circuit with tensorflow I built a small toy model. The purpose of this toy model is to find via tensorflow the correct angle to get ...
0
votes
1answer
35 views

Qiskit HHL algorithm BrokenProcessPool error

I try to run HHL algorithm on qasm_simulator. I took the example from here. I try to solve 8x8 random matrix and adjust some parameters in create_eigs. ...
3
votes
1answer
28 views

Is it possible to plot the average counts from two jobs with multiple circuits on a single histogram in Qiskit?

I have the results of 2 separate jobs that contain a set of 75 circuits each. I am trying to compare these jobs by plotting the average counts from all the circuits in job 1 vs the average counts from ...
1
vote
0answers
20 views

Tutorial, optimization part, 5_admm_optimizer has attribute error

In admm optimizer, when running the demo, it has attribute error, binary_vartype does not have attribute 'one_letter_symbol'. Does any one know how to solve it? Here is the code: ...
1
vote
1answer
26 views

How to change the names of the registers displayed with circuit_drawer (output='mpl')

I am trying to change the appearance of the circuit_drawer in output='mpl' mode. The registers of the Quantum Circuit are named like ($q0_0$, $q0_1$, $q1_0$, $q2_0$, $q2_1$,..) but I'd like to name ...
1
vote
0answers
27 views

How to implement the Maximum or Minimum Searching Algorithm (QUMMSA) circuit in Quirk?

I am Java and Python programmer who started self-learning Quantum Computing a couple of months back. The journey has been thus far very tough. I have been using QisKit and Quirk to learn by in ...
0
votes
1answer
83 views

Comparing QSVM & Classic SVM on BigData. Quantum Supremacy

I work on comparing QSVM and Classic SVM (SKlearnSVM) with using Qiskit. I have to show quantum supremacy at 400000-500000 samples but I don't get good results. I have problem with long time training ...
2
votes
1answer
44 views

TypeError: 'NumPyMinimumEigensolver' object is not subscriptable

I'm trying to implement the same Jupyter notebook Jin-Sung Kim gave in his YouTube video The Variational Quantum Eigensolver — Programming on Quantum Computers — Coding with Qiskit S2E4; however, I'm ...
1
vote
1answer
47 views

No histogram appears in my job results

Newbie here - logged in to IBM Q Experience on a MacBook Air with up-to-date OS (macOS Catalina 10.15.7) and Safari browser (14.0). I can build a circuit in Circuit Composer, select a back-end in Run ...
0
votes
1answer
36 views

Qiskit get qubits from statevector

How do I get the amplitude of each qubit, like plot_bloch_multivector(), but not output the tensor product of all qubits. In this case I need output ...
1
vote
1answer
27 views

How to get a molecular Hamiltonians in OpenFermion

I want to get a jordan_wigner_hamiltonians of a molecule-ion by using ...
1
vote
1answer
46 views

ImportError when setting up PySCF driver

I have a problem when attempting to set up a PySCF driver for a hydrogen molecule from the QISKIT Chemistry tutorial: https://qiskit.org/documentation/tutorials/chemistry/01_electronic_structure.html. ...
3
votes
2answers
99 views

Traveling salesman problem in Qiskit: cannot find a solution on simulator

I am trying to solve Traveling Salesman Problem (TSP) in Qiskit based on Qiskit Tutorial. I used TSP for four cities described by this distance matrix: $$ D = \begin{pmatrix} 0 & 207 & 92 &...
2
votes
1answer
49 views

Applying conditional X-gate in Qiskit

I have problem with implementation of the circuit below. How can I write down the conditional X-gate in the following circuit?

1
2 3 4 5
14