qibolab.compilers package#


qibolab.compilers.compiler module#

class qibolab.compilers.compiler.Compiler(rules: dict = <factory>)[source]#

Bases: object

Compiler that transforms a qibo.models.Circuit to a qibolab.pulses.PulseSequence.

The transformation is done using a dictionary of rules which map each Qibo gate to a pulse sequence and some virtual Z-phases.

A rule is a function that takes two argumens:
  • gate (qibo.gates.abstract.Gate): Gate object to be compiled.

  • platform (qibolab.platforms.abstract.AbstractPlatform): Platform object to read

    native gate pulses from.

and returns:
  • sequence (qibolab.pulses.PulseSequence): Sequence of pulses that implement

    the given gate.

  • virtual_z_phases (dict): Dictionary mapping qubits to virtual Z-phases induced by the gate.

See qibolab.compilers.default for an example of a compiler implementation.

rules: dict#

Map from gates to compilation rules.

classmethod default()[source]#

Decorator for registering a function as a rule in the compiler.

Using this decorator is optional. Alternatively the user can set the rules directly via __setitem__.


gate_cls – Qibo gate object that the rule will be assigned to.

compile(circuit, platform)[source]#

Transforms a circuit to pulse sequence.

  • circuit (qibo.models.Circuit) – Qibo circuit that respects the platform’s connectivity and native gates.

  • platform (qibolab.platforms.abstract.AbstractPlatform) – Platform used to load the native pulse representations.


Pulse sequence that implements the circuit. measurement_map (dict): Map from each measurement gate to the sequence of readout pulse implementing it.

Return type:

sequence (qibolab.pulses.PulseSequence)

qibolab.compilers.default module#

Implementation of the default compiler.

Uses I, Z, RZ, U3, CZ, and M as the set of native gates.

qibolab.compilers.default.identity_rule(gate, platform)[source]#

Identity gate skipped.

qibolab.compilers.default.z_rule(gate, platform)[source]#

Z gate applied virtually.

qibolab.compilers.default.rz_rule(gate, platform)[source]#

RZ gate applied virtually.

qibolab.compilers.default.gpi2_rule(gate, platform)[source]#

Rule for GPI2.

qibolab.compilers.default.u3_rule(gate, platform)[source]#

U3 applied as RZ-RX90-RZ-RX90-RZ.

qibolab.compilers.default.cz_rule(gate, platform)[source]#

CZ applied as defined in the platform runcard.

Applying the CZ gate may involve sending pulses on qubits that the gate is not directly acting on.

qibolab.compilers.default.cnot_rule(gate, platform)[source]#

CNOT applied as defined in the platform runcard.

qibolab.compilers.default.measurement_rule(gate, platform)[source]#

Measurement gate applied using the platform readout pulse.