Hot answers tagged

16 votes
Accepted

Is Qiskit more popular than cirq? Why?

The answer above, from a Cirq developer, is mostly in the right direction. We (Qiskit / IBM) probably do spend more on outreach and education (I also do not know for sure). Democratization of ...
user avatar
  • 2,169
14 votes

Is Qiskit more popular than cirq? Why?

Completely speculating here, but I think the main differentiator is that IBM has a stated goal of, and spends significant resources on, getting quantum computing into everyone's hands. For example, ...
user avatar
  • 23.4k
12 votes

What are physically allowed CNOTs for Rigetti's 19 qubit chip and Google's 72 qubit BristleCone chip?

Bristlecone's native operation is the CZ, not CNOTs. However, you can transform between the two with Hadamard gates so this is sort of a trivial difference. Bristlecone can perform a CZ between any ...
user avatar
  • 23.4k
9 votes

What are physically allowed CNOTs for Rigetti's 19 qubit chip and Google's 72 qubit BristleCone chip?

From the original blog post presenting the Bristlecone quantum chip, here is the connectivity map of the chip: Each cross represent a qubit, with nearest-neighbour connectivity. If you number the ...
user avatar
  • 4,542
7 votes
Accepted

How to add control to gates in Cirq?

You can use the controlled_by method on any Operation: op = cirq.X(target_qubit).controlled_by(control_qubit) You can also ...
user avatar
  • 23.4k
7 votes
Accepted

How to set a starting state in cirq?

Cirq distinguishes between "running" a circuit, which is generally supposed to act like hardware would (e.g. only getting samples), and "simulating" a circuit, which has more freedom. Most "simulate" ...
user avatar
  • 23.4k
7 votes
Accepted

List of qubit locations with cirq

GridQubit has comparison methods defined, so sorted will give you a list of the qubits in row-major order: ...
user avatar
  • 23.4k
7 votes
Accepted

N-Toffoli on Cirq

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. ...
user avatar
7 votes
Accepted

Creating an ansatz for variational quantum algorithms?

Take a look again at the Hamiltonian, which is $$ H = \sum_{\langle i, j \rangle} J_{i j} Z_i Z_j + \sum_{i} h_i Z_i $$ Then notice that ZPowGate is generated by the the Pauli Z operator, and ...
user avatar
6 votes
Accepted

GridQubit in Cirq vs LineQubit

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, ...
user avatar
  • 23.4k
6 votes

Is it possible to create controlled gates with an exponent in Cirq?

Yes, it is possible to create controlled gates with an exponent in Cirq. For the specific case of the Z gate, Cirq includes a dedicated CZ gate that can be raised to a power: ...
user avatar
  • 23.4k
6 votes
Accepted

Is there a mistake in the VQE Ansatz in Cirq's tutorial?

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 ...
user avatar
6 votes
Accepted

Bloch sphere visualization using Cirq, ProjectQ, PyQuil

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 ...
user avatar
  • 1,898
5 votes
Accepted

Where does the Xmon simulator from Googles cirq framework its entropy from?

Cirq uses numpy's pseudo random number generator to pick measurement results, e.g. here is code from XmonStepper.simulate_measurement: ...
user avatar
  • 23.4k
5 votes

How to prepare a specific initial state of three qubits?

You can initialize a quantum state by using the QuantumCircuit.initialize() function. For example, to initialize a circuit into the state |1>, we can perform the ...
user avatar
  • 3,193
5 votes
Accepted

How do you represent one-qubit rotations in two registers as a $4\times 4$ unitary matrix?

Note 100% sure if this is what you are asking but when you have a circuit like: and you want to write it as a $4 \times 4$ Unitary matrix $U$ then you can do it as: $ U = R_y(a[0]) \otimes R_z(a[1]) ...
user avatar
  • 12.7k
5 votes

Does anyone have some references on EigenGate used in Google's cirq framework?

The cirq.EigenGate class is not one specific gate; it's more like a framework for describing gates in a way that makes it easy to do things like compute the square ...
user avatar
  • 23.4k
5 votes
Accepted

Random circuits with google cirq

Cirq does have some methods for generating random circuits, such as cirq.testing.random_circuit and cirq.random_rotations_between_grid_interaction_layers_circuit. That being said, in my experience, ...
user avatar
  • 23.4k
4 votes

How is $X^q$ equal to $RX(\pi q)$?

This is the matrix for $Z^t$: $$Z^t = \begin{bmatrix} 1&0\\0&(-1)^t \end{bmatrix} = \begin{bmatrix} 1&0\\0&e^{i \pi t} \end{bmatrix}$$ This is the matrix for $R_Z(\pi t)$: $$R_Z(\pi ...
user avatar
  • 23.4k
4 votes

Estimate run time of Cirq circuit on forthcoming Google quantum computer

You can get a rough idea of runtimes by using the cirq.estimate_run_time (doc), cirq.estimate_run_sweep_time(doc), or ...
user avatar
  • 655
4 votes
Accepted

How to prepare a specific initial state of three qubits?

If you call initialize in this case, you will be specifying a general state in $\mathbb{C}^8$. However what you have is more specialized. For example only having 4 nonzero amplitudes. So the call to ...
user avatar
  • 3,553
4 votes

How to add noise to existing gates in Cirq?

One simple way to do it is by defining a composite gate, like this: ...
user avatar
  • 23.4k
4 votes
Accepted

Moments-based quantum circuit in Cirq

What is the design philosophy behind the moment-based quantum circuit? What are the advantages and disadvantages of it? The basic idea is that we wanted to give users more control over what will ...
user avatar
  • 23.4k
4 votes

Computing circuit depth in Cirq

On hardware, the number of moments is the relevant metric. That is why cirq focuses on that. To compute circuit depth in cirq, create a new circuit using just the operations. It defaults to packing ...
user avatar
  • 23.4k
4 votes

Cirq - Print state of qubit

Your mental model of how cirq works is slightly off. You don't invoke operations on a qubit in one line and then check how that qubit changed in another line. You create a circuit in one line and ...
user avatar
  • 23.4k
4 votes
Accepted

Does TensorFlow Quantum tfq.convert_to_tensor work on custom gates?

I'm the engineer who looks after TensorFlow Quantum. Serializing custom gates is not supported. There is an active issue on the GitHub here: https://github.com/tensorflow/quantum/issues/354 . A quick ...
user avatar
  • 373
4 votes
Accepted

In Simon's algorithm, is there a general method to define an oracle given a certain periodicity?

Assuming $x$ is $n$ bits, here's a simple procedure: take $n$ ancilla qubits, all prepared in $|0\rangle$. Do a transversal controlled-not (i.e. bit by bit controlled-not) from the register with $|x\...
user avatar
  • 47.5k
4 votes
Accepted

Is there a way to present conjugate transpose of a Y Pauli rotation as a Cirq Operator?

cirq.inverse(operation) will return the conjugate transpose of an operation. Equivalently, you can use operation**-1 (this is ...
user avatar
  • 23.4k
4 votes

Wrong expected value from cirq PauliString

You want cirq.PauliSum instead of cirq.PauliString. Actually you had exactly that... but then asked for it to be converted to a <...
user avatar
  • 23.4k
3 votes
Accepted

How to implement NM Algorithm for Variational Quantum Eigensolver?

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 ...
user avatar

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