Custom
Custom Drive Shaper config
Section titled “Custom Drive Shaper config”If one desires to develop his own drive shaping method, a subclass of qubosolver.pipeline.drive.BaseDriveShaper should be implemented with a mandatory generate method.
The generate method syntax is generate(register: Register, instance: QUBOInstance) -> tuple[Drive, QUBOSolution]
with arguments:
- a
Registerinstance specifying the qubits we work with. - a
QUBOInstancespecifying the qubo problem we target.
It returns:
- an instance of
qoolqit.Drive - a
QUBOSolutionspecyfing the solution that may be used by a solver.
For concrete examples, we have the HeuristicDriveShaper and the OptimizedDriveShaper and their current implementations lie in qubosolver.pipeline.drive.py.
Let us show an example of a custom simple hard-coded drive shaper.
from qoolqit import Drive, Constant, Ramp, Registerfrom qubosolver.pipeline.drive import BaseDriveShaperfrom qubosolver.data import QUBOSolutionfrom qubosolver.config import ( DriveShapingConfig, SolverConfig,)
class SimpleShaper(BaseDriveShaper): def generate( self, register: Register, ) -> tuple[Drive, QUBOSolution]:
# Defining the drive parameters omega = 2.0 delta_i = -4.0 * omega delta_f = -delta_i T = 200.0
# Defining the drive wf_amp = Constant(T, omega) wf_det = Ramp(T, delta_i, delta_f) drive = Drive(amplitude=wf_amp, detuning=wf_det)
return drive, QUBOSolution(torch.Tensor(), torch.Tensor())
config = SolverConfig( use_quantum=True, drive_shaping=DriveShapingConfig(drive_shaping_method=SimpleShaper),)