Skip to content

Add a Human-Readable Diff Helper for Before/After Optimization Passes #28

Description

@amir-hameed-mir

Add a Human-Readable Diff Helper for Before/After Optimization Passes

Labels: good first issue, developer-experience
Estimated effort: ~1–2 hours.

Context

Circuit::gate_counts() and NativeCircuit::gate_counts() already provide
gate-kind statistics, but there is currently no helper that summarizes how an
optimization pass changes a circuit.

Such a utility would make it easier to:

  • Review optimization-related pull requests.
  • Compare circuits before and after optimization.
  • Understand the impact of optimization passes while developing or debugging
    the crate.

Task

Implement a helper that compares the gate counts of two circuits and returns a
human-readable summary of the differences.

For example:

h: 2 -> 2
cx: 4 -> 2   (-2)
rz: 6 -> 3   (-3)

Only gate kinds whose counts changed need to be displayed. Unchanged gate
kinds may either be omitted or shown without a delta—either behavior is
acceptable, provided it is documented.

A suitable location would be:

  • a new diff module,
  • a free helper function in ir_optimize.rs, or
  • a free helper function in optimize.rs.

Choose whichever best fits the existing project structure.

Acceptance Criteria

  • Add a unit test using a small before/after circuit pair that verifies the
    expected diff output.
  • Existing optimizer behavior remains unchanged.
  • This is a purely additive utility; no optimization logic should be modified.
  • Include a short doc comment or documentation explaining whether unchanged
    gate kinds are omitted or displayed.

If You Get Stuck

If you're unsure about the API or where the helper best fits within the crate,
feel free to open a draft pull request or comment on the issue before starting.
We're happy to discuss the design and provide guidance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions