# Tag Info

2

How about something like this: from qiskit.circuit import QuantumCircuit def my_circuit(initial_gate_params, params): circuit = QuantumCircuit(1) circuit.u3(initial_gate_params[0],initial_gate_params[1],initial_gate_params[2],0) circuit.u3(params[0], params[1], params[2], 0) return circuit initial_gate_params = [ [0,0,0], [2,3,2], [...

1

If $P_x = P_y = P_z$ then DEPOLARIZE1 is what you need. If $P_y = P_z = 0$ then X_ERROR is what you need (ditto Y_ERROR, Z_ERROR). Otherwise you can use CORRELATED_ERROR and ELSE_CORRELATED_ERROR. For example, suppose $P_x = 0.1$, $P_y = 0.2$, $P_z = 0.3$ and your target is qubit $5$. You can do this: CORRELATED_ERROR(0.1) X5 ELSE_CORRELATED_ERROR(0....

2

You can just use the constructor of the Statevector class. sv1 = Statevector.from_label('1010') # construct Statevector from string label sv2 = Statevector(sv1.data) # construct Statevector from numpy array sv1 == sv2 returns True

0

Direct conversion There is a way to convert a QuadraticProgram(QP) from Qiskit into a BinaryQuadraticModel(BQM). First the QP has to be created with Qiskit. It can have linear constraints, integer variables and binary variables. The objective can have linear and quadratic terms. Quadratic constraints and float variables are not supported in the following ...

1

Problem solving in Ocean framework goes by modeling the problem into a BinaryQuadraticModel. The pure quantum samplers natively only understand this model. For the hybrid samplers (Leap) one can model the problem into DiscreteQuadraticModel. The bias are the linear terms in those models objective functions. They are derived with respect to the problem after ...

3

This post contains a few questions, so let's first recap the steps the circuit sampler goes through (you can also check out the source code here), before answering your questions. How the Circuit Sampler works Provided with a backend/quantum instance and an operator expression, the job of the circuit sampler is to execute all circuits in the operator ...

1

Your circuit is looking like this: Thus, your unitary matrix is: $$U = CNOT \cdot \big( H \otimes X \big)$$ where \begin{align} H \otimes X &= \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \end{pmatrix} \otimes \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 \cdot \begin{pmatrix} 0 & 1 \...

1

You can use fake pulse backend to do this. from qiskit.circuit import QuantumCircuit import matplotlib.pyplot as plt from qiskit.test.mock import FakeOpenPulse2Q backend = FakeOpenPulse2Q() from qiskit import transpile, schedule bell = QuantumCircuit(2, 2) bell.h(0) bell.cx(0,1) qc = transpile(bell,backend) pulse_schedule = schedule(qc, backend) fig, ax = ...

0

i did the hamiltonian simulation with minus sign, but in QPE, I don't have to consider it

4

The number of qubits is part of the backend configuration: FakeManhattan().configuration().n_qubits 65 If you need to filter the list of mocked backends based on the amount of qubits: from qiskit.test.mock import FakeProvider provider = FakeProvider() [ b.name() for b in provider.backends() if b.configuration().n_qubits > 20] ['fake_cambridge', '...

4

All the jobs are sent in a non-blocking way. You can send all your jobs with job = backend.run and recover their results in a fully different session. In order to fully recover your Job object from a backend, you need the job id (given you are running Qiskit 0.24 or later. See @jyu00's comment) You can save your job ids like this: jobs = [] for circuit in ...

6

The IBM circuit composer used to be also known as IBM Quantum Experience, or IQX for short. For those historical reasons, the name of the style is iqx: from qiskit import * circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.t(1) circuit.draw('mpl', style='iqx') Compare with the composer look:

1

I found the answer on my own. In case someone has a similar problem: You can use the standard measure() function in the quantum circuit. When you assemble you can specify meas_level=1 which returns the raw measured data without running it through a classifier. Then you can build your own classifier.

6

That’s possible, just do circuit.draw('mpl', style='iqx')

2

Grover's algorithm has two components, which alternate and repeat $O(\sqrt{N})$ times: a diffusion operator and an oracle operator. The diffusion operator will cause problems with your idea. As I understand, what you want to do is start from a uniform superposition $$\vert \psi_0\rangle =\frac{1}{\sqrt{2^n}}\sum_{b_1,\dots,b_n\in\{0,1\}} \vert b_1\rangle \... 2 I think you underestimated how long your circuit really is.... When running your circuit on the hardware, it has to be transpile into the set of gates that is known to the hardware. For IBM machines, these are \{ CX, ID, RZ, SX, X \} . Furthermore, there is a constraint on the qubit layout of the hardware as well. Not all qubits are connected. Thus there ... 3 Well, originally the idea was that we didn't want to exclude things like continuous quantum systems, and ancillary systems being used as control surfaces, and concepts like "a place where an ion might be" as opposed to the ion itself. So we went with a very generic "identifier for quantum-associated thing" name (qid). At some point Qid ... 1 On the Qiskit slack there have been others who have the same issue connecting to Quantum Lab. A 503 Service Unavailable Error may be due to service maintenance or being overloaded. You may have to just wait for the server to return. 5 If you have an ideal quantum circuit, you can easily get its superoperator representation using qiskit.quantum_info.SuperOp as follows, qc = QuantumCircuit(1) qc.x(0) super_op = SuperOp(qc) array_to_latex(super_op) The output will be$$ \left[\begin{matrix} 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\\ 0 & 1 & 0 & 0\\ 1 & 0 ...

0

Programmatically, you have to do the following: from qiskit import IBMQ IBMQ.load_account() provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main') print(provider.backends())

4

You can do this as follow: Specify your circuit then transpile it to the backend of interst. transpile_circuit = transpile(circuit, backend) Convert this to DAG (Directed Acylic Graph) dag_circuit = circuit_to_dag(transpile_circuit) count all the operation in the longest path: dag_circuit.count_ops_longest_path() Explicit example: Says you have the ...

0

Your description sounds like the notion of depth. You can get the depth of a circuit in Qiskit with the depth method: https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.html#qiskit.circuit.QuantumCircuit.depth circuit.depth()

3

This is just a quirk of how complex numbers are implemented in Python/Numpy, etc. At the end of the day, these are represented as floating-point numbers within the target simulator. These are then transformed via various mathematical operations to implement the simulation and this eventually leads to an accumulation of round off error. For all intents and ...

6

The answer seems to be "no" for all three. From what I can find, Cirq and PyQuil default to QuTiP for Bloch sphere visualization, and ProjectQ does not have any examples to go off of, nor can I find the functionality in their GitHub. TensorFlow Quantum, which primarily uses Cirq (since they are both owned by Google), used qutip.Bloch in this ...

1

I think the widget is supposed to only show you the initialization and Oracle part of the circuit and not actually implement the measurement process into it. Thus, that is why you don't see the measurement step. However, it is quite simple to write a function for perform the Bernstein-Vazirani algorithm. You can just use the script below: import numpy as np ...

1

According to the docs of scipy and qiskit, the first uses primitive root $\omega = e^{-\frac{2\pi i}{n}}$ and the second uses $\omega = e^{\frac{2\pi i}{n}}$. This implies that one matrix is complex conjugate of the other (which is the same as inverse).

0

Analogy to numbers in binary format: number 2 = b10 (2 bits) number 6 = b110 (added 1 bit , and it is the highest bit) If 6 is represented as an array: arr=[0,1,1], that is what we would expect but it is the opposite order as binary representation. For qubits, the register is created the same way. Mathematicians could explain nomenclature better but in bra-...

2

The reason for your second result is because unitary synthesis is not part of the SolovayKitaevDecomposition pass. Actually, you can combine your attempts to get the desired result. This is the first stage (you first snippet), it will synthesise your circuit in terms of u* and cx: from qiskit import QuantumCircuit from qiskit.quantum_info import Operator ...

4

You can definitely run this on a real quantum computer! In your snippet above you mixed circuits and operators. A circuit is only used for the ansatz of your ground state, not for representing the operators. The website you provided talks about the Hamiltonian in terms of the Pauli X and Z matrices; $\hat\sigma^x$ and $\hat\sigma^z$. If you want to compute ...

2

The reason for your error is that you are running on a backend that does not support CH. The function execute works because it runs transpile before, adapting the basis. However, if I understand the spirit of your question, you can quickly get the unitary of any circuit using kaleidoscope, a very nice 3rd-party Qiskit extension. It can be installed with pip ...

3

As it is written in the error message, it is here because the CH gate is not in the basis gates of UnitarySimulator, therefore the backend doesn't understand it and can't do anything with it ; check this line of code : 'ch' in UnitarySimulator().configuration().basis_gates It returns False. Now I believe it has the error with the run method and not the ...

0

Thanks for the comments. If I use python 3.7.3 (3.8 won't work) + qiskit 0.23.5, I can get fidelity = 1.

1

This is normal! If you look at the molecular Hamiltonian ozone_molecule.get_molecular_hamiltonian(), you will notice that it is a Hamiltonian that acts on 30 spin orbitals, and so ozone_qubit_hamiltonian is a 30 qubit Hamiltonian. This means it has $2^{30} \times 2^{30} = 2^{60} \approx 1.15 \times 10^{18}$ matrix elements, which will surely consume all your ...

2

If you want, everything is detailed here about the system configuration, it will explain everything you can find in the configuration. Just a quick resume about how to see the info : personally, I sometimes use backend.configuration().to_dict(), with this all of the information will be printed in a dict, and it's pretty easy to use. Now, you can also do a &...

2

Number of states marked isn't a strict correspondence with number of CZ gates: your new oracle still marks two states, but, rather than $\left|101\right>$ and $\left|110\right>$, it marks $\left|101\right>$ and $\left|111\right>$. To see this, remember a $Z$ gate flips the sign of a $\left|1\right>$: if the $Z$ gate is applied to a 1 and the ...

1

To use the GaussianForcesDirver in Qiskit, you either need an output file generated by Gaussian (such as this .log file from the tutorial). Or you need an installation (and hence also a license) of Gaussian, as stated in the Qiskit documentation here: The drivers in the chemistry module obtain their information from classical ab-initio programs or libraries....

1

Measurements in a VQE (also in Qiskit) are performed as projective measurements. Have a look here for a related question in Physics SE. Citing from Nielsen and Chuang's book "Quantum Computation and Quantum Information": A projective measurement is described by an observable, $M$, a Hermitian operator on the state space of the system being ...

0

I believe these links can help solve your problem: https://qiskit.org/documentation/stubs/qiskit.aqua.algorithms.VQE.html https://qiskit.org/documentation/apidoc/qiskit.aqua.operators.expectations.html https://qiskit.org/documentation/tutorials/noise/1_hamiltonian_and_gate_characterization.html

2

No symbolic computation software with quantum circuits built in The asker has clarified in this comment that they want a symbolic computation software in which the user does not "have to manually define circuits in terms of matrix multiplications", and the question says that the software cannot "force you to encode the matrix of each gate ...

Top 50 recent answers are included