# Tag Info

15

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 quantum computing is a primary goal in what we do. Basically, the more doors you open, the more people can walk through and do cool things. Free access to quantum ...

12

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 adjacent pair of qubits on a grid. You can see the grid by installing cirq and printing out the Bristlecone device: $pip install cirq$ python >>> ...

11

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, they run a lot of tutorials and create a lot of course materials. And, maybe most importantly, they make it reasonably frictionless for someone to run something ...

9

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 qubits from left to right, top to bottom (just like how you read english), starting by $0$ then the connectivity map would be given by: connectivity_map = { i ...

7

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 = ...

7

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 CZPowGate is equivalent to an operator generated by $Z \otimes Z$ up to single-qubit rotations. The idea is that Step 2 of the ansatz corresponds to applying a pulse ...

7

You can use the controlled_by method on any Operation: op = cirq.X(target_qubit).controlled_by(control_qubit) You can also use controlled before specifying the target qubits: op = cirq.X.controlled().on(control_qubit, target_qubit) There are also built-in controlled operations such as cirq.CNOT, cirq.CZ, and cirq.CSWAP. The built-in operations are ...

7

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" methods, like cirq.Simulator().simulate(...) have a parameter initial_state which can either be a computational basis state (specified as an integer e.g. ...

7

GridQubit has comparison methods defined, so sorted will give you a list of the qubits in row-major order: >>> sorted(cirq.google.Foxtail.qubits) [GridQubit(0, 0), GridQubit(0, 1), [...] GridQubit(1, 9), GridQubit(1, 10)] Once you have that, you're one list comprehension away: >>> [(q.row, q.col) for q in sorted(cirq.google.Foxtail....

6

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: cs = cirq.CZ**0.5 More generally, cirq.ControlledGate works on any gate. It's a bit clunkier than the dedicated gates, but it does support being raised to a power (as long as the ...

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

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

5

Cirq uses numpy's pseudo random number generator to pick measurement results, e.g. here is code from XmonStepper.simulate_measurement: def simulate_measurement(self, index: int) -> bool: [...] prob_one = np.sum(self._pool.map(_one_prob_per_shard, args)) result = bool(np.random.random() <= prob_one) [...] Cirq ...

5

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

5

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 initialization as follows : vector = [0,1] qr = QuantumRegister(1) qc = QuantumCircuit(qr) qc.initialize(vector, [qr[0]]) There is more detail about how to use it in this tutorial

5

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])$ This can be generalized to any size as well. So if you have then it can be written as an $8 \times 8$ matrix $U$ as $U = R_y(a[0]) \otimes R_z(a[1]) \... 4 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 t) = e^{-iZt/2} = \begin{bmatrix} e^{-i \pi t / 2}&0\\0&e^{+i \pi t / 2} \end{bmatrix} = e^{-i \pi t/2} Z^t$$ Which means that $$Z^t \equiv R_Z(\pi ... 4 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 initialize won't know this a priori. So it won't realize the initialization circuit can be decomposed easily. Or at least it will need to do some extra ... 4 One simple way to do it is by defining a composite gate, like this: class MyGateThenDepolarize(cirq.SingleQubitGate): def _decompose_(self, qubits): q = qubits[0] return [MyGate.on(q), cirq.depolarize(p).on(q)] If you want a depolarizing gate on every qubit at the end of every moment, you can do a noisy simulation: cirq.sample(circuit, ... 4 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 actually happen on hardware. Whether or not two gates are run in parallel is really important information when dealing with noise (e.g. it determines total runtime),... 4 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 them as tightly as possible, so the number of moments will be the depth. depth = len(cirq.Circuit(my_circuit.all_operations())) 4 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 then ask about its properties, such as its effect on a qubit, in another line. In this case, you want to ask what the final_wavefunction of your circuit is and ... 4 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 workaround would be to try and determine the gate decomposition for your custom gate in terms of tfq.util.get_supported_gates gate instances. A good place to ... 4 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\rangle to the ancilla register. THis means that if you started wuth$$ \sum_xa_x|x\rangle, $$you now have$$ \sum_xa_x|x\rangle|x\rangle. $$Next, find a bit ... 4 cirq.inverse(operation) will return the conjugate transpose of an operation. Equivalently, you can use operation**-1 (this is the first thing that cirq.inverse tries). For the specific case of R_y, you can just negate the angle i.e. use cirq.ry(-theta). 4 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 root of the gate. For example, cirq.X, cirq.H, cirq.Z, and cirq.S are all implemented using classes that derive from eigengate. As a result, you can compute roots like cirq.Z**0.5 == cirq.S. The ... 3 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 ... 3 I would suggest to start with Quirk as it offers a drag-and-drop circuit model. Furthermore, Quirk offers some subroutines such as basic arithmetic operation (on integers) and allows to easily define new subroutines. (All drag an drop!) It can simulate up to 17 (?) qubits. Once you want to go beyond an "easy" circuit representation I suggest Microsofts Q#. ... 3 The Fourier transform part (everything from the swaps onward) looks correct. The initialization (column of Hadamards) looks correct. But the part where you do controlled modular multiplications doesn't, because there's no operations controlled on the 2nd through fifth qubits that you are QFT-ing. You also seem to expect the output to be the period, when ... 3 You can test stand alone the a modular multiplication circuit. In this case \text{base} = 2 and N = 3. However the smallest useful composite N = 15 = 3 \times 5. Let's take a well known Multiplication by 7 modulo 15 circuit We start with input$$\ |1\rangle \text{ gives } |7\rangle\ |7\rangle \text{ gives } |4\rangle\ |4\rangle \text{ gives ...

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