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
2 answers
494 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 ...
0 votes
0 answers
17 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
239 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 ...
1 vote
1 answer
53 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 ...
3 votes
1 answer
190 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
65 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
37 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
50 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
58 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
38 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
19 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
93 views

Question about Controlled Modulo Quantum Gate

How does the Ux(x, N) function implements Ux|y> -> |xy mod N> ? ...
1 vote
0 answers
34 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
88 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
118 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
34 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
50 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
101 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
77 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
60 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 ...
1 vote
1 answer
56 views

How can I define two distinct sets of qubits? (Cirq)

I am trying to familiarise myself with Cirq, and I came across something I don't know how to code. I would like to define two sets of qubits as follows: say the number of qubits in set 1 and 2 are ...
0 votes
1 answer
57 views

type object 'Circuit' has no attribute 'from_ops'

I am working on a Cirq notebook and the quantum circuit is created in this way: ...
1 vote
1 answer
54 views

cirq_google library in Python

I am trying to use the cirq_google library in Python but I receive an error: ...
2 votes
0 answers
91 views

How to define a Clifford Gate while given a tableau in Google Cirq?

I would like to uniformly sample from the group of random Clifford gates. I am aware of the paper https://arxiv.org/abs/2003.09412 where they have designed the algorithm to do this task and even ...
3 votes
1 answer
76 views

How to Properly Cite Amazon Braket?

This is a fairly basic question, but how does one cite Braket in BibTeX style? A similar question was asked for Cirq in How to cite cirq in a scientific article? but I am unable to find a similar page ...
0 votes
0 answers
15 views

Understanding how control parameter inputs work in tfq.layers.ControlledPQC

In the documentation of tfq.layers.ControlledPQC, the authors provide model_params as one of the argument to the ControlledPQC object ...
3 votes
1 answer
83 views

Cirq error models

I have two questions about error channels used in Cirq to model noise quantum circuits. The first one is that for the deplorizing error model, one common setting is to set larger error rates for two-...
1 vote
1 answer
163 views

Writing a Phase Estimation function in Cirq

I am trying to write a phase estimation algorithm using Cirq. The algorithm works for different inputs but I receive a few errors in the estimate_phi(mystery) function. ...
1 vote
1 answer
42 views

ValueError: Operation doesn't satisfy the given `keep` but can't be decomposed

I was going through Cirq tutorial on Shor's algorithm and was able to implement it successfully using cirq. But it takes forever to run for any n > 21; so I ...
1 vote
1 answer
89 views

Bit Flip, Separable state and Several Question about Cirq

1)I want to use noise model for my state and bit_flip is not defined on cirq. ...
2 votes
0 answers
113 views

How to convert a dataset of different values in [0,1000] to quantum data for training a model using Tensorflow QuantumHaving?

...
1 vote
1 answer
56 views

Implementation of .run() methods in google Cirq

I am developing a sampling algorithm using Fourier analysis of Boolean functions for which I use Google's Cirq to obtain the state vector with .simulate(). I wanted to know what sampling algorithm ...
3 votes
1 answer
165 views

How to use Cirq to transpile circuit to custom native gate set?

I am trying to use Cirq to compile arbitrary quantum circuits to custom native gate sets, e.g., to use the Cirq compiler to generate quantum circuits for different quantum computers (IBM, Rigetti, ...
2 votes
1 answer
63 views

What does PhISwap gate mean in Cirq?

I am currently using the Cirq pakage and when drawing the circuit structure, I constantly encountered the PhISwap gate, like in here. What does this gate mean?
2 votes
0 answers
69 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 ...
2 votes
1 answer
59 views

Wrong expected value from cirq PauliString

I have to compute the exact expectation value from a state vector obtained after running a circuit. While I was running my code, I found different weird outcome so I decided to create few tests and I ...
2 votes
1 answer
131 views

Find and replace gate

I have a collection of circuits with cirq that use CNOT(q1, q2). I would like to be able to find and replace all the instance of this gate in the circuit collection and replace them with a composite ...
1 vote
0 answers
32 views

Cirq: How to change `atol` in `validate_density_matrix` when using `DensityMatrixSimulator`

I have a code that essentially looks like this ...
2 votes
1 answer
759 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.
5 votes
2 answers
603 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
89 views

Openfermion state transformation from Bravyi-Kitaev basis to occupation number

I'm working in the Bravyi-Kitaev basis implemented by the openfermion.bravyi_kitaev() function to find the ground state of a fermionic operator in the BK ...
1 vote
1 answer
254 views

Is there a quantum circuit builder package that allows you to import/export a circuit as a JSON?

I've done a superficial search in each of the qiskit, cirq, and braket open source repositories for such a feature, but can't find any explicit examples of this functionality. I'm wondering if anyone ...
7 votes
3 answers
248 views

How to learn parameters in a quantum circuit, given an interference pattern?

Using cirq, I have the following quantum circuit, with three parameters: phi, alpha and beta: ...
0 votes
1 answer
115 views

Random circuits with google cirq

For my dissertation I need to simulate random circuits and I have been trying to use google Cirq for that. Looking at the documentation I have seen how to create my own circuit and simulate it, but it ...
1 vote
3 answers
2k views

Which quantum computing frame is suitable for optimization problems?

As in the computer world, not all programming languages are suitable for everything. Php = Backend Javascript = Frontend Data Analsys/ML = Python embedded systems = C Mobilphone/apps = Android / Swift ...
1 vote
1 answer
75 views

Decomposition of the multi-controlled gate in tensorflow quantum

In TensorFlow Quantum 0.5.0, the support for Cirq gates that have arbitrary control via the gate.controlled_by function is added. I would like to know which kind of ...
2 votes
0 answers
70 views

Does anyone know how to use TF Quantum with real hardware data?

I'm currently trying to embed a tensorflow model for denoising measurements as a tensorflow quantum model, and at some point I'd like for this to be able to run on hardware. After reading through all ...
5 votes
0 answers
723 views

In Cirq, how do you display circuit diagrams that are "prettier" than the ones displayed by default?

This is a duplicate of a question that was asked on the Cirq issues page. I'm duplicating this question to increase it's visibility. The standard way to print circuits in Cirq is by calling ...
1 vote
1 answer
121 views

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

I am trying to understand the code below but can not find any references other than the code itself. https://github.com/quantumlib/Cirq/blob/v0.11.1/cirq-core/cirq/ops/eigen_gate.py I am not clear ...
1 vote
0 answers
83 views

Quantum Circuits for Time-Series Data

I am currently working with a dataset with autocorrelated features, i.e, x(t) affects the value of x(t+1) which affects the value of x(t+2). Suppose this is the circuit representing x(t): Does ...