Hot answers tagged

17 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 ...
Paul Nation's user avatar
  • 2,239
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, ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Adrien Suau's user avatar
  • 4,777
8 votes
Accepted

is cirq suitable for simulation of quantum error correction?

I wrote most (as in >50% not as in all) of the initial versions of cirq, and was its team lead for a couple years. I wouldn't recommend using Cirq as a tool for simulating QEC codes. Cirq is first ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
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" ...
Craig Gidney's user avatar
  • 33.3k
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: ...
Craig Gidney's user avatar
  • 33.3k
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. ...
Joseph Geipel's 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 ...
Kevin Sung's 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, ...
Craig Gidney's user avatar
  • 33.3k
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: ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Jack Ceroni's 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 ...
ryanhill1's user avatar
  • 2,433
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: ...
Craig Gidney's user avatar
  • 33.3k
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 ...
met927's user avatar
  • 3,241
5 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 ...
Michael's user avatar
  • 393
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]) ...
KAJ226's user avatar
  • 13.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 ...
Craig Gidney's user avatar
  • 33.3k
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, ...
Craig Gidney's user avatar
  • 33.3k
5 votes
Accepted

Controlled NOT gate which flips target when at least one of the control qubits is |1>

Use De Morgan's law to turn intersection into union.
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
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 ...
dabacon's user avatar
  • 675
4 votes

Overview of Cirq, qiskit, q#, ibmq(circuit board), other

I am definitely biased (writing a book on quantum computing with Python and Q#), but I am a Pythonista and love using Q#. The design of the language is good for long term quantum computing development;...
Dr. Sarah Kaiser's user avatar
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 ...
AHusain's user avatar
  • 3,613
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: ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
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 ...
Craig Gidney's user avatar
  • 33.3k
4 votes

How to assign values to the symbols in a parametrized Cirq circuit without running it?

You're looking for cirq.resolve_parameters(object, resolver), which returns the object after the parameters have been resolved. For example: ...
Craig Gidney's user avatar
  • 33.3k

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