Hot answers tagged

10

I view QAOA as an algorithm for solving (approximately) a special class of problems, namely combinatorial problems and VQE as a possible subroutine to QAOA (but not necessarily as in the case of MaxCut). Let me explain The VQE - Variational Quantum Eigensolver - solves the problem of approximating the smallest eigenvalue of some Hermitian operator $H$ which ...


7

If you want to extract the exact value then would need infinite number of samples. However, assume no hardware noise, based in the Chebyshev's inequality you would need to do $O(1/\epsilon^2)$ to get within $\epsilon$ accuracy for each circuit in your experiment. Here, each circuit correspond to a Pauli term that your operator $O$ decomposed into. For ...


7

Welcome to Quantum Computing StackExchange. In general, finding the ground state energy of a k-local Hamiltonian is QMA-hard for k ≥ 2. That means, any problem in the complexity class QMA can be solved by reducing it to a k-local Hamiltonian and finding its ground state. And since NP is a subclass of QMA, any NP problem can be solved this way including NP-...


6

You're right in the sense that the cost unitary, which is composed of all the $Z$ and $CZ$ gates does not affect the underlying probabilities of measuring a specific state by itself, however when we apply the mixer (the layer of $Rx$ gates), the probabilities are changed, due to these added phases. Let's look at a basic example, to convince you that ...


6

Qiskit currently supports measurements in the computational basis from Qiskit Terra and Aer, that is, returning 1 if the qubit is in state $|1\rangle$, and 0 if the qubit is measured to be in state $|0\rangle$. However, it is relatively easy to perform a change of basis unitary to our quantum circuit just prior to measurement, in order to instead measure in ...


5

The computational advantage of using quantum computers can be reached if the classical resources (memory; number of operations), required to solve a particular problem, grow exponentially in a certain parameter, while the quantum resources (memory; number of operations; number of measurements) grow polynomially in the same parameter. Finding the lowest ...


5

You can plug any parameterized QuantumCircuit into the VQE. Parameterized means it contains Parameter objects e.g. as rotation angles. For instance from qiskit.circuit import QuantumCircuit, ParameterVector from qiskit.aqua.algorithms import VQE params = ParameterVector(3) wavefunction = QuantumCircuit(3) wavefunction.ry(params[0], 0) wavefunction.ry(...


5

You can use a callback function to save the parameters for each iterations of your vqe algorithm and even store the mean, std. Below an example: # Create the callback function to store intermediate values in vqe counts = [] values = [] parameters_list=[] std_list=[] def store_intermediate_result(eval_count, parameters, mean, std): counts.append(...


5

VQE has an initial_point parameter, which is the starting point it uses for the optimization. In the absence on one being provided (or suggested via the variational form) it will pick a random one. You can seed Aqua, like you did the simulator, so it will end up with the same random one each time, to get a predictable outcome. Add the following to do this ...


5

Let's denote $P$ as a Pauli tensor product term (Pauli term: e.g. $Z \otimes Z$, $X \otimes X$ or $Y \otimes X \otimes X$), then note that $P$ is a Hermitian matrix whose expectation value is real, the eigenvalues are $+1$ and $-1$ with corresponding eigenspaces. The expectation value of $P$ will be equal to: $$ \langle \psi | P |\psi\rangle = p_{+} - p_{-}$$...


5

Interesting question! An ansatz circuit is a parameterized circuit, say $V(\theta)$ where $\theta$ are a set of parameters, used to prepare a trial state for your problem: $$ |\Psi(\theta)\rangle = V(\theta)|0\rangle $$ In a variational algorithm, such as VQE, the trial state encodes your solution and is iteratively updated until some termination criterion ...


5

In term of the $RY$ Ansatze, from my understanding, this is because many systems of interest, the Hamiltonian contains only real terms. And if we have real Hamiltonian, then the decomposition of the matrix representation of the Hamiltonian can be achieved with real eigenvectors. Now, a single-qubit $RY$ rotation confined the qubit state remains real. That is,...


4

The proof of the variational theorem (the theorem that the ground state energy is the lowest possible energy you can get from $\frac{\langle \psi|H|\psi\rangle}{ \langle \psi | \psi \rangle}$) is very simple: https://en.wikipedia.org/wiki/Variational_method_(quantum_mechanics) If you get a lower energy, it means you don't actually have $\frac{\langle \psi|...


4

When you have $\langle \varphi | I \otimes Z | \varphi \rangle $ It means you are calculating the expectation of the operator $I \otimes Z$ with respect to some state $|\varphi \rangle$. Since $I$ is on the first qubit, we would not need to do anything there, no need to do any rotation or even measurement. The eigenspace is decomposed into two halves ...


4

First, note that we can only measure in the computational basis in quantum computing (at least at the moment). But this is not a problem since \begin{align} \langle \psi | H | \psi \rangle = \langle \psi | 2X + 0.5 Z | \psi \rangle &= 2\langle \psi | X |\psi \rangle + 0.5\langle \psi|Z|\psi\rangle \\ &= 2\langle \psi|HZH|\psi\rangle + 0.5\langle\...


4

Short answer: The units of your result will be the same as the units of your input problem to VQE (units of your Hamiltonian coefficients). Long answer: In a VQE calculation, some problem Hamiltonian is mapped to a representation that is suitable for implementation in a quantum circuit. Often, this means mapping all Hamiltonian operators to strings of Pauli ...


3

I think that $UCC$ ansatz is good for chemistry related problems. However, if you an arbitrary Hamiltonian and want to find its smallest eigenvalue then it's not very obvious what the anstaz form should look like.... it will also depend on how you initialize your state. And if you define an anstaz with polynomial number of gates, you don't expect to be able ...


3

This can actually be easily done using the Qiskit Terra qiskit.quantum.info.analysis.average.average_data function that takes the counts data returned by a backend and the desired observable defined by a dict, list, or ndarray. The doc-string for that function actually has the ZZ your looking for as an example.


3

You can create an arbitrary number of parameters in your circuit by using the qiskit.circuit.Parameter class. Here's a brief example from qiskit.circuit import Parameter, QuantumCircuit # define your parameters a, b, c = Parameter('a'), Parameter('b'), Parameter('c') circuit = QuantumCircuit(2) circuit.rx(a, 0) # RX(a) on qubit 0 circuit.ry(b, 0) # RY(b) ...


3

If you decomposed your Hamiltonian into Pauli strings, and it has 100 different terms, then yes you can use one machine to do the quantum subroutine to evaluate the expectation for each of the term. $$ \langle H \rangle = \sum_{i} h_i \langle P_i \rangle $$ So you can evaluate $\langle P_1 \rangle$ on one machine and $\langle P_2 \rangle$ on another machine.....


3

Here I am going to show why $\langle Z_1 Z_3 \rangle$ generally cannot be estimated from $\langle Z_1 Z_2 \rangle$ and $\langle Z_2 Z_3 \rangle$. Let's start with an arbitrary three-qubit state: \begin{align*} |\psi \rangle = c_{000} &|000\rangle + c_{001} |001\rangle + c_{010} |010\rangle + c_{011} |011\rangle + \\ +c_{100} &|100\rangle + c_{101} |...


3

The line: exact_result = NumPyMinimumEigensolver(qubit_op, aux_operators=aux_ops) should be exact_result = NumPyMinimumEigensolver(qubit_op, aux_operators=aux_ops).run() Here is the full code that I ran and its output: # %% import numpy as np import pylab import copy from qiskit import BasicAer from qiskit.aqua import aqua_globals, QuantumInstance from ...


3

Seems like you are mixing a couple of things here. The VQEUCCSDFactory uses the HartreeFock state as an initial_state by default. See also here VQEUCCSDFactory. The initial_point that you are specifying is the initial values of the variational parameters to start the optimization from. One more point, seeing you snippet seems like you want to calculate a PES ...


3

Although the documentation says that the entanglement_blocks parameter can be specified via the name of a gate or the gate type itself, not all gates can be used this way. You can check the code to get the list of supported gate names. Since "pass by name" is not supported for iSWAP, you can use the gate type: ansatz = TwoLocal(num_spin_orbitals, ['...


3

You can set the attribute parameters_bounds of a circuit to the desired intervals like below: from qiskit import QuantumCircuit from qiskit.circuit import Parameter a=Parameter('a') b=Parameter('b') ansatz=QuantumCircuit(2) ansatz.ry(a,0) ansatz.ry(b,1) ansatz.parameter_bounds=[[0,np.pi]]*2 Then you can run your vqe program.


3

With just single qubit gate in your circuit, you can only generate a small subset of quantum states. In fact, the states that you can generate are called separable states. These states have no entanglement in them. Here is an example to see why you need to be able to generate entangle state to have successful VQE calculation, supposed you have the ...


3

Easy Fix: It seems like it is because of the way you define $H$. You need the parenthesis around each of the term! So something like: H = (504.0 * I^I^I^I^I^I^I^Z) + (1008.0 * I^I^I^I^I^I^Z^I) + ( 2016.0 * I^I^I^I^I^Z^I^I) Just replace this in your code then it will work! Alternative (longer) way: Here I will offer another way to define the Hamiltonian ...


2

Remember that we can expand $$ e^{i\gamma(Z\otimes Z)}=I\cos\gamma+i(Z\otimes Z)\sin(\gamma). $$ Let's call this $U$. If I calculate $$ U|+\rangle|+\rangle=\cos\gamma|+\rangle|+\rangle+i\sin\gamma|-\rangle|-\rangle. $$ For most vales of $\gamma$, this state is entangled (indeed, for $\gamma=\pi/4$, you essentially have a Bell state in the Hadamard basis). So ...


2

When $H = I_1 \otimes I_2$, $e^{-i\gamma I_1 \otimes I_2} = I_1 \otimes I_2$. Therefore, you don't have to apply any gates. Your CNOT RZ CNOT circuit represents the time evolution of Ising coupling. However, if you want to solve the Ising model problem by QAOA, you need "mixing term" like RX rotation. Rigetti grove's document is very good to understanding ...


2

If you have one parameter (one $\theta$) for both circuits then I think the first one is better... they are doing the same job, but the second one is creating extra gates. So the first one will be faster and will have fewer errors because there are fewer gates in the first circuit. But if you are obtaining the second circuit with two parameters (two ...


Only top voted, non community-wiki answers of a minimum length are eligible