Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix ZX-checker inadvertedly terminating early #382

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

burgholzer
Copy link
Member

Description

While experimenting on some benchmarks, it turned out that, sometimes, the ZX checker would just stop simplification even though further simplifications were possible.
This PR adresses the underlying bug by revamping and simplifying the handling of the stopping criterion during ZX simplification.

A (not necessarily minimal) reproducer for the bug is:

from mqt.bench import CompilerSettings, QiskitSettings, get_benchmark
from mqt.qcec import verify_compilation

alg = "ae"
num_qubits = 7

# construct the first circuit
qc1 = get_benchmark(alg, circuit_size=num_qubits, level="alg")

# construct the second circuit
optimization_level = 2
settings = CompilerSettings(qiskit=QiskitSettings(optimization_level=2))
qc2 = get_benchmark(alg, circuit_size=num_qubits, level="nativegates", compiler_settings=settings)

    # verify the compilation only using the ZX checker
result2 = verify_compilation(
    qc1,
    qc2,
    optimization_level=optimization_level,
    run_alternating_checker=False,
    run_zx_checker=True,
    run_simulation_checker=False,
)
print(f"ZX-Checker \t|\t {result2.considered_equivalent()} \t|\t {result2.check_time}")

Checklist:

  • The pull request only contains commits that are related to it.
  • I have added appropriate tests and documentation.
  • I have made sure that all CI jobs on GitHub pass.
  • The pull request introduces no new warnings and follows the project's style guidelines.

Sometimes, the ZX checker would just stop simplification even though further simplifications were possible.

Signed-off-by: burgholzer <burgholzer@me.com>
@burgholzer burgholzer self-assigned this Apr 10, 2024
@burgholzer burgholzer added c++ Anything related to C++ code fix Anything related to bugfixes labels Apr 10, 2024
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.4%. Comparing base (e45f80f) to head (d6c6c46).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #382     +/-   ##
=======================================
- Coverage   96.4%   96.4%   -0.1%     
=======================================
  Files         34      34             
  Lines       1765    1759      -6     
  Branches     218     222      +4     
=======================================
- Hits        1703    1697      -6     
  Misses        62      62             
Flag Coverage Δ
cpp 96.2% <100.0%> (-0.1%) ⬇️
python 97.2% <ø> (ø)
Files Coverage Δ
include/checker/zx/ZXChecker.hpp 100.0% <100.0%> (ø)
src/checker/zx/ZXChecker.cpp 100.0% <100.0%> (+0.6%) ⬆️

... and 2 files with indirect coverage changes

@burgholzer burgholzer enabled auto-merge (squash) April 10, 2024 17:32
@burgholzer burgholzer merged commit 7bcf851 into main Apr 10, 2024
37 checks passed
@burgholzer burgholzer deleted the fix-early-termination-of-zx-checker branch April 10, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Anything related to C++ code fix Anything related to bugfixes
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant