Questions tagged [cirq]

A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits. It is a Python library for writing, manipulating, and optimizing quantum circuits and running them against quantum computers and simulators.

Filter by
Sorted by
Tagged with
2 votes
0 answers
120 views

Wrong Expectation value when implementing a VQE for the Heisenberg Hamiltonian

I tried to implement an extended Heisenberg-Hamiltonian as an extra exercise further than my homework. My Hamiltonian is the following: $H = \sum_{NN} \sigma_x\sigma_x + \sigma_z\sigma_z$ I try to ...
0 votes
1 answer
365 views

XX and YY and ZZ Hamiltonians in vqe

I'm trying to implement a vqe in cirq and I have sort of a brain knot. I have a 4 qubit chain with periodic boundary condition. So in fact a 2x2 qubit grid. Now 2 of them each are coupled. How do I ...
-1 votes
1 answer
87 views

Implementing Cirq Coding Gates

Can someone please help me making these gates on CIRQ programming: Decrement Gate (-1) Splitter Gate (If possible) I was having trouble implementing these and was not sure if it's possible either. ...
  • 33
1 vote
2 answers
141 views

Running Google Cirq example code from their webpage -- where do I find information about PROCESSOR_ID?

I'm just ttrying to run the simple example code in Google's Cirq startup page: https://cirq.readthedocs.io/en/stable/google/engine.html I think I have the access authorized correctly via Google's ...
  • 11
1 vote
1 answer
101 views

Reordering commuting gates in cirq to reduce circuit depth?

The main functionality for ordering gates in a cirq circuit that I'm aware of is using the predefined insert strategies of cirq.Circuit.insert(). As far as I see, ...
  • 45
-1 votes
1 answer
49 views

Create this state using CIRQ Coding language [closed]

I needed help with CIRQ coding as I'm quite new to Quantum Computing. I read the tutorials on CIRQ but don't really understand it. I'd be very thankful if someone could help. A program to create the ...
  • 33
-1 votes
1 answer
71 views

What is the analysis of the Bell Inequality protocol in Cirq's 'examples'?

This question is taken from https://github.com/quantumlib/Cirq/issues/3032. The "standard" protocol measures Alice's and Bob's qubits in different bases, while the one in Cirq measures in ...
1 vote
1 answer
206 views

Applying a gate to all line qubits without explicitly listing them in Cirq

Say we have a custom gate CG, defined by a unitary matrix U, and line qubits qubits in Cirq. ...
1 vote
1 answer
231 views

Visualizing custom gates in Cirq

I'm trying to visualize a custom gate in Cirq. I have through this page, which briefly mentions how to create custom gates in Cirq. However, I'm getting errors when trying to visualize it. My current ...
0 votes
1 answer
131 views

How to build a controlled two-qubit gate?

I have a two-qubit gate with below unitary: ...
  • 47
1 vote
1 answer
125 views

Can not build circuit unitary for a three-qubit gate in Cirq

I am trying to implement a three-qubit gate in an eight-qubit circuit. The method I use is the same by which I create my two-qubit gates with no issues. I produce the unitary of the gate and then ...
  • 47
1 vote
0 answers
99 views

Adding Quantum State Tomography Step to HHL Algorithm (Cirq)

Over the past month, I have been learning about the HHL algorithm and am interested in extending the Cirq implementation to include the quantum state tomography step to extract the amplitudes or ...
2 votes
1 answer
292 views

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

Is there a way to use a ParamResolver or Sweep to assign values to the symbols in a parameterized Cirq circuit without running it? For example, something like: ...
1 vote
1 answer
38 views

Can't append multiple times with self-defined oracle

...
2 votes
1 answer
259 views

How to cite cirq in a scientific article?

What would be the best/prefered bibtex entry for citing cirq ? Is this ok ? ...
1 vote
0 answers
41 views

Can We Currently Import Quantum Datasets (Datasets Containing Quantum Data) Onto NISQ-era Quantum Computers?

I'm still investigating the TFQ whitepaper. In one section of the paper, the authors say this with respect to Quantum Datasets In general, [a quantum dataset] might come from a given black-box ...
0 votes
1 answer
209 views

