Writing Passes for the MQSS¶
Adding your pass¶
Two types of passes can be added : Dialect-Agnostic and Dialect-specific
The dialect agnostic passes should be added within
lib/common/Passes, whereas, dialect-specific passes should be added withinlib/mqss-catalyst/lib/MQSSCatalystPasses(for catalyst-quantum) andlib/mqss-cudaq/lib/MQSSQuakePasses(for quake).A key step in adding your pass is pass registration. This ensures that the passes can be found by the targets
mqss-cudaq-optand ``````mqss-catalyst-opt```.To register a pass we need to make additions to 2 files
Transforms.handTransforms.td. These files can be found withinlib/mqss-catalyst/include/MQSSCatalystPassesandlib/mqss-cudaq/include/MQSSQuakePasses.Here is an example of pass registration within
lib/mqss-cudaq/include/MQSSQuakePasses/Transforms.td:
def CommonNormalizeArgAnglePass : Pass<"CommonNormalizeArgAnglePass", "mlir::ModuleOp"> { let summary = "Normalize Arg angle of RX, RY, RZ gates. "; let description = [{ Normalize Arg angle of RX, RY, RZ gates. }]; let constructor = "mqss_cudaq::opt::CommonNormalizeArgAnglePass()"; }
The pass is registered for the
mqss-cudaq-opttarget. Since the pass is dialect agnostic, the same pass can be registered for themqss-catalyst-opttarget by changing the namespacemqss_cudaq::opttomqss_catalyst::optwithin the constructor. 3. InTransforms.hwithin themqss_cudaq::optandmqss_catalyst::optnamespaces, the following should be added:std::unique_ptr<mlir::Pass> CommonNormalizeArgAnglePass();