New answers tagged


If you are looking for a more complete implementation of a quantum variational algorithm in the context of Cirq, I would recommend looking at the second example in the OpenFermion-Cirq notebook found here. It uses a custom ansatz for hydrogen in a minimal basis, but makes a bit more explicit all the required pieces. Another good example, perhaps without ...


When using a simulator, it doesn't really matter what kind of qubit you refer to. You can even mix-and-match the types. The type of qubit only becomes relevant when you intend to run on a device, because devices have qubits at specific locations. For example, if you wanted to run on Bristlecone, you would limit yourself to GridQubit instances that actually ...


Cirq defines qubits to be LineQubits or GridQubits, since these are common constructions in NISQ computers. Qubits are commonly defined in lists (or generally iterables) for easy indexing in algorithms. In simulation using either has no impact on your algorithm. From Cirq's documentation GirdQubit is a qubit on a 2d square lattice.


This is actually very easy in Cirq. The controlled_by method can be used to automatically make any given gate controlled by an arbitrary number of control qubits. Here is a simple example for creating an X gate with 5 controls: import cirq qb = [cirq.LineQubit(i) for i in range(6)] cnX = cirq.X.controlled_by(qb[0], qb[1], qb[2], qb[3], qb[4]); circuit = ...

Top 50 recent answers are included