Implementing U2-Gates on Cirq

I am interested in using the QASM2Cirq methods to make this gate: u2(0, np.pi, q[0]). How can I build that object using Cirq rather than QASM string value passed onto cirq.
0 votes
1 answer
538 views

VQE for Beginners : Using Tutorial and Cirq

I have been following this tutorial: https://dkopczyk.quantee.co.uk/vqe/ I am using Cirq to try to teach myself VQE, replicate their results, and also try to understand more about ansatz for ...
0 votes
1 answer
65 views

Placement of quantum circuits

I have a question concerning the placement of quantum circuits on Google devices. Consider the following code: ...
2 votes
0 answers
116 views

A bug during CIRQ installation

I had the following problem with an installation of the Cirq. When I typed python -m pip install cirq, I got the following line: "Cannot uninstall 'sympy'. It is ...
  • 21
2 votes
1 answer
869 views

Cirq: easiest way to compute qubit Hamiltonian expectation value with number of shots

I was wondering what was the easiest way to take a qubit Hamiltonian, and get an expectation value estimated with a certain number of shots over a parameterized quantum circuit (or ansatz) with Cirq.
  • 4,604
3 votes
1 answer
327 views

Building a state with parallel execution

I'm trying to implement the main algorithm described in the Quantum Recommendation Systems paper. In order to do this, I have to create a quantum state $|x\rangle$ corresponding to a real vector ...
1 vote
2 answers
358 views

How to calculate the probabilities of observing quantum states using the "expectation_from_wavefunction" in cirq (and why)

I am currently simulating some quantum circuits, and want to calculate the probabilities of observing each individual state. I am able to use Cirq for this, and calculate it using $P_{00} = |\alpha|^2$...
1 vote
2 answers
399 views

Normalization of the quantum state in Cirq

My understanding, for instance from this youtube video, is the following: Assuming a state $\psi = \alpha |0\rangle + \beta |1\rangle$, where $\alpha$ and $\beta$ can be complex. I believe any state ...
1 vote
0 answers
131 views

Explanation of HHL Cirq implementation [closed]

Can someone help me in understanding the program on the link given below? I would really appreciate if someone could give a detailed explanation ... https://github.com/quantumlib/Cirq/blob/master/...
  • 11
2 votes
1 answer
385 views

Cirq - Print state of qubit

Seeing a state of qubit is too complicated in Cirq I don't want to simulate, I would be happy for debugging, to see the probability/ amplitude of the state of a qubit, without measure and simulate ...
2 votes
2 answers
525 views

VQE Cirq example

Is my understanding correct that in this example the Hamiltonian measurement is not performed through measuring individual Pauli operators because all its terms are mutually commuting? So, for each ...
  • 1,700
1 vote
0 answers
104 views

Ising Model, Graphs, and Cirq

How would you explain, pictorially and without too much overhead, an interaction between the qubits on this model using Cirq? I am interested in trying to map accurately the ansatz on Cirq to a ...
1 vote
1 answer
110 views

Cirq: creating a new device with custom coupling topology?

Cirq has two in-built realizations of quantum hardware, which are realized as GridQubit() and LineQubit() classes (naming convention is slightly disturbing:). GridQubit device mimics connectivity of ...
1 vote
1 answer
368 views

Computing circuit depth in Cirq

I ran into a problem of how to extract circuit depth from Cirq circuit object. In Cirq circuits consist of a list of Moments. Number of moments is not equal to the circuit depth in general case. I ...
4 votes
1 answer
378 views

Moments-based quantum circuit in Cirq

In Cirq, quantum circuit consists of moments, which in turn consists of operations. This is different from Qiskit/OpenQASM, which doesn’t have the concept of moments. What is the design philosophy ...
8 votes
1 answer
417 views

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

I have been going through Cirq's VQE background tutorial and after examining the Ansatz it seems to me that the only layer that actually affects the final measurement is the rot_x_layer. The other ...
  • 138
4 votes
1 answer
401 views

How to add noise to existing gates in Cirq?

I would like to add noise to existing gates in Cirq, i.e. to define something like NewGate = cirq.Gate(qubit) followed by ...
3 votes
1 answer
104 views

cirq.Ry complains that it needs one argument

When I try to put an Ry gate into my circuit in cirq, I get an error saying that it only takes one argument. ...
  • 28.6k
2 votes
0 answers
145 views

Cirq: Any interesting introductory level example using 2D grid of qubits?

I have already asked this question on reddit.com/r/QuantumComputing. Cirq supports to create quantum circuits composed by qubits having 2D grid structure. We have been preparing educational ...
6 votes
2 answers
939 views

How to prepare a specific initial state of three qubits?

I would like to prepare the following initial state for variational quantum algorithms: $$ \sin\theta_1 \sin\theta_2 \sin\theta_3 |000\rangle + \sin\theta_1 \sin\theta_2 \cos\theta_3 |001\rangle + \...
  • 365
5 votes
3 answers
4k views

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

What is the difference between these frameworks or languages? What are the pros and cons of each of these? Do you know any similar framework/platform/language that gives some more advantages?
0 votes
1 answer
253 views

Is there a function that returns the probability of measuring a particular state in Cirq?

It is possible to use cirq.simulate and then the final_state keyword to get the final wavefunction of the circuit, however, the ...
0 votes
1 answer
237 views

How to do a $C-PH$ gate in google cirq

I know that I can just use the $RZ$ gate to replace the $PH$ phase gate. But I need a way to implement the controlled phase gate $C-PH$ this cannot just be replaced with a $CRZ$ gate.
4 votes
1 answer
84 views

Estimate run time of Cirq circuit on forthcoming Google quantum computer

Calling cirq.Simulator().run(..) on your circuit to get an idea of how it'd behave if you were to run on Google's (apparently) forthcoming real hardware is fine and dandy. Is there a way to estimate ...
3 votes
0 answers
170 views

Quantum Optimization via Quantum Label Classification in Quantum Circuits

I have been reading Farhi and Neven's paper on quantum neural networks on quantum circuits. I also found an example - albeit not ideal as pointed out by a couple of users - thank you - in here. ...
3 votes
2 answers
745 views

GridQubit in Cirq vs LineQubit

It's perhaps a very silly question, but in what ways is it advantageous to use GridQubit vs LineQubits to develop quantum circuits? Specially to develop ansatz ? Are GridQubits Cirq's way of ...
4 votes
1 answer
329 views

How to implement NM Algorithm for Variational Quantum Eigensolver?

First of all: thanks for reading again. I appreciate the feedback I have gotten from this community the past weeks as I started to feel ready to ask questions about quantum computing topics. I am ...
3 votes
0 answers
176 views

Measuring the expected energy of a quantum circuit

I implemented the following circuit: I am interested in measuring the expected energy of the circuit. I am using Cirq. I am wondering what are the next steps. Sorry if the question seems very basic, ...
5 votes
2 answers
663 views

N-Toffoli on Cirq

I am looking for guidance in more generally how to developed n-bit gates in Cirq. I am working on a QNN paper and I need to develop a n-controlled gate to be able to measure the cost function of the ...
1 vote
1 answer
514 views

How do you start a simulation with a random initial state in Cirq?

How do you create a random initial state by modifying the $2^{n}$ vector amplitudes instead of starting every simulation at $|0000...000\rangle$?
4 votes
1 answer
754 views

Creating an ansatz for variational quantum algorithms?

I was recently reading through the tutorial on the Cirq documentation about creating variational quantum algorithms, and I came to the section on ansatz preparation. The way that the ansatz is ...
4 votes
2 answers
446 views

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

I've seen in google cirq that a $X^q$ gate is converted in openqasm to $RX(\pi q)$, why is that? Same for $S^q$ into $RZ(\pi q/2)$.
3 votes
1 answer
1k views

How to add control to gates in Cirq?

My question is very simple. I know there is a method to add a control to previously defined gates. I saw in the API of cirq that there is a command Controlled gate (here). I'm not understanding though ...
  • 523
4 votes
1 answer
1k views

How to set a starting state in cirq?

I'm learning how to use the cirq library. Every time I set up a circuit the starting state of the qubits is $|0000..0\rangle$. Is there any way to make the starting state different? I'm thinking of ...
  • 523