Skip to content

Cleanup non stim

Remove leftover impure non-stim statements after conversion.

After the full squin-to-stim conversion pipeline, some impure non-stim statements survive because DCE only removes pure ops. This pass deletes dead impure statements from an explicit list of expected leftovers and warns if an unexpected impure non-stim statement survives.

RemoveDeadNonStimStatements

RemoveDeadNonStimStatements(keep: DialectGroup)

Bases: RewriteRule


              flowchart TD
              bloqade.stim.passes.cleanup_non_stim.RemoveDeadNonStimStatements[RemoveDeadNonStimStatements]

              

              click bloqade.stim.passes.cleanup_non_stim.RemoveDeadNonStimStatements href "" "bloqade.stim.passes.cleanup_non_stim.RemoveDeadNonStimStatements"
            

Remove dead impure non-stim statements after conversion.

  • Dead impure statements in EXPECTED_IMPURE_DEAD: deleted.
  • Dead impure statements NOT in the list: warned about (likely a missed rewrite).
  • Pure statements are left for DCE to handle.
Source code in .venv/lib/python3.12/site-packages/bloqade/stim/passes/cleanup_non_stim.py
34
35
def __init__(self, keep: ir.DialectGroup):
    self.keep = keep