tket2 icon indicating copy to clipboard operation
tket2 copied to clipboard

RuntimeError: Can only build replacement circuits for basic gates: QControlBox

Open ACE07-Sev opened this issue 1 year ago • 3 comments

Greetings there,

Hope you are well. I am trying to add tket2 to my library, and noticed that it doesn't support QControlBox. May I know when this would be added?

ACE07-Sev avatar Sep 04 '24 16:09 ACE07-Sev

For the moment, I found that by setting rebase=False resolves the issue.

ACE07-Sev avatar Sep 08 '24 08:09 ACE07-Sev

Hello, could you say a bit more about how you were using tket2, which function were you calling?

ss2165 avatar Sep 25 '24 09:09 ss2165

Greetings there,

Hope you are well. Gosh, I'm really embarrassed, I actually forgot to add the reproduction code. Really sorry about that. I believe I was running this:

from pytket import Circuit, OpType
from pytket.circuit import Op, QControlBox
from tket2.circuit import Tk2Circuit, render_circuit_mermaid
from tket2.passes import badger_pass


setattr(
    Tk2Circuit,
    "_repr_markdown_",
    lambda self: f"```mermaid\n{render_circuit_mermaid(self)}\n```"
)

c = Circuit(3)
CX = QControlBox(Op.create(OpType.X), 1)
c.add_qcontrolbox(CX, [0, 1])

badger_pass(rebase=False).apply(c)

But now I'm getting a new error (which I wasn't getting before):

thread '<unnamed>' panicked at tket2-py/src/optimiser.rs:32:73:
called `Result::unwrap()` on an `Err` value: Deserialisation(Syntax("unknown variant `CustomOp`, expected one of `Module`, `FuncDefn`, `FuncDecl`, `AliasDecl`, `AliasDefn`, `Const`, `Input`, `Output`, `Call`, `CallIndirect`, `LoadConstant`, `LoadFunction`, `DFG`, `Extension`, `Tag`, `DataflowBlock`, `ExitBlock`, `TailLoop`, `CFG`, `Conditional`, `Case`"))

ACE07-Sev avatar Sep 26 '24 10:09 ACE07-Sev

Fixed after updating to 0.4.1.

ACE07-Sev avatar Oct 28 '24 16:10 ACE07-Sev