2 min read

Cirq is a Python library for writing quantum circuits and running them against quantum computers created by Google. Cirq 0.4.0 is now released and is available on GitHub.

Changes in Cirq 0.4.0 themes

The API is now more pythonic and more consistent with respect to breaking changes and refactoring. The simulation is faster.

New functionality in Cirq 0.4.0

The following functions, parameters are added.

  • cirq.Rx, cirq.Ry, and cirq.Rz
  • cirq.XX, cirq.YY, cirq.ZZ, and cirq.MS related to the Mølmer–Sørensen gate
  • cirq.Simulator
  • cirq.SupportsApplyUnitary protocol is added to specify fast simulation methods
  • cirq.Circuit.reachable_frontier_from and cirq.Circuit.findall_operations_between
  • cirq.decompose
  • sorted(qubits) and cirq.QubitOrder.DEFAULT.order_for(qubits) are now equivalent
  • cirq.experiments.generate_supremacy_circuit_[…]
  • dtype parameters are added to control the precision versus speed of simulations
  • cirq.TrialResult helper methods (dirac_notation / bloch_vector / density_matrix)
  • cirq.TOFFOLI and cirq.CCZ can be raised to powers

Breaking changes in Cirq 0.4.0

  • Most of the gate classes have been standardized. They can now take an exponent argument and have a name which is of the form NamePowGate. For example, RotXGate is now XPowGate and it no longer takes rads, degs, or half_turns.
  • The xmon gate set has now been merged into the common gate set.
  • The capability marker classes have been replaced by magic method protocols. As an example, gates now just implement a _unitary_ method as opposed to inheriting from KnownMatrix.
  • cirq.Extensions and cirq.PotentialImplementation are removed.
  • Many decomposition classes and methods have been moved from cirq.google.* to cirq.*. Example: cirq.google.EjectFullW is now cirq.EjectPhasedPaulis.
  • The classes and methods related to line placement are moved into cirq.google.

Notable bug fixes

  • A two-qubit gate decomposition will no longer produce a glut of single qubit gates.
  • When multi-line entries are given, circuit diagrams stay aligned. They now include “same moment” indicators.
  • The false-positives and false-negatives are fixed in cirq.testing.assert_circuits_with_terminal_measurements_are_equivalent.
  • Many repr methods returning code are fixed that assumed from cirq import * instead of import cirq.
  • Example code now runs in both Python 2 and Python 3 without the need for transpilation.

Notable dev changes

  • The test files now import cirq instead of just specific modules.
  • There is better testing and packaging of scripts.
  • The package versions for Python 2 and Python 3 are no longer different.
  • cirq.value_equality decorator is added.
  • New cirq.testing methods and classes are added.

Additions to contrib

  • cirq.contrib.acquaintance: New utilities for defining permutation gates
  • cirq.contrib.paulistring: Utilities for optimizing non-Clifford operations which are separated by Clifford operations
  • cirq.contrib.tpu: Utilities for converting circuits into an executable form to be used on cloud TPUs. This requires TensorFlow.

Read next

Google AdaNet, a TensorFlow-based AutoML framework

Graph Nets – DeepMind’s library for graph networks in Tensorflow and Sonnet

A new Model optimization Toolkit for TensorFlow can make models 3x faster


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

* indicates required