Circuit identity generation

Submodule to generate and store a database of circuit identities involving up to three successive \(GPI\) and \(GPI2\) gates.

This module is primarily for internal use. It exposes only functions to query the database for an identity involving a specified gate sequence. The database is included as a set of pickle files with the package.

ionizer.identity_hunter.lookup_gate_identity(gates)

Given a sequence of two or three single-qubit gates, query a database of known circuit identities for a shorter implementation.

Parameters:

gates (List[Operation]) – A list of two or three GPI and/or GPI2 operations. These should be ordered as they appear in the circuit diagram.

Returns:

If an equivalent but shorter sequence of GPI and GPI2 gates is found in the identity database, this will be returned. If no equivalent sequence is found, the empty list is returned.

Return type:

List[Operation]

Example

>>> gate_list = [GPI(np.pi / 4, wires=0), GPI2(-3 * np.pi / 4)]
>>> lookup_gate_identity(gate_list)
[GPI2(0.7853981633974483, wires=[0])]
ionizer.identity_hunter.search_and_apply_three_gate_identities(gates_to_apply)

Try to simplify a sequence of three gates.

Sequences that are found are queued to the current context; if no identity is found, we simply queue the provided sequence of gates.

Parameters:

gates_to_apply (List[pennylane.Operation]) – A sequence of three gates we would like to simplify.

Returns:

The simplified or alternate gate sequence that will be applied within the transform.

Return type:

List[pennylane.Operation]

ionizer.identity_hunter.search_and_apply_two_gate_identities(gates_to_apply)

Try to simplify a sequence of two gates.

Sequences that are found are queued to the current context; if no identity is found, we simply queue the provided sequence of gates.

Parameters:

gates_to_apply (List[pennylane.Operation]) – A sequence of two gates we would like to simplify.

Returns:

The simplified or alternate gate sequence that will be applied within the transform.

Return type:

List[pennylane.Operation]