New answers tagged

0 votes

Reducing circuit initialization complexity

I think that the QuantumCircuit.initialize() method isn't always providing the most efficient state preparations. I have tried to initialize some very simple states,...
user avatar
  • 119
0 votes

Reducing circuit initialization complexity

Try using isometry instead of initialize: ...
user avatar
2 votes
Accepted

Computational cost of a circuit in Qiskit

I think what you are looking for is the notion of circuit depth - which is basically the amount of steps being done by the quantum computer that runs the circuit. Some gate operations can be executed ...
user avatar
  • 119
0 votes

QiskitError: 'Sum of amplitudes-squared does not equal one.'

A quantum statevector must posses a norm (magnitude) of 1. This is called the normalization condition. Anyway in the code above I don't see that you have done something to any of the circuits/...
user avatar
  • 119
0 votes

What's the paper referenced by qiskit.compiler.transpile? My tranpile solution is wrong from the perspective of fidelity

The Qiskit transpilation process does not currently preserve the unitary equivalence, because it is oriented to real hardware that uses measurements. Here is your circuit with the only addition of <...
user avatar
  • 4,040
1 vote
Accepted

Qiskit - MultiCX gate mcxgate

You circuit is correct. The result is not matched with what you expect because Qiskit uses little endian bit ordering. If you want to get the result in big endian convention, use ...
user avatar
1 vote
Accepted

Qiskit: how to ensure binded parameters in circuit?

Qiskit is complaining because apparently self.theta is not present in the circuit. There's two solutions to this: Ensure that ...
user avatar
  • 2,288
1 vote

How can I save IBM Quantum API token to local environment?

I personally utilize python Keyring package for storing and retrieving the secrets on local OS. It leverages the OS provided security and supports mac, windows and linux os backends. This prevents the ...
user avatar
0 votes

How to design a RF-SQUID qubit by Qiskit Metal?

This is a great question for the #metal Slack channel where we have active developer support You can find the Slack channel #metal in the qiskit workspace.
user avatar
0 votes

Qiskit implementation for projecting a hermitian operator and finding its eigenvalues

I'm not super experienced with quantum either, but I'm not sure that what your looking for is doable with in the circuit using a matrix representation. I think if you vectorize the matrices you should ...
user avatar
0 votes
Accepted

Qiskit textbook: mod 15 multiplication circuit

It turns out that this is indeed an issue and has been reported to the qiskit-textbook project on GitHub.
user avatar
2 votes
Accepted

Qiskit UGate - which angles corresponds to which axes

You can find the documentation page for UGate which shows the matrix representation of the gate with different angles. https://qiskit.org/documentation/stubs/qiskit.circuit.library.UGate.html
user avatar
1 vote
Accepted

Qiskit textbook: Shor's algorithm

I believe you're correct and this is an inconsistency in the textbook. Since they initialize the state backwards but also do the modular multiplication backwards (as you also pointed out), it seems ...
user avatar
1 vote

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

It seems the executable pdflatex is not in path. You might need to restart your Windows or extend the PATH variable with the <...
user avatar
  • 4,040
1 vote

Long execution time to create controlled version of custom unitary gate in Qiskit

I have the same problem although I just use a one-qubit unitary! I attempted to implement a multiple qubit unitary myself with Gray codes and two-level matrices(acting on one qubit) as explained in ...
user avatar
1 vote
Accepted

Qiskit - CircuitError Index 1 out of range for size 1

You are applying X to two qubits, [0,1]. However, your circuit has only one. You can change your code to: ...
user avatar
  • 4,040
2 votes
Accepted

CCCRY gate creation

Here is how to create and append $CCCRY(\theta)$: ...
user avatar
  • 4,040
0 votes

Qiskit Runtime: What are the units of job.result().time_taken? Seconds, milli-seconds, micro-seconds?

As @3yakuya has said, this is missing from the documentation. The best I could find is a Qiskit tutorial (version 0.37.1) which uses the parameter. According to this tutorial (see the 3rd code cell), ...
user avatar
  • 174
1 vote

How well different featuremap encode the data?

Maybe this article can help you: 'Automatic design of quantum feature maps', Sergio Altares-López, Angela Ribeiro and Juan José García-Ripoll, 19 August 2021 - https://doi.org/10.1088/2058-9565/ac1ab1....
user avatar
  • 11
0 votes

Which protocol does the Qiskit textbook use for Quantum Key Distribution?

Looking into it, there are two main categories for implementations of Quantum Key Distribution. One of them is the protocol where you prepare and measure random quantum bits, and the other protocol ...
user avatar
  • 409
2 votes
Accepted

What makes oracle algorithms difficult to design and implement?

From my experience in building oracles, this question is answered by the following statement: The complexity of constructing a specific quantum oracle is inversely proportional to the amount of ...
user avatar
  • 4,542
2 votes
Accepted

Ansatz printing in Qiskit draws a single block

You can break all the blocks in a circuit in smaller blocks by using the decompose method. ...
user avatar
  • 4,040
1 vote
Accepted

How to construct a multi-control quantum gate whose control bit relation is XOR?

I think what you are asking for is a block unitary matrix. To be concrete I'll discuss a three-qubit case, the generalization is straightforward. Consider $$U=|00\rangle\langle00|\otimes U_{00}+|01\...
user avatar
1 vote

TranspilerError: 'The input circuit None is not scheduled'

The issue with your withDelay function is its use of execute (which combines transpile and <...
user avatar
  • 1,888
0 votes

Gradient descent for a quantum-classical hybrid neural network

Pennylane also provides PyTorch/TensorFlow plug-ins which enable back-propagation based optimizers. For instance, for PyTorch you can use TorchLayer. This might also be relevant for the Hybrid-Neural ...
user avatar
1 vote

different results between aer_simulator and aer_simulator_statevector using Qiskit opflow circuit sampler

The statevector simulator has to do with "ideal" circuits, and the regular simulator does not. See these links: What are the differences between Qiskit's AerSimulator, QasmSimulator and ...
user avatar
  • 79
1 vote
Accepted

How are the experiments ordered in a Qiskit Job?

If the parameter experiments is a list[QuantumCircuit], then the qiskit.execute_function ...
user avatar
  • 1,888
0 votes

Exponentiating a multi-controlled NOT gate for trotterization

MCXGate exists in Qiskit's circuit library. So, you can get the operator as follows: ...
user avatar
1 vote

When will Qiskit Runtime be available to all users?

In Sept. 2021, they announced that the Qiskit runtime has been enabled on all IBM Quantum systems on slack. Follow this link for more https://qiskit.slack.com/archives/C8GLMQ1U5/p1631806010144500. ...
user avatar
2 votes
Accepted

How to calculate the average fidelity of Pauli error channel

TL;DR: Two steps. First, we find the entanglement fidelity $F_e(\mathcal{P}_{p_x,p_y,p_z})=1-(p_x+p_y+p_z)$. Next, we use Horodecki's formula that connects the average and entanglement fidelities $$ \...
user avatar
  • 14.3k
1 vote

Using machine learning to determine a good initial mapping for a quantum circuit

There are some serious issues in the choice of model architecture that will make learning almost impossible. Below I'll comment on why this specific architecture and implementation is not going to ...
user avatar
  • 4,867
1 vote
Accepted

Rigetti "Timeout on client tcp://127.0.0.1:5555, method name quil_to_native_quil" error

It seems indeed related with the size of circuit. If I interpret qiskit_rigetti.RigettiQCSProvider documentation correctly, you should be able to extend the timeout ...
user avatar
  • 4,040
1 vote
Accepted

Append a controlled Initialize in Qiskit

The way to append gate instances to a QuantumCircuit is with the append method. ...
user avatar
  • 4,040
1 vote

How to initialize a $n$ qubit system in this specific state

@Ergetta.Thula's answer is complete. I just thought to add a little bit more to this discussion. In general, the following circuit takes the state $|0\rangle^{\otimes 2N}$ to the state $\sum_{i=1}^N \...
user avatar
  • 12.6k
1 vote
Accepted

Qiskit: Understanding statevector output

This is circuit is easy to analyse. H gate on qo will result in a + state. The x gate on q1 puts 1 to 1 state. Next te Hgate on q1 will put q1 in the - state. In the circuit measurementgates are used ...
user avatar
  • 524
1 vote
Accepted

Generating random circuits with only CNOT gates using qiskit.circuit.random.random_circuit

Just add: if max_possible_operands < 2: break before: num_operands = 2
user avatar
2 votes

Using Qiskit's AerSimulator with an AMD GPU

The GPU support included in qiskit-aer is explicitly built with CUDA, so it won't work out of the box with an AMD GPU as CUDA only works with NVIDIA GPUs. If you're trying to run simulations with ...
user avatar
1 vote
Accepted

Are there multiple control quantum gates where the control bit is an OR relationship?

If you can implement standard AND-controlled $U^\dagger$ gate you can implement your OR-controlled $U$ gate without any additional controls, as follows This is an example for the $S$ gate and 2 ...
user avatar
2 votes

Qiskit: evaluating expectation value of S^2 operator

Your qiskit installation is quite old. qiskit.chemistry is part of the now deprecated and unsupported Qiskit Aqua, see migration guide if you need. Qiskit Nature was the replacement for the chemistry ...
user avatar
3 votes

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

You can use swap test to calculate $\langle 0^{\otimes n} | e^{iA} P_j e^{-iB} |0^{\otimes n} \rangle$ for each term $P_j$ in Pauli decomposition of $H$, then do the weighted sum classically:
user avatar
5 votes
Accepted

How to initialize a $n$ qubit system in this specific state

You can generate an equal superposition on the first $n$ qubits using $H^{\otimes n}$, then use $n$ CNOT gates to get the desired state: This circuit has a depth of $2$
user avatar
2 votes

Are there multiple control quantum gates where the control bit is an OR relationship?

You can use the fact that: $$a \lor b = \neg(\neg a \land \neg b)$$ For example, in the following circuit the unitary is applied if either $q_0$ or $q_1$ (or both) equals $1$:
user avatar
1 vote

Multiple Hadamard gates Transformation on N qbits

There is a formula for the Hadamard transform on $N$ qubits. $$ H^{\otimes N}=\frac{1}{\sqrt{2^N}}\sum_{x,y\in\{0,1\}^N}(-1)^{x\cdot y}|y\rangle\langle x| $$ In this case, $$ x\cdot y=\sum_{i=1}^...
user avatar
  • 47.5k
1 vote
Accepted

Can you find how many one qubit and 2 qubit gates are in a circuit in Qiskit?

The easiest way to find the number of gates is to use QuantumCircuit.count_ops() which will return a dictionary with the name of the operations present in the ...
user avatar
1 vote
Accepted

how to go from matrix to tableau to circuit in qiskit or stim

How would I generate a corresponding tableau? You can create an empty stim.PauliString of the right size and then use indexing to set its entries (...
user avatar
  • 23.1k
1 vote
Accepted

Why is HF Initial point seems to be better than MP2 initial point in qiskit?

The reason that you are not observing the expected MP2 energy after that first energy evaluation is due to the fact that you are combining it with the unitary coupled cluster ansatz. Compared to the ...
user avatar
  • 126
1 vote

What's wrong with this simplified Bell experiment?

One issue could be that you are not taking very many samples. You have 1000 random circuits, but you seem to only simulate one shot from each of them. Since there are 9 possible settings, this means ...
user avatar
  • 655

Top 50 recent answers are included