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. If your question is about installation or any specific framework error, consider posting it in https://stackoverflow.com/ instead.

Filter by
Sorted by
Tagged with
0 votes
1 answer
41 views

Expectation values of non-local operators in Qiskit

Is there a convenient way in Qiskit to calculate the expectation value for a non-local operator, i.e. I would like to calculate: $$ \langle \Psi|O|\Psi \rangle $$ More precisely, I would like to ...
0 votes
0 answers
19 views

What does it mean for a Qiskit pulse to have a negative amplitude?

I'm going through tutorials on Qiskit Pulse. From this documentation, I can see that it is possible to give a pulse, such as a Gaussian a few different parameters. One of the parameters that I can ...
1 vote
1 answer
25 views

ModuleNotFoundError when running Qiskit RNG

I'm trying to generate random numbers using IBMQ backends with the following code: ...
1 vote
2 answers
85 views

get_statevector() not working with Qiskit Aer's statevector simulator

I'm trying to understand how result.get_statevector() works. Using BasicAer, the following code gives the result for the statevector: ...
  • 33
1 vote
0 answers
23 views

How to read data from multiple qubits and feed it to a MLP

Being new in the field of quantum computing, I tried with the implementation of "https://qiskit.org/textbook/ch-machine-learning/machine-learning-qiskit-pytorch.html" using a single qubit. ...
  • 187
1 vote
1 answer
42 views

ModuleNotFoundError: No module named 'qiskit_aer'

I am trying to perform some noise simulations using the Aer Provider. I read through a tutorials here, but I am not able to really implement the qiskit_aer. When I ...
  • 317
0 votes
0 answers
16 views

How to convert a large CQM to a BQM [closed]

My constraints are defined in a generic format, i.e. as an arithmetic expression (something that is accepted by CQM). I am trying to convert this expression to a BQM that can be added as a penalty ...
  • 141
1 vote
0 answers
9 views

Absolute value of a BQM: how to substitute it with constraint?

I need to build an expression for the objective to be minimized which is based on the L1-norm. For doing this, I need to take the absolute value of a BQM, which is not possible, at least at the moment ...
  • 141
0 votes
0 answers
21 views

Equivalence check between rotational gates and Pauli gates

My question is highly related to this one. I am trying to understand the relationship between rotational gates $R_P(\theta)$, where $P \in \{X,Y,Z\}$. As stated here, $\exp(iPx)=\cos(x)I+i\sin(x)P$. ...
1 vote
0 answers
20 views

How to add constraints to a BQM?

BQM is unconstrained by definition. I need to submit a knapsack problem with two constraints (equality constraints + inequality constraints) to a quantum annealer (DWaveSampler). How would you set the ...
  • 141
0 votes
0 answers
22 views

How to convert equality/inequality constraint to a BQM?

I need to submit a BQM to DWaveSampler. Since my problem has both objective and constraints, my understanding is that I need to add the latter as bqm to a composite BQM, which is then sent to the ...
  • 141
1 vote
1 answer
55 views

AttributeError: 'list' object has no attribute 'values'

While implementing a code, getting the below error: ...
  • 187
2 votes
1 answer
45 views

get.statevector() error: Failed to load qobj: Duplicate key "statevector" in save instruction

I'm building a mini tutorial to introduce the construction of composite systems using qiskit. While doing so I am demonstrating multiple ways to construct and view the statevector, but I have come ...
  • 313
1 vote
1 answer
26 views

How to apply mid-circuit measurement and measurement based conditional operations in `amazon-braket`?

Is there any method to apply mid circuit measurements in amazon-braket? I'm implementing a circuit that has few operations conditioned to measurement. In ...
  • 53
1 vote
0 answers
13 views

projectq code hangs with only 8 qibts

I have written a simple projectq code with 8qbits in order to perform full addition but it gets stuck somewhere between without generating any error message. It worked fine for 4 qbits. ...
  • 181
1 vote
1 answer
36 views

Insufficient memory to run circuit using the statevector simulator

I am a newbie to quantum and have been trying qiskit library for learning quantum computing (in order to explore quantum effects on cryptography). I am basically ...
  • 181
4 votes
1 answer
102 views

How to represent a statevector in Dirac notation form using Qiskit?

