CQCL / tket2

Version 2 of the TKET quantum compiler
http://crates.io/crates/tket2
Apache License 2.0
26 stars 6 forks source link

Rewrite `to_halfturns` with unsafe (infallible) op #630

Open aborgna-q opened 6 days ago

aborgna-q commented 6 days ago

This may be required to extract pytket circuits from hugrs with float/rotation parameter manipulation.

We should be able to match on the to_halfturns op followed by a conditional to unwrap or panic emitted by guppy. The general case is harder, as it may require type changing rewrites (as the Option<float> may be passed around).

The alternative to this is to track option<float> as parameters in the pytket encoder, and have a constant folding that interprets panics as undefined behaviour (so the failing branch can be ignored).

doug-q commented 5 days ago

We should add to_halfturns_unsafe or similar which does the panic for you.