Skip to main content
IBM Quantum Platform
This page is from the dev version of Qiskit SDK. Go to the stable version.

CommutativeCancellation

class qiskit.transpiler.passes.CommutativeCancellation(*args, **kwargs)

GitHub

Bases: TransformationPass

Cancel the redundant (self-adjoint) gates through commutation relations.

Pass for cancelling self-inverse gates/rotations. The cancellation utilizes the commutation relations in the circuit. Gates considered include:

H, X, Y, Z, CX, CY, CZ

This pass is multithreaded and will potentially launch a thread pool with threads equal to the number of CPUs by default. You can tune the number of threads with the RAYON_NUM_THREADS environment variable. For example, setting RAYON_NUM_THREADS=4 would limit the thread pool to 4 threads.

CommutativeCancellation initializer.

Parameters

  • basis_gates (list[str]) – Basis gates to consider, e.g. ['u3', 'cx']. For the effects of this pass, the basis is the set intersection between the basis_gates parameter and the gates in the dag.
  • target (Target) – The Target representing the target backend, if both basis_gates and target are specified then this argument will take precedence and basis_gates will be ignored.
  • approximation_degree – The threshold used in the average gate fidelity computation to decide whether pairs of gates can be considered as canceling or commuting. A floating point value between 0 and 1, where 1.0 means no approximation (default).

Attributes

is_analysis_pass

Check if the pass is an analysis pass.

If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.

is_transformation_pass

Check if the pass is a transformation pass.

If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).


Methods

execute

execute(passmanager_ir, state, callback=None)

GitHub

Execute optimization task for input Qiskit IR.

Parameters

Returns

Optimized Qiskit IR and state of the workflow.

Return type

tuple[DAGCircuit, PassManagerState]

name

name()

GitHub

Name of the pass.

Return type

str

run

run(dag)

GitHub

Run the CommutativeCancellation pass on dag.

Parameters

dag (DAGCircuit) – the DAG to be optimized.

Returns

the optimized DAG.

Return type

DAGCircuit

update_status

update_status(state, run_state)

GitHub

Update workflow status.

Parameters

  • state (PassManagerState) – Pass manager state to update.
  • run_state (RunState) – Completion status of current task.

Returns

Updated pass manager state.

Return type

PassManagerState

Was this page helpful?
Report a bug, typo, or request content on GitHub.