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

Invalid circuit produced during TASO optimisation #200

Closed
aborgna-q opened this issue Oct 25, 2023 · 4 comments
Closed

Invalid circuit produced during TASO optimisation #200

aborgna-q opened this issue Oct 25, 2023 · 4 comments
Assignees
Labels
badger-optimiser TASO optimization bug Something isn't working

Comments

@aborgna-q
Copy link
Collaborator

The following script panics mid-optimisation. It seems an invalid circuit gets produced somewhere during the TASO run.

from pytket.qasm.qasm import circuit_from_qasm
from pytket.passes import PauliSquash
from pyrs.pyrs import optimiser

def compile(circ):
    print(f"Compiling optimiser")
    opt = optimiser.TasoOptimiser.load_precompiled("nam_6_3.rwr")

    PauliSquash().apply(circ)
    return opt.optimise(circ, 30, log_progress="/tmp/progress.log")

if __name__ == "__main__":
    circ = circuit_from_qasm("failing.qasm")
    compile(circ)

Failing circ:

failing.qasm.tar.gz

@aborgna-q aborgna-q added bug Something isn't working P-critical badger-optimiser TASO optimization labels Oct 25, 2023
@aborgna-q aborgna-q self-assigned this Oct 25, 2023
@aborgna-q
Copy link
Collaborator Author

Update:
This circuit fails to validate after the first rewrite without the PauliSquash step.

OPENQASM 2.0;
include "qelib1.inc";

qreg q[3];
cx q[2],q[0];
cx q[1],q[0];
u3(0.5*pi,0.0*pi,0.5*pi) q[2];

Error:

Edge mismatch: Extensions at source node Node(11) ([IdentList("prelude")]) exceed those at target Node(12) ([])

original-circuit

post-rewrite circuit

@aborgna-q
Copy link
Collaborator Author

aborgna-q commented Nov 6, 2023

Reproducible test case in here: https://github.com/CQCL/tket2/blob/debug/validation-fail-example/examples/failing_validation.rs

Checkout the debug/validation-fail-example branch and run
cargo run --example failing_validation

@croyzor
Copy link
Contributor

croyzor commented Nov 13, 2023

The test case seems to be working now after recent changes to extension inference! I rebased on the current head of tket2 (d8a7bd5) and running the example gives no such error! I've pushed the rebase to the debug/validation-fail-example branch

@aborgna-q
Copy link
Collaborator Author

Seems to be fixed 👍
(It'd be nice to know how :P )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
badger-optimiser TASO optimization bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants