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
2
votes
1answer
80 views

how can we save a model using qiskit_machine_learning?

How can we save a trained model using Qiskit Machine Learning library? I've built a VQC classification model and once finished, I'd like to save the different models to be loaded later. There is a <...
0
votes
1answer
60 views

Manual measurement error mitigation returning a negative number of counts

I have a simple 2 qubit circuit which I am trying to protect from errors using the measurement error mitigation technique laid out here: https://qiskit.org/textbook/ch-quantum-hardware/measurement-...
1
vote
0answers
78 views

Error when computing the self-designed gradient in qiskit

I had question with the way to define a new kind of gradient to improve the performance of VQE. The gradient formula I used consists of multiply energy (measurement result of the Hamiltonian) with the ...
0
votes
0answers
55 views

How to solve a linear equation of qubit operators in qiskit?

I am trying to repeat the results from Peng and Kowalski (Eq 11) which solves the analytical form of an equation consisting of powers of the Hamiltonian (moments): The $K$-th order PDS formalism is ...
1
vote
1answer
102 views

Get the inverse of a Hermitian operator for measurement in qiskit

I am using qiksit to measure the Hamiltonian H, which isbasically sum of Pauli strings, say something like 2*X^X+0.5*Z^Y. For ...
0
votes
2answers
104 views

How to assemble two quantum circuits whose qubit mapping states are different each other?

I uploaded similar question before, but the answer was not I want. I think I should show you in more detail about my question. I use SABRE algorithm which can do qubit mapping for executing quantum ...
0
votes
0answers
58 views

Qiskit equivalent of get_expectation_value() in ProjectQ

Is there a corresponding function that has the same function as function get_expectation_value() in Project Q? Get the expectation value of qubit_operator w.r.t. the current wave function ...
1
vote
5answers
241 views

How can I get the number of measurements where any specific qubit is equal to 0?

Say I am using a 100 qubit quantum computer, but my circuit is such that I am only interested in the output of a particular qubit. So for example I want to know how many outcomes had a result of 0 on ...
1
vote
1answer
50 views

How do you create a square pulse in Qiskit?

I am wondering how to create a square pulse in Qiskit. I am working off this Qiskit documentation but still cannot figure out how to create a square pulse.
2
votes
2answers
90 views

Trying to connect IBM Quantum to External API

Is it possible to connect a quantum computer to openlibary.org API? How do I find the public IP address to my quantum instance?
-1
votes
1answer
76 views

FileNotFoundError: No such file or directory. This error occurs while giving a data path to upload datafile(present on desktop) in IBMQ [closed]

I am trying to implement https://qiskit.org/textbook/ch-machine-learning/machine-learning-qiskit-pytorch.html#3.-Let's-code!- in IBMQ using a dataset present on my desktop. While uploading a dataset ...
-1
votes
1answer
49 views

HLL Algorithm results interpretation

I have the following HLL qiskit implementation and really need some help interpreting the results! CODE ------------------------------ ...
0
votes
1answer
71 views

Are there any packages that can calculate stabilizer tableau of a QECC

I'm experimenting with some small quantum error correcting codes (QECC). For example $[[5,1,3]]$, $[[8,3,3]]$ or toric codes $[[2d^2,2,d]]$ ($d=2,3,\cdots$). The last one being defined by redundant ...
0
votes
1answer
66 views

How to assemble two quantum circuits which has each own qubit mapping state?

I'm curious about something. I tried to do some qubit mapping using SABRE algorithm. Suppose I have two quantum circuits and apply SABRE algorithm to both of them. Then each of them has its own qubit ...
1
vote
0answers
36 views

Difference in HLL applications

I am new to Qiskit and I have seen two types of simple 2X2 $Ax=b$ system solutions. I am wondering what the difference is exactly. They both occur on a simulator backend, but the first gives me a ...
0
votes
0answers
84 views

Qiskit State Tomography with Additional Classical Register

For a circuit with a classical register like in the image, I cannot apply StateTomographyFitter(result, tomography_circuits).fit() method for the second and third ...
1
vote
0answers
39 views

Quantum Machine Learning: how to get effective time of training/scoring

I am trying to examine the potential of Quantum Machine learning in terms of performance and time compared to classical algorithms. I am using both Qiskit's QSVM and scikit's SVM with Qiskit Quantum ...
1
vote
1answer
44 views

Use of Data loaders or State Initialization Circuits

I have recently started working on qiskit and I am struggling to use qc.initialize API in any practical or useful application. I have read at multiple places that ...
1
vote
1answer
61 views

How to get the matrix representation of a circuit in Amazon braket?

Say I define a circuit using the amazon-braket-sdk, for example: ...
1
vote
0answers
34 views

Recover qubits used in an actual computation

How do I recover from a certain job_id in the IBM backends which qubits where used? I would be interested to know if for instance, in a batch of say 50 jobs, 25 of ...
2
votes
2answers
150 views

How to implement parametric iSWAP gate in Qiskit?

I'm trying to implement the parametric $\text{iSWAP}$ gate, also known as $\text{XY}(\theta)$, in Qiskit. $$ \text{XY}(\theta)= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos{\theta/2} &...
3
votes
0answers
72 views

How exactly does the QuantumCircuit.decompose() method work?

From what I can understand from the source code, the circuit is converted into a DAG before the decomposition transpiler is performed onto the DAG circuit. How does converting to a DAG circuit help us ...
2
votes
1answer
91 views

Is it true that QasmSimulator is much slower than StatevectorSimulator, or am I doing something wrong?

I'm trying to calculate the expectation value of some operator for a state that comes out of a quantum circuit using Qiskit. I was initially using ...
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 ...
0
votes
1answer
144 views

QuantumInstance object has no attribute "name" [closed]

I follow qiskit tutorial "Portfolio optimization". When I executed this cell, I encounter the attribute error as the title(picture showed below). Do anyone know how to fix this problem? It ...
4
votes
1answer
209 views

How does one access data from retired backends?

I am having trouble retrieving data using Qiskit from jobs I ran on a currently retired system. However, I can still retrieve the same data from the dashboard (GUI), so I think the data are still ...
3
votes
2answers
188 views

How to construct a controlled $V$ gate in qiskit?

I have come across most of the quantum circuit which contains gate such as controlled $V$ and $V^{\dagger}$ but I dont know how to code it in Qiskit.
2
votes
0answers
23 views

Output of D-Wave LeapHybrid solver takes long to evaluate

we made the strange observation that the evaluation of the output in form of the dimod.SampleSet takes a long time to evaluate especially in comparison to the actual sampling step. Here is a minimal ...
4
votes
0answers
55 views

Extract the Crosstalk noise of a circuit in Qiskit

I'm new to Quantum Computing. How to extract the cross-talk noise of a quantum circuit using qiskit? Can someone provide an example code for this?
3
votes
2answers
63 views

Are job IDs unique across backends?

Are job IDs unique across backends, or is it possible that two jobs on two different backends have the same job ID? I'd like to use the job ID as primary key in a database. Thanks in advance!
1
vote
1answer
202 views

How to get measurement result on Qiskit

I want to get measurement result from my circuit output, like '00', '01', '10', or '11' because want to process it further classically. Any suggestion? We can see the highest probability '01'. How I ...
1
vote
1answer
113 views

Why qiskit transpiler makes different results everytime? (Non-deterministic)

I tried to do qubit mapping called 'SABRE' and execute transpiled quantum circuit. I use FakeTokyo backend which has some noise because it is mock version of IBMQ 20-Tokyo. I know using this backend ...
1
vote
1answer
64 views

IBMQ.load_account() is failing

When I try IBMQ.load_account or IBMQ.delete_account gives an error in the ubuntu machine and the error is, ...
2
votes
0answers
54 views

Issues in calculating exact runtime on ibmq_16_melbourne

I am working on calculating the exact runtime of a quantum circuit on the ibmq_16_melbourne device. I am using the API ...
6
votes
2answers
100 views

Cascade/Feedforward quantum circuits

I would like to know if it is possible implement the following situation in Qiskit (either using the simulators or real quantum computers). Consider this illustrative toy example: The arrows ...
4
votes
1answer
54 views

How can I write unit tests for a pennylane circuit?

I have several mixing unitary circuits written using Pennylane to be used in the QAOA algorithm. Furthermore, I'd like to write unit tests for these mixing circuits to ensure that the code is doing ...
2
votes
1answer
105 views

How to find the expectation value of several circuits using Qiskit aqua operator logic?

I am using the method from this SE answer to calculate the expectation value using qiskit aqua operator logic which works well for a single circuit. Here is a simplified code snippet to demonstrate ...
2
votes
2answers
151 views

Transpilation on restricted topology does not yield an equivalent circuit in Qiskit

Here is an MWE: a simple circuit on three qubits with a CNOT acting on qubits 0 and 2. The coupling map prohibits a two-qubit gate between qubits 0 and 2 and so qubit 1 must get involved. ...
3
votes
1answer
70 views

Qiskit: total number of parameters after composing parametrized circuits

I'm trying to use the .compose() method to join two parametrized circuits, specifically TwoLocal instances from the ...
1
vote
0answers
69 views

Are inconsistent results between different VQE runs justified?

I made this post a while ago, where I learned I could use qiskit's VQE to calculate (or approximate) the Transverse Field Ising Hamiltonian and other similar Hamiltonians. After working with my code ...
1
vote
2answers
346 views

ibmq_16_melbourne system of Qiskit giving wrong result for Bernstein-Vazirani Algorithm

I have just started learning Qiskit and to begin I tried running the Bernstein Vazirani Algorithm(secret number detector) on qasm_simulator and the ...
4
votes
1answer
99 views

Is a black-box gate whose output is conditional on the value of an input amplitude possible?

Suppose we have a qubit in the state $|q\rangle = a |0\rangle + b |1\rangle$, and another ancilla qubit $= |0\rangle$. I wish to have the following black-box gate: ...
2
votes
0answers
54 views

How do I construct a Breidbart gate in Qiskit?

Based on this : https://qiskit.org/textbook/ch-states/single-qubit-gates.html How do I construct a Breidbart gate (which is like the Hadamard gate but with $\pi/8$ instead of rotating by $\pi/4$)? I ...
2
votes
1answer
86 views

Qiskit: set_frequency workaround in PulseSimulator

I am trying to run exercise 4 from the recent IBM Quantum Challenge using a PulseSimulator since the device used in the challenge is not available for public use. A snippet of what I am trying to run ...
2
votes
1answer
98 views

IF statement in OpenQASM2.0 on IBM Quantum Experience -- error

I have written the following toy .qasm file, which has some adaptive measurements: ...
4
votes
2answers
162 views

How do I identify a VQE job run in real hardware?

I am running a VQEUCCFactory for H2 on a real hardware device. ...
1
vote
0answers
61 views

How to calculate Alpha and Beta values for QAOA Max-cut problem manually?

I'm new to Quantum Computing. I came across solving the Max-cut problem using QAOA. For example, if I have a $U3$ gate with parameters $U3(0,0, \gamma_{XYZ})$ gamma parameter at $p=X$ between logical ...
1
vote
1answer
116 views

Qiskit - lesson 3 - with Abe

Coding for Qiskit I watched this video: https://www.youtube.com/watch?v=RrUTwq5jKM4 Using Mac OS Big Sur Using Jupyter 2.0.8 Using Python 3.8 The below code did not work and therefore installed ...
5
votes
1answer
307 views

Transpilation into custom gate set in qiskit

In qiskit, I can transpile a given circuit into a some predefined gate set as follows (just an example) ...
5
votes
1answer
134 views

Use one_body_integrals to know which orbitals to freeze in ElectronicStructureProblem

In exercise 5 of the this year's IBM Quantum Challenge, you need to use the FreezeCoreTransformer (along two_qubit_reduction and ...

1
3 4
5
6 7
25