As of May 31, 2023, we have updated our Code of Conduct.

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
1 vote
1 answer
22 views

How to create a multicontrol mcx gate or operation in cirq

In qiskit the method to apply a multi control with more than 2 control qubits is: qc.mct ( listcontrols,targetbit,listancillas, mode=mode[i]) What is the ...
0 votes
1 answer
25 views

AttributeError: module 'cirq_google' has no attribute 'Foxtail'

I have installed cirq in my anaconda environment by using the command: pip install cirq When I ran the code below to print the ...
1 vote
1 answer
60 views

Resolving AWS-Braket - ValidationException: An error occurred (ValidationException) when calling the CreateQuantumTask operation

I have a quantum circuit for the Markovian Reservoir Engineering[MRE] Model, written in cirq (frontend) and trying to run it on Ionq hardware, using qbraid credits. This is all being done on qbraid ...
0 votes
0 answers
23 views

Grover's algorithm for max cut problem - Implementation in cirq

I am using the Grover's algorithm for max cut problem using an oracle for the graph described below to check whether it admits a valid 2-coloring. Here are the edges: (0,3),(0,4),(1,3),(1,4),(2,3),(2,...
0 votes
1 answer
28 views

Marking a specific quantum state in the oracle function in the Grover's algorithm

I have a simple implementation of Grover's algorithm. As depicted in the results, the oracle function marks the state |111>. How can I change the Oracle function to mark |010>? ...
0 votes
0 answers
33 views

Understanding the meaning of [2, 2] for input_register and target_register in a custom Cirq gate

I'm learning a custom gate implementation from google Cirq official tutorial of shor algorithm(https://colab.research.google.com/github/quantumlib/Cirq/blob/master/docs/experiments/shor.ipynb#scrollTo=...
1 vote
1 answer
82 views

In Cirq, how do I separate transpilation from execution in simulator.simulate()?

In Qiskit, there are explicit transpile [1] (where a circuit is transpiled to primitive gates) and backend.run [2] (where the ...
2 votes
1 answer
101 views

Merge two Y**0.5 gate into a single Y gate

How can I merge two consecutive cirq.Y**0.5 gates into a single cirq.Y gate with a transformer? I can use ...
0 votes
0 answers
74 views

tensorflow, tensorflow-quantum, tensorflow-federated latest version compatibility?

I have been working with on some research on tensorflow, tensorflow-quantum and tensorflow-federated and the problem with that is I just can't install those three at my google colab and I tried ...
0 votes
0 answers
26 views

Custom noise models in Cirq

I want to simulate a quantum circuit using Cirq, with a noise model that defines a certain error rate $e_1$ for single-qubit gates and a certain error rate $e_2$ for 2-qubit gates. So I know it's ...
4 votes
1 answer
208 views

How to define a custom gate from a matrix in TKET

I'm currently learning all about different quantum tools such as qiskit, tket, cirq, Forest SDK and so on. I just want to create a circuit that gets executed given a matrix, because a circuit can be ...
1 vote
1 answer
163 views

How we can perform measurements on an X, Y or Z basis in cirq?

How we can perform measurements on an X, Y or Z basis in cirq? Is there any function where we can give the list of qubits and measurement basis as an argument and get the output?
0 votes
0 answers
21 views

Cirq/OpenFermion Trotterization of parametrised FermionOperator?

I am using OpenFermion and Cirq. I would like to define a Hamiltonian with a symbolic parameter and then generate a quantum circuit via Trotterization of its time evolution, which then also contains ...
2 votes
1 answer
48 views

Generalizing a brick-wall circuit acting on qubits to acting on qudits

Recently, I have been creating a "brick layer" circuit of random unitary gates (each acting on 2 qubits) which acts on a n qubit register using cirq. A typical circuit looks like this. (...
1 vote
0 answers
14 views

Two-time correlators in Cirq?

Is there a way to calculate two-time correlators in Cirq directly? For example, suppose we have an initial mixed state described by a density matrix $\rho_0$, and we want to obtain in our quantum ...
1 vote
1 answer
63 views

Efficient simulation of circuit with variable depth using Cirq

I have a program that needs to evaluate several Cirq circuits by using both simulators the Simulator() and ...
0 votes
1 answer
67 views

How to change the qubits of a cirq Circuit?

I am constructing generic circuits, and I would like to change the qubits after creating the circuits. Is there a way in cirq to do so? for instance: ...
2 votes
2 answers
530 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 vote
0 answers
22 views

How to take gradient of the `tfq.layers.State` output?

I am using the following code for building a quantum circuit as a custom tf.keras.layers.Layer: ...
0 votes
0 answers
46 views

Topmost Universal Gate Based Quantum Simulator?

I am Elijah I'm interested in Drug Discovery and Materials Simulation. I want to purchase a gate based Quantum Simulator for research. I received a proposal. Full State Simulator 30 Qubits on Laptop, ...
3 votes
1 answer
72 views

how to flatten a cirq.Circuit with CircuitOperation

I have a cirq.Circuit that uses a CircuitOperation, something like: ...
0 votes
0 answers
39 views

How can i describe Custome Gate Sets in Cirq?

i try to create a Custome GateSet with the CompilationTargetGateset class but it does not work. ...
3 votes
1 answer
295 views

Cirq: n-qubit GHZ state

I am trying to write $n$ party GHZ state but at the end of the day, it seems like bi partite state. I am missing a detail. Here is my code ...
1 vote
1 answer
205 views

Producing $|ghz\rangle\langle ghz|$ State in Cirq

I could manage to produce 3 qubit ghz state in Cirq. But I don't know how I can produce $|GHZ\rangle\langle GHZ|$ in Cirq Here is my code for 3 qubit ghz state Can you help me please for improving my ...
1 vote
0 answers
33 views

Is there a method in pyQuil to create logical boolean gates

is there another way to represent a boolean gate. The straight forward way would be to define a gate my a matrix and then apply this gate to the circuit. What i mean by that? For Example an AND-Gate ...
1 vote
0 answers
32 views

Convert an integer to its basis state in Cirq

I am trying to implement Quantum Adder using QFT in Cirq. I previously did the same problem using Pennylane, in which I converted an integer into its Basis state using the BasisStatePreparation method ...
1 vote
0 answers
88 views

How to rewrite this Cirq problem into Qiskit?

I have a following example problem in Cirq, representing a very simple operator given by $$ \hat{H} = a^\dagger_0a_2 + a_0a^\dagger_1 + 0.9\, a^\dagger_0a_1a^\dagger_2a^\dagger_3 + a^\...
0 votes
0 answers
16 views

Noise model on CircuitOperation

When I use a self-defined NoiseModel to add noise to the circuit in cirq, it treats cirq.CircuitOperation as a single operation ...
2 votes
1 answer
100 views

Use parametrized quantum circuit output amplitudes for training in tensorflow

I am trying to train a quantum neural network in tensorflow_quantum (tfq). Using cirq.Circuit I have set up my circuit. I now need to wrap it in a keras model for ...
1 vote
1 answer
46 views

Two Qudit custom gate error in Cirq

I am trying to build two qudit CX (d-dim) gate. and getting below error. There is no issue in the unitary matrix. Please suggest to resolve the error.
0 votes
1 answer
55 views

Interpretation of Qudit measurement output in cirq

Here [+1] represents X gate for qutrit. How the Counter value is coming to 5? which is the measurement outcome(q0q1q2->102). Even for (q0q1q2->101) also counter value is 5. In total, for this 3 ...
0 votes
1 answer
56 views

Printing Stabilizer State of a circuit using Cirq

How to print the stabilizers for a given circuit using Cirq (just like in Qiskit)? For example, if I have the following cluster state and make a circuit using Cirq. I give the circuit as input, and I ...
0 votes
0 answers
26 views

Why importing cirq_ionq gives an unexpected argument error

I'm trying to install cirq_ionq, a python library for running cirq circuits on IonQ's quantum hardware. However, when I try importing it I get an unexpected argument error: ...
3 votes
1 answer
301 views

is cirq suitable for simulation of quantum error correction?

I experimented with stim and qiskit for QECC simulations. They both have limitations : for example stim has no support for non-clifford operations (qiskit does); qiskit has no support for multiple ...
4 votes
1 answer
239 views

Does TensorFlow Quantum tfq.convert_to_tensor work on custom gates?

I'm trying to use Cirq with TensorFlow Quantum to simulate a variational quantum classifier. There's a tutorial on the TFQ website on building a quantum neural network to classify a simplified version ...
0 votes
1 answer
95 views

$S^2$ expectation value of a circuit seems wrong

I need to rewrite a following circuit from Cirq to Qiskit with $2\varphi = \pi$. It's a circuit representing an initial state for VQE calculation. Considering, that ...
0 votes
1 answer
99 views

CIRQ How to iteratively apply a multi qubit gate to first n qubits

I've got an arbitrary n qubit circuit, with a "for Q in range(n):", which creates a custom gate class that affects (Q+1) qubits, which I want to apply to first (Q+1) qubits of the circuit ...
1 vote
1 answer
142 views

Use simulator.simulate() to obtain probability distribution instead of simulator.run() (cirq)

So far, I have my code set up to find the probability distribution using simulator.run(), and I was wondering if I can use the simulator.simulate() function instead to obtain a probability ...
1 vote
2 answers
121 views

How to measure a qubit and depending on measurement outcome act with a gate (cirq)

Is there a way on cirq that I can make a measurement on a qubit, and depending on the outcome of that measurement act with another gate on that qubit. So, I want to measure a qubit (in the ...
0 votes
0 answers
58 views

Circuit gives unexpected phase factor (cirq)

I implemented the following circuit on cirq: For clarity: the circuit consists of X gates, (controlled) Hadamard gates (H), N-toffoli gates, and reset operations (R). The (1,4) qubit is the one I ...
1 vote
0 answers
23 views

duality quantum computing simulation

I am a starter of this quantum mostly new to quantum computing but I wonder if there is any option of simulating duality quantum computing in qiskit or IBM q or any other alternative way? Duality ...
0 votes
1 answer
111 views

Question about Controlled Modulo Quantum Gate

How does the Ux(x, N) function implements Ux|y> -> |xy mod N> ? ...
1 vote
0 answers
67 views

Amplitude Amplification applied to HHL Algorithm

I’m trying to understand and implement the amplitude amplification algorithm described in the HHL paper. I’m using the cirq implementation of the HHL algorithm as my starting point. I have a couple of ...
0 votes
1 answer
369 views

AttributeError: module 'cirq' has no attribute 'google'

I have just installed Qiskit, Qutip, and Cirq in my Anaconda Enviornment. When I tried to run the test program: ...
3 votes
1 answer
203 views

How to convert Pennylane decompose_hamiltonian to Cirq PauliString?

I have a matrix that I would like to decompose into a Pauli String. Pennylane's qml.utils.decompose_hamiltonian does this and returns a list of coefficients and a list of operations representing the ...
0 votes
0 answers
60 views

unitary matrix of CCZPowGate and CZPowGate

For CCZPowGate , how to derive the unitary matrix of CCZ**t ? and how does it different from that of CZPowGate ?
2 votes
0 answers
77 views

Simulating density matrices in quantum simulators

I would like to load random quantum states sampled from a given density matrix based on its classical probabilities ie based on the definition of the given density matrix: $\rho = \sum_i p_i |\psi _i \...
3 votes
1 answer
127 views

Cirq : Reference for Toffoli decomposition

I was trying to find a reference for the 7 T-gate decomposition of the Toffoli gate given by Cirq. The decomposition originates from the the one used for CCZPowGate as given in the doc string here ...
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 ...
1 vote
1 answer
78 views

Cirq: Getting The Instances (samples) of a Quantum Circuit with Probabilistic Unitaries or Mixtures

The wavefunction simulator in Cirq uses a Monte Carlo approach to simulate a certain subset of quantum noise channels, namely through probabilistic/stochastic application of unitary gates. These are ...