Cirq | python framework
kandi X-RAY | Cirq Summary
kandi X-RAY | Cirq Summary
A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Perform a t2decay calculation .
- Calculates the gate product for the given base gate .
- Deserialize a Gow gate operation .
- Returns the reachable from the start_frontier to the vertex .
- Translates a circuit to an optimized circuit .
- This method is used for testing only
- add a custom quantizer service
- Decompose cphase gate into two scales .
- Performs a cross - entropy benchmark .
- Attempts to find a direct fidelity interval for the given circuit .
Cirq Key Features
Cirq Examples and Code Snippets
from qubitrbm.qaoa import QAOA
G = nx.random_regular_graph(3, 16, seed=123)
qaoa = QAOA(G, p=1)
gamma, beta = np.random.rand(2)
psi = qaoa.simulate(gamma, beta).final_state_vector
samples = qaoa.sample(gamma, beta, n_samples=100)
angles, costs =
@INPROCEEDINGS{quantify2020,
author={O. {Oumarou} and A. {Paler} and R. {Basmadjian}},
booktitle={2020 IEEE Computer Society Annual Symposium on VLSI (ISVLSI)},
title={QUANTIFY: A Framework for Resource Analysis and Design Verification of Quan
@article{paler2019opensurgery,
title={OpenSurgery for Topological Assemblies},
author={Paler, Alexandru and Fowler, Austin G},
journal={arXiv preprint arXiv:1906.07994},
year={2019}
}
Community Discussions
Trending Discussions on Cirq
QUESTION
I just started using python cirq library and I came across the following line of code in the tutorial:
...ANSWER
Answered 2021-Apr-05 at 16:28First, you need to find what the type of cirq.X(q0)
is:
QUESTION
I am running some examples and tests on TensorFlow Quantum (TFQ) and I am struggling to perform a multi-class classification. I will used the MNIST classification example as base (https://www.tensorflow.org/quantum/tutorials/mnist), since this is where I am starting from too.
For binary classification I played with the different examples of classes and different gates combination, and the classification result is obtained by measuring a single readout qubit (qR)result, thus if qR=0 we classify with class 0 and if qR=1 then we have class 1.
I extended it to a multi-class problems, so we have a 4 classes (0,1,2,3). To do this I change the labels of the classes with tf.keras.utils.to_categorical(y_train)
, such that the labels get converted from single values to vectors (0 -> (1,0,0,0); 1-> (0,1,0,0); etc..), use tf.keras.losses.CategoricalHinge()
as loss of the model and create 4 readouts qubits, one for each class (M(qR0, qR1, qR2, qR3) = (0,0,1,0) -> class 2), and this works.
However, this method increases massively the size of the circuit. So what I want to do is to pass to TFQ only 2 readout qubits and use the combined measurement for the 4 classes classification (|00> = 0, |10> = 1, |01> = 2, |11> = 3). Ideally this would allow a 2^n multi-class classification, where n is the number of qubits. In Cirq I can achieved this output by performing a cirq.measure(qR0, qR1, key='measure')
on the two readout qubits. However I am struggling in passing such command to TFQ, since from what I understand it measures only the qubits that end with a single qubit Pauli gate.
So, is there something that I am missing in the functionalities of TFQ that allows such kind of measurements in the training process?
...ANSWER
Answered 2020-Aug-24 at 08:18Starting with this snippet:
QUESTION
I am trying to implement a controlled rotation gate in Cirq/Tensorflow Quantum.
The readthedocs.io at https://cirq.readthedocs.io/en/stable/gates.html states:
"Gates can be converted to a controlled version by using Gate.controlled(). In general, this returns an instance of a ControlledGate. However, for certain special cases where the controlled version of the gate is also a known gate, this returns the instance of that gate. For instance, cirq.X.controlled() returns a cirq.CNOT gate. Operations have similar functionality Operation.controlled_by(), such as cirq.X(q0).controlled_by(q1)."
I have implemented
...ANSWER
Answered 2020-May-21 at 01:59What you have is a completely correct implementation of a controlled X rotation in Cirq. It can be used in simulation and other things like cirq.unitary
without any issues.
TFQ only supports a subset of gates in Cirq. For example a cirq.ControlledGate
can have an arbitrary number of control qubits, which in some cases can make it harder to decompose down to primitive gates that are compatible with NiSQ hardware platforms (This is why cirq.decompose
doesn't do anything to ControlledOperations
). TFQ only supports these primitive style gates , for a full list of the supported gates, you can do:
QUESTION
I am working on Cirq and need to perform certain unitary operations on qubits. For that, I am using the MatrixGate()
function in Cirq. Unlike Qiskit, I could not find any function like decompose or transpile to simplify the Unitary operation into basic U3 and CNOT gates.
For instance, if I want to act the following Unitary Operator,
To do this I use this code in Qiskit. Looking for something equivalent in Cirq.
...ANSWER
Answered 2020-May-17 at 20:53An example of such a method is cirq.two_qubit_matrix_to_operations
. It uses the kak decomposition (cartan decomposition) to determine how to translate a unitary matrix into a series of operations with minimal number of CZ gates.
QUESTION
how to save tensorflow quantum model? I am getting the following when i am trying to save keras model with quantum circuits. I didnt find any support for the same. tensorflow:Layer add_circuit_2 was passed non-serializable keyword arguments tensorflow:Layer add_circuit_2 was passed non-serializable keyword arguments tensorflow:Layer add_circuit_2 was passed non-serializable keyword arguments
...ANSWER
Answered 2020-Mar-15 at 13:55TensorFlow Quantum does not yet implement get_config
and load_config
. We had some difficulty with saving certain Cirq objects, we are working on it.
For now if you want to save models that contain quantum layers you can use the
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Cirq
You can use Cirq like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page