Questions tagged [programming]

For questions about writing code to be executed on a quantum computer, or to more generally simulate some aspect of it. For questions about a specific programming language, please also include a more specific tag.

Filter by
Sorted by
Tagged with
2
votes
1answer
277 views

Qiskit issues with Apple Silicon?

Edit/summary: Everything below this first paragraph is my original question posted several days ago and involves a lot of speculating on a problem I knew less about at the time. The purpose of this ...
1
vote
2answers
50 views

I am uploading a CSV file but cannot access it in the notebook [closed]

I uploaded a CSV file using import in Quantum Computing Lab folder. It is uploaded, I can see it. When I write "import filename" in my notebook, it shows an error. I have tried doing the ...
0
votes
2answers
58 views
2
votes
1answer
50 views

Increase maximum shots on IBM Hardware when running Quantum Variational Algorithms

I am interested to know whether there is a quick and elegant way of increasing the number of shots (more than 8192 shots) on IBM hardware when running variational algorithms like VQE or QAOA. I know ...
3
votes
1answer
43 views

Kernel stopping when solving water molecule ground state

I'm new to QISKIT Aqua and I'm trying to follow the Ground State tutorial to solve the Water molecule ground state, but when I execute the calculations the kernel stops. I'm using IBM Q Experience ...
4
votes
0answers
50 views

Inequality constraints on D'Wave (using PyQUBO)

Inequalities cannot be directly converted into a qubo form 0⩽ Expression ⩽ N We can introduce a slack variable and convert it to an equality problem: ⟹ Expression + s = N where: s ∈ Z, s ∈ [0,N] Since ...
3
votes
2answers
82 views

How do you represent one-quibit rotations in two registers as its own 4x4 unitary matrix?

Let's say you have a circuit that performs a Z-rotation in the first register, and a Y-rotation in second register. How can we express this "moment" in terms of a 4x4 matrix, i.e. a two-...
2
votes
3answers
92 views

Grover's algorithm for finding 6/8 states

I'm trying to apply the diffusion operator to this state (normalization factors excluded): $|000\rangle + |001\rangle - |010\rangle - |011\rangle - |100\rangle - |101\rangle - |110\rangle -|111\...
3
votes
1answer
98 views

XY Hamiltonian in a 1D Heisenberg Chain

I've been trying to implement the 1D Heisenberg chain (i.e. the XXZ model) on Qiskit but have been having trouble. To recap, the Heisenberg hamiltonian is as follows: $$H_{XXZ} = \sum^{N}_{i = 1} [J(S^...
4
votes
1answer
45 views

Access and set_state during quantum computation simulation in cirq

The documentation for Cirq mentions the possibility to step through a circuit's moments, and access the exact wavefunction via step.state_vector(), and edit set it ...
2
votes
3answers
130 views

Computing the CDF with QAE in Qiskit

I want to load a lognormal distribution and then use an IntegerComparator to flip a qubit ($|0\rangle$ to $|1\rangle$) if its value is less than a threshold. Then I want to use an Quantum Amplitude ...
3
votes
0answers
72 views

How can I measure a qubit on a generic axis on Qiskit?

I'm trying to prove Bell's inequality by following the one made by Wigner, that is: $P(+_a,+_b) \le P(+_a,+_c) + P(+_c,+_b)$ And that this proof is NOT satisfied for angles between the various axes $\...
3
votes
2answers
257 views

Does the Qiskit ADMM optimizer really run on quantum computers?

I read Qiskit quantum admm on this website. I doubt whether this Qiskit ADMM algorithm can run on a quantum computer. The code did import packages from Qiskit, but it doesn't create any quantum ...
4
votes
2answers
219 views

Get state vector of a single qubit in a circuit in Qiskit

I have two quantum circuits, and I would like to compare state vector of the first qubit and check if equals, what is the best way to do that in qiskit ? Let's say I have : ...
0
votes
1answer
89 views

ProjectQ - Error messages

How can we get rid of runtime next error: ...
0
votes
1answer
53 views

Classically controlled quantum operators

Does CirQ support classically controlled quantum operators where the classical values obtained by the measurement?
2
votes
1answer
81 views

Design a circuit implementing the unitary matrix

Is it possible to design a circuit implementing the unitary matrix $$U-\begin{bmatrix} R_{\Theta_1} & 0 & 0 & 0 \\ 0 & R_{\Theta_2} & 0 & 0 \\ 0 & 0 & R_{\Theta_3} &...
2
votes
1answer
73 views

Transpiler in IBM Quantum devices [duplicate]

I am having trouble understanding how the transpiler works in IBM quantum computers. I am studying the spatial noise correlation between two qubits in an IBM Q device. For that, I don't want the ...
1
vote
1answer
33 views

How can I resolve this get_count issue from running multiple circuits?

I'm running a couple of circuits at the same time using an array of variables. However, I met an issue regarding accessing the counts. Here's part of the code I have: ...
6
votes
1answer
170 views

Trying to understand this measurement of a simple quantum circuit

It's a newbie question, I know. But I was just wondering if someone could help me understand why this simple circuit results with the measurement shown. I've just didn't get the last step. It's not ...
2
votes
2answers
94 views

IBM quantum experience: Why are intermediate measurements ignored?

Why am I getting here a measurement outcome of $00$? I measure after the first $X$ gate in a separate output bit c[1] which should result in a $1$ and I measure ...
1
vote
1answer
74 views

Does Cirq support GPU acceleration?

I'm wondering if Cirq does (or plans to) support GPU acceleration of matrix operations, including density matrix simulations. I would like to speed up training and evaluations of variational circuits ...
1
vote
2answers
64 views

How to project a composite system down into a smaller subspace in Python?

If we have a composite system over five qubits ($|\psi\rangle = |a\rangle|b\rangle|c\rangle|d\rangle|e\rangle$), and I want to project into a specific subspace of the first three systems, I can build ...
2
votes
2answers
81 views

Conjugate transpose of a U-gate

I want to be able to create the circuit depicted below, but running the code below results in an empty circuit when viewing the job afterwards. ...
5
votes
3answers
471 views

Qubit Connectivity of IBM Quantum Computer

When simulating a quantum circuit using qiskit qasm_simulator, the qubits that you assigned to the quantum circuit can be ...
1
vote
1answer
64 views

Get a sparse matrix of quantum circuit

Is there a way that can obtain sparse matrix of quantum circuit? I used to check my quantum circuit with quantum_info.Operator, but for large number of qubits, it ...
0
votes
2answers
64 views

qiskit: How to get an operator acting on a certain qubit?

I have a system of $N$ qubits and want to construct a quantum operator $Z_i Z_j + Z_k$, where $Z_i$ denotes the Pauli-Z operator acting on the $i$th qubit. Is there any direct way in qiskit, how I ...
3
votes
0answers
32 views

D-WAVE QUBO Matrix Form

I am trying to write down this problem (friend/enemy graph) in a polynomial matrix form in order to understand quantum annealing better, but it seems like the problem should actually be split into ...
1
vote
1answer
35 views

Is there a faster way to get 'a list of' result from 'a list of inputs'?

I had a question about obtaining the probability of a certain state from the histogram, still using this example, suppose there's a variable in my quantum circuit, it's values are stored in an 'np....
3
votes
1answer
83 views

Does TensorFlow Quantum tfq.convert_to_tensor work on custom gates?

I'm trying to use Cirq with TensorFlow Quantum to simulate a variational quantum classifier. There's a tutorial on the TFQ website on building a quantum neural network to classify a simplified version ...
2
votes
1answer
78 views

Connectivity in Grover's algorithm on real quantum computers

Everytime I execute Grover's search algorithm on IBM real quantum computers I get a wrong answer (it doesn't find the correct winner state) unless I use only 2 qubits. For any higher number of qubits ...
1
vote
4answers
136 views

How to transpile a circuit using Qiskit as done in IBMQ experience

When I create a circuit using Qiskit and then transpile it using transpiled_circuit = transpile(circuit, ibm_backend, optimization_level=1) then I open my IBMQ ...
2
votes
1answer
93 views

How to get subspace of quantum circuit?

How can I get a subspace of a quantum circuit? More precisely, I'm dealing with quantum circuit with data qubits ('q') and ancilla qubits ('anc'), such as $(q_0,q_1,...,q_n,anc_0,..anc_m)$. After some ...
2
votes
1answer
149 views

How to run a OpenQASM 3.0 file?

When uploading a QASM-file with ÒPENQASM 3.0; as first line, the code editor on quantum-computing.ibm.com will throw an error. However the qiskit Python library ...
2
votes
1answer
61 views

Why does the problem Hamiltonian of QAOA always consist of $Z$ and $I$ gates?

I noticed that in QAOA the problem hamiltonian always consists of $Z$ and $I$ gates. But isn't QAOA a form of Adiabatic Programming? Where the idea is just to go from one ground state to another? Does ...
0
votes
1answer
42 views

Device Repitition Rate on Melbourne

I've been receiving "Circuit runtime is greater than the device repetition rate [8020]" errors when running a relatively simple circuit on ibmq_16_Melbourne, but have had no issues ...
0
votes
2answers
63 views

Coping values based on indicator qubit in Qiskit

Give the following input: $$ A: 1110 \\ B: 0111 \\ \text{indicator}: 0 \text{ or } 1 $$ How do I copy the value of A or B to target qubits if indicator is 0 or 1 respectively? In the image below, the <...
1
vote
2answers
71 views

Why is the Measurement Result Always 1? (expected to find uniformly random measurement)

I created a $|0\rangle$ state then applied $H$ gate to get $\frac{1}{\sqrt{2}}(|0\rangle+|1\rangle)$ and then I meausred my state. But I always found 1. I expected to find 0 and 1 uniformly random ...
4
votes
1answer
48 views

Classical optimisation of angles in QAOA for TSP gets stuck in local minima?

I have been trying to implement a QAOA for solving a traveling salesman problem (TSP) using qulacs and python. However, even for ...
1
vote
1answer
33 views

Mechanism of measurement in IBM quantum devices

I am trying to find out about the mechanism of measurement in IBM Q devices. To be specific, if I apply two Hadamard gates on the first qubit and identity on the second then is it possible to ...
3
votes
1answer
137 views

Using Qiskit VQE for solving an eigenvalue problem

I am a new user of Qiskit and I believe there is a simple answer to my question but I have had a very hard time finding a straightforward answer. I am trying to transform a given $3 \times 3$ (...
2
votes
2answers
339 views

Maximum number of qubits suppoted by the Qasm simulator

By using the Qiskit qasm-simulator, I want to simulate a quantum circuit of 40 qubits. However, the number of qubits 40 is greater than maximum number (24) for qasm-simulator. Is there any possibility ...
2
votes
1answer
29 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 ...
3
votes
1answer
86 views

IBMQ: Can I implement a quantum measurement in the middle of a quantum circuit?

I am executing a quantum circuit on an IBM quantum device. The circuit is simple: A single qubit (start from $|0\rangle$), Rx($\pi/2$) Measure (in z) 3 .Rx($-\pi/2$) Measure (in z) The final ...
1
vote
1answer
68 views

How to measure a quantum circuit's execution time on a real IBM device?

I am executing a quantum circuit on an IBM quantum device and I need to start a timer as soon as the job in the queue starts running. I have already used: ...
1
vote
2answers
133 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
66 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
59 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
122 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
71 views

IBMQ: “Credentials are already in use”

Executing the following: ...

1
3 4
5
6 7
19