I am learning from qiskit textbook, and I was wondering how may I get a statevector of the following form: $$ \frac{\sqrt{2}}{2}|00\rangle + \frac{\sqrt{2}}{2}|10\rangle $$ If I run code for this in ...
  • 73
-1 votes
0 answers
37 views

how to solve the error given by backend=provider.get_backend('ibmq_vigo')

I try to run a quanum circuit with noise. I get an error at backend=provider.get_backend('ibmq_vigo'). I am not sure what causes the error. Could anybody help me ...
2 votes
0 answers
20 views

Why does method to_bqm not maintain variables order?

When converting to bqm with .compile().to_bqm(), the original order of the variables is not maintained. To reproduce: ...
  • 141
1 vote
1 answer
36 views

Seeding a stim.TableauSimulator

When creating a sampler from a stim.Circuit (say, for example, using stim.Circuit.compile_sampler), one can provide a ...
0 votes
1 answer
40 views

How does the Active Space Transform work theoretically?

I have a question about the ActiveSpaceTransformer which is used in vqe calculations for a molecule of LiH in Qiskit. In the documentation the inactive Fock operator is defined.I don't understand why ...
2 votes
0 answers
36 views

How does the c_if instruction work in QISKit?

The c_if instruction can be used to make the result of a measurement saved to a classical register adjust whether a gate is or is not performed. How does the c_if instruction obtain the measurement ...
1 vote
2 answers
134 views

Quantum Computing Daily Practice / Quiz platform

I am looking for a platform where I can solve quizzes and programming / algorithmic challenges related to quantum computation and information. To be more specific, I am looking for a platform that is ...
1 vote
2 answers
39 views

Qiskit: Can I run real experiments in QPUs with OOP structured code?

The question might be naive, but I'm hesitant to design my algorithm in a complex, Object-Oriented scheme (custom classes, objects etc.). My fear is that current frameworks (e.g. ibmq, qiskit-runtime) ...
  • 169
3 votes
1 answer
38 views

How to extract per shots measurement result from ionq device using qiskit_braket_provider?

I'm running a circuit on ionq device using qiskit_braket_provider. I want to extract per shot measurement results. While running ...
  • 53
3 votes
0 answers
32 views

Is there a tutorial for error mitigation in qiskit that does not use the deprecated ignis?

Working through the qiskit text I have come accross measurement error mitigation a few times (Measurement Error Mitigation, Lab 3: Quantum Measurment,...]. In the online textbook the coding indicates ...
  • 313
2 votes
0 answers
39 views

A path towards building quantum Computing graduation project for undergraduates

I need help. I'm a computer science student with a Data science major. I have a final graduation project this year. With that, I want to create a project in the Quantum computing field. I'm already ...
3 votes
0 answers
21 views

How does it work QasmSimulator with the option "density matrix"?

I am making some simulations on IBM Quantum Lab and as backend I tried to use QasmSimulator(method = "density_matrix") in order to simulate noise. I wanted to know how this method works in ...
2 votes
1 answer
39 views

Partial Measurement in AWS Braket

Is there a way to do partial Measurement in AWS Braket? Basically, if I have a circuit with $N$ qubits, can I measure only $n$ qubits out of them with the result type "expectation"?
0 votes
1 answer
35 views

How to initialize my circuit with two random complex numbers?

Working through Lab 3 in the Qiskit text, I have been attempting to initialize my one qubit circuit with two random numbers. My first attempt, as directed, is using ...
  • 313
3 votes
1 answer
69 views

What techniques can be used in order to debug a quantum program

I am programming in IBM tools like Qiskit and ProjectQ but have not found any examples/tutorials to debug a quantum program. I ...
  • 181
1 vote
0 answers
34 views

Amplitude Amplification applied to HHL Algorithm

I’m trying to understand and implement the amplitude amplification algorithm described in the HHL paper. I’m using the cirq implementation of the HHL algorithm as my starting point. I have a couple of ...
2 votes
0 answers
64 views

Add a negative phase to selected states

I have $n$ qubits in superposition. I want to add a negative phase to all states with more than $m$ $1$s, e.g. for $n=3$ qubits and $m=1$ I want to get: $\frac{1}{\sqrt{N}}(|000\rangle + |001\rangle + ...
  • 21
3 votes
2 answers
70 views

Is there a way to get the controlled version of a AWS Braket Unitary?

In qiskit we can simply define a custom unitary $U$ and get its controlled version $C-U$ with the method .control(). So, is there a way to do the same in AWS Braket?...
1 vote
0 answers
100 views

Jupyter Notebook not rendering latex code

Working through the Qiskit text and came across this bit of coding on the density matrix page: psi_AB.draw('latex', prefix='|\\psi_{AB}\\rangle = ') which is ...
  • 313
1 vote
1 answer
76 views

Qiskit - MissingOptionalLibraryError pdflatex library is required to use LaTeX circuit drawing

Trying to run below snippet to generate circuit diagram in a Jupyter notebook on Windows. ...
4 votes
1 answer
54 views

CCCRY gate creation

I'm aware there's a few questions about CCCRY gate composition on here but I still have a few questions. I'm following Frank Zickert's book on qiskit and he has defined a CCRY gate as ...
2 votes
1 answer
47 views

TranspilerError: 'The input circuit None is not scheduled'

The following error occurs when executing the code to measure the dephasing time(T2). I would appreciate it if someone could give me a solution to this problem. Among the two functions below, ...
1 vote
3 answers
153 views

Is there any way to always output |1> if the measurement has a probability to output 1?

Let's say I have an oracle that outputs 1 on a specific input (there can be multiple inputs x so that f(x)=1), else it outputs 0. If there is no such input so that f(x)=1, the quantum state of the ...
3 votes
1 answer
50 views

How are the experiments ordered in a Qiskit Job?

Using the execute function, assuming the parameter experiments is a list[QuantumCircuit], would each circuit execute on the ...
0 votes
0 answers
28 views

How to write QSVR_Loss function in Python?

I encountered a problem when I was doing quantum support vector machine experiments: when I was doing quantum kernel alignment, I saw that the example given by qiskit was SVC_Loss: https://qiskit.org/...
1 vote
1 answer
102 views

Using Qiskit's AerSimulator with an AMD GPU

I have an AMD 6700S that I want to use for Qiskit simulations. The test case below is calculating the QFT. If I set my code up like this: ...
3 votes
1 answer
94 views

Efficiently compute $\langle 0^{\otimes n} | e^{iA} H e^{-iB} |0^{\otimes n} \rangle$ in Qiskit

From this SE question and this Qiskit tutorial, I understand how to compute the expectation such in the form of $\langle \psi|H|\psi\rangle$ or $\langle 0^{\otimes n} |e^{iA} H e^{-iA}|0^{\otimes n} \...
0 votes
0 answers
20 views

How to monitor a qiskit neural network on IBM Cloud?

I know qiskit offers the job_monitor function. However it only allows monitoring a BaseJob, for instance the one outputted from ...
  • 435
2 votes
1 answer
137 views

Understanding Paddle Quantum's MBQC simulation

Paddle Quantum have a toolkit for simulating measurement-based QC patterns in Python, and I'm having a hard time understanding how this works. For example, the following code snippet considers the ...
  • 174
1 vote
1 answer
60 views

Is this Quantum Neural Network overfitting?

In the accuracy graphs (attached the graph images below) shown in this code (Binary Classification for Fraud Detection): validation loss is greater than training loss training accuracy is greater ...
  • 11
1 vote
0 answers
104 views

PyZX optimisation steps for Clifford circuits

Given the following ZX-diagram It should represent some random Clifford circuit (LC means Local Clifford). As far as I got, any Clifford circuit can be transformed into a ZX-diagram like the above, i....
0 votes
1 answer
31 views

What is the data type "Unit is Adj" in Q#?

I came across it as the return type of operations in this paper: https://arxiv.org/abs/2204.13835. It is also used in various places in the Q# documentation.
  • 485
0 votes
1 answer
58 views

References for two-local forms in QISKIT

I am using 'Two local' form of QISKIT as a waveform ansatz in VQE to compute ground state. QISKIT documentation does not provide references to all the entangling options. Is there any other place ...
  • 35
1 vote
1 answer
54 views

cirq_google library in Python

I am trying to use the cirq_google library in Python but I receive an error: ...
  • 223

1
2 3 4 5
28