qgym.generators.circuit module

This module contains circuit generators for Scheduling.

class qgym.generators.circuit.BasicCircuitGenerator(seed=None)[source]

Bases: CircuitGenerator

BasicCircuitGenerator is a basic random circuit generation implementation.

__init__(seed=None)[source]

Init of the BasicInteractionGenerator.

Parameters:

seed (Generator | SupportsInt | None) – Seed to use.

__next__()[source]

Create a new randomly generated circuit.

The length of the circuit is a random integer in the interval [n_qubits, max_length].

Return type:

list[Gate]

__repr__()[source]

String representation of the BasicCircuitGenerator.

Return type:

str

set_state_attributes(machine_properties=None, max_gates=0, **kwargs)[source]

Set the n_qubits and max_gates attributes.

Parameters:
  • machine_properties (Any) – MachineProperties containing at least the number of qubits of the machine.

  • max_gates (SupportsInt) – Maximum number of gates allowed in the circuit.

  • kwargs (Any) – Additional keyword arguments. These are not used.

Return type:

None

class qgym.generators.circuit.CircuitGenerator[source]

Bases: Iterator[List[Gate]]

Abstract Base Class for circuit generation used for scheduling.

All interaction circuit generators should inherit from CircuitGenerator to be compatible with the Scheduling environment.

abstract __next__()[source]

Make a new circuit.

The __next__ method of a CircuitGenerator should generate a list of Gates.

Return type:

list[Gate]

Example circuit:
>>> circuit = [Gate("prep", 0,0), Gate("prep", 1,1), Gate("cnot", 0,1)]
finite: bool

Boolean value stating whether the generator is finite.

abstract set_state_attributes(**kwargs)[source]

Set attributes that the state can receive.

This method is called inside the scheduling environment to receive information about the state. The same keywords as for the the init of the SchedulingState are provided.

Return type:

None

class qgym.generators.circuit.NullCircuitGenerator[source]

Bases: CircuitGenerator

Generator class for generating empty circuits.

Useful for unit testing.

__init__()[source]

Init of the NullCircuitGenerator

__next__()[source]

Create a new empty circuit.

Return type:

list[Gate]

__repr__()[source]

String representation of the NullCircuitGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Receive state attributes, but do nothing with it.

Parameters:

kwargs (dict[str, Any]) – Keyword arguments.

Return type:

None

class qgym.generators.circuit.WorkshopCircuitGenerator(seed=None)[source]

Bases: CircuitGenerator

WorkshopCircuitGenerator is a simplified random circuit generation implementation.

__init__(seed=None)[source]

Init of the WorkshopCircuitGenerator.

Parameters:

seed (Generator | SupportsInt | None) – Seed to use.

__next__()[source]

Create a new randomly generated circuit.

The length of the circuit is a random integer in the interval [n_qubits, max_length].

Return type:

list[Gate]

__repr__()[source]

String representation of the WorkshopCircuitGenerator.

Return type:

str

set_state_attributes(**kwargs)[source]

Set the- n_qubits and max_gates attributes.

Parameters:

kwargs (dict[str, Any]) – Keyword arguments. Must have the keys "machine_properties" and "max_gates" with values of type MachineProperties and integerlike (SupportsInt) respectively.

Return type:

None