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

Port connect panic in force_order for CallIndirect #2005

Closed
ss2165 opened this issue Mar 19, 2025 · 1 comment · Fixed by #2006
Closed

Port connect panic in force_order for CallIndirect #2005

ss2165 opened this issue Mar 19, 2025 · 1 comment · Fixed by #2006
Assignees

Comments

@ss2165
Copy link
Member

ss2165 commented Mar 19, 2025

Generating guppy (v0.17):

@guppy
def bar(x: int) -> int:
    return x

@guppy
@no_type_check
def foo(f: Callable[[int], int], y: int) -> int:
    return f(y) 

@guppy
@no_type_check
def main() -> None:
    foo(bar, 1)

Error (port number is too high):

---- force_order::test::call_indirect_bug stdout ----

thread 'force_order::test::call_indirect_bug' panicked at hugr-core/src/hugr/hugrmut.rs:372:9:
Received an invalid port Port(Incoming, 3) for node Node(18) while mutating a HUGR:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
   1: core::panicking::panic_fmt
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
   2: hugr_core::hugr::hugrmut::panic_invalid_port
             at /Users/seyon/ng/hugr/hugr-core/src/hugr/hugrmut.rs:627:9
   3: <T as hugr_core::hugr::hugrmut::HugrMut>::connect
             at /Users/seyon/ng/hugr/hugr-core/src/hugr/hugrmut.rs:372:9
   4: hugr_passes::force_order::force_order_by_key
             at ./src/force_order.rs:92:17
   5: hugr_passes::force_order::force_order
             at ./src/force_order.rs:44:5
   6: hugr_passes::force_order::test::call_indirect_bug
             at ./src/force_order.rs:347:9
   7: hugr_passes::force_order::test::call_indirect_bug::{{closure}}
             at ./src/force_order.rs:333:27
   8: core::ops::function::FnOnce::call_once
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/ops/function.rs:250:5
   9: core::ops::function::FnOnce::call_once
             at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/ops/function.rs:250:5

 graph LR
    subgraph 0 ["(0) Module"]
        direction LR
        subgraph 1 ["(1) FuncDefn: #quot;bar#quot;"]
            direction LR
            2["(2) Input"]
            3["(3) Output"]
            subgraph 4 ["(4) CFG"]
                direction LR
                subgraph 5 ["(5) DataflowBlock"]
                    direction LR
                    6["(6) Input"]
                    7["(7) Output"]
                    9["(9) Tag"]
                    6--"0:1<br>int(6)"-->7
                    6-."1:0".->9
                    9--"0:0<br>Unit"-->7
                end
                8["(8) ExitBlock"]
                5-."0:0".->8
            end
            2--"0:0<br>int(6)"-->4
            4--"0:0<br>int(6)"-->3
        end
        subgraph 10 ["(10) FuncDefn: #quot;foo#quot;"]
            direction LR
            11["(11) Input"]
            12["(12) Output"]
            subgraph 13 ["(13) CFG"]
                direction LR
                subgraph 14 ["(14) DataflowBlock"]
                    direction LR
                    15["(15) Input"]
                    16["(16) Output"]
                    18["(18) CallIndirect"]
                    19["(19) Tag"]
                    15--"0:0<br>[int(6)] -> [int(6)]"-->18
                    15--"1:1<br>int(6)"-->18
                    15-."2:0".->19
                    18--"0:1<br>int(6)"-->16
                    19--"0:0<br>Unit"-->16
                end
                17["(17) ExitBlock"]
                14-."0:0".->17
            end
            11--"0:0<br>[int(6)] -> [int(6)]"-->13
            11--"1:1<br>int(6)"-->13
            13--"0:0<br>int(6)"-->12
        end
        subgraph 20 ["(20) FuncDefn: #quot;main#quot;"]
            direction LR
            21["(21) Input"]
            22["(22) Output"]
            subgraph 23 ["(23) CFG"]
                direction LR
                subgraph 24 ["(24) DataflowBlock"]
                    direction LR
                    25["(25) Input"]
                    26["(26) Output"]
                    28["(28) LoadFunction"]
                    29["(29) const:custom:u64(1)"]
                    30["(30) LoadConstant"]
                    31["(31) Call"]
                    32["(32) Tag"]
                    28--"0:0<br>[int(6)] -> [int(6)]"-->31
                    29--"0:0<br>int(6)"-->30
                    30--"0:1<br>int(6)"-->31
                    32--"0:0<br>Unit"-->26
                end
                27["(27) ExitBlock"]
                24-."0:0".->27
            end
            21-."0:0".->23
            23-."0:0".->22
        end
        1--"0:0<br>[int(6)] -> [int(6)]"-->28
        10--"0:2<br>[[int(6)] -> [int(6)], int(6)] -> [int(6)]"-->31
    end
Loading
generated HUGR envelope ``` HUGRiHJv?@{"modules":[{"version":"live","nodes":[{"parent":0,"op":"Module"},{"parent":0,"op":"FuncDefn","name":"bar","signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}}},{"parent":1,"op":"Input","types":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":1,"op":"Output","types":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":1,"op":"CFG","signature":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},{"parent":4,"op":"DataflowBlock","inputs":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"other_outputs":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"sum_rows":[[]],"extension_delta":[]},{"parent":5,"op":"Input","types":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":5,"op":"Output","types":[{"t":"Sum","s":"Unit","size":1},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":4,"op":"ExitBlock","cfg_outputs":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":5,"op":"Tag","tag":0,"variants":[[]]},{"parent":0,"op":"FuncDefn","name":"foo","signature":{"params":[],"body":{"t":"G","input":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}}},{"parent":10,"op":"Input","types":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":10,"op":"Output","types":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":10,"op":"CFG","signature":{"t":"G","input":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},{"parent":13,"op":"DataflowBlock","inputs":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"other_outputs":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"sum_rows":[[]],"extension_delta":[]},{"parent":14,"op":"Input","types":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":14,"op":"Output","types":[{"t":"Sum","s":"Unit","size":1},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":13,"op":"ExitBlock","cfg_outputs":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}]},{"parent":14,"op":"CallIndirect","signature":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},{"parent":14,"op":"Tag","tag":0,"variants":[[]]},{"parent":0,"op":"FuncDefn","name":"main","signature":{"params":[],"body":{"t":"G","input":[],"output":[],"runtime_reqs":[]}}},{"parent":20,"op":"Input","types":[]},{"parent":20,"op":"Output","types":[]},{"parent":20,"op":"CFG","signature":{"t":"G","input":[],"output":[],"runtime_reqs":[]}},{"parent":23,"op":"DataflowBlock","inputs":[],"other_outputs":[],"sum_rows":[[]],"extension_delta":[]},{"parent":24,"op":"Input","types":[]},{"parent":24,"op":"Output","types":[{"t":"Sum","s":"Unit","size":1}]},{"parent":23,"op":"ExitBlock","cfg_outputs":[]},{"parent":24,"op":"LoadFunction","func_sig":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},"type_args":[],"instantiation":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},{"parent":24,"op":"Const","v":{"v":"Extension","extensions":["arithmetic.int.types"],"typ":{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"},"value":{"c":"ConstInt","v":{"log_width":6,"value":1}}}},{"parent":24,"op":"LoadConstant","datatype":{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}},{"parent":24,"op":"Call","func_sig":{"params":[],"body":{"t":"G","input":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},"type_args":[],"instantiation":{"t":"G","input":[{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":[]}},{"parent":24,"op":"Tag","tag":0,"variants":[[]]}],"edges":[[[2,0],[4,0]],[[9,0],[7,0]],[[6,0],[7,1]],[[5,0],[8,0]],[[4,0],[3,0]],[[11,0],[13,0]],[[11,1],[13,1]],[[15,0],[18,0]],[[15,1],[18,1]],[[19,0],[16,0]],[[18,0],[16,1]],[[14,0],[17,0]],[[13,0],[12,0]],[[1,0],[28,0]],[[29,0],[30,0]],[[10,0],[31,2]],[[28,0],[31,0]],[[30,0],[31,1]],[[32,0],[26,0]],[[24,0],[27,0]]],"metadata":[],"encoder":null}],"extensions":[{"version":"0.1.0","name":"tket2.futures","runtime_reqs":[],"types":{"Future":{"extension":"tket2.futures","name":"Future","description":"A value that is computed asynchronously","params":[{"tp":"Type","b":"A"}],"bound":{"b":"Explicit","bound":"A"}}},"values":{},"operations":{"Dup":{"extension":"tket2.futures","name":"Dup","description":"Duplicate a Future. The original Future is consumed and two Futures are returned","misc":{},"signature":{"params":[{"tp":"Type","b":"A"}],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"V","i":0,"b":"A"}}],"bound":"A"}],"output":[{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"V","i":0,"b":"A"}}],"bound":"A"},{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"V","i":0,"b":"A"}}],"bound":"A"}],"runtime_reqs":["tket2.futures"]}},"binary":false,"lower_funcs":[]},"Free":{"extension":"tket2.futures","name":"Free","description":"Consume a future without reading it.","misc":{},"signature":{"params":[{"tp":"Type","b":"A"}],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"V","i":0,"b":"A"}}],"bound":"A"}],"output":[],"runtime_reqs":["tket2.futures"]}},"binary":false,"lower_funcs":[]},"Read":{"extension":"tket2.futures","name":"Read","description":"Read a value from a Future, consuming it","misc":{},"signature":{"params":[{"tp":"Type","b":"A"}],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"V","i":0,"b":"A"}}],"bound":"A"}],"output":[{"t":"V","i":0,"b":"A"}],"runtime_reqs":["tket2.futures"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.2.0","name":"tket2.qsystem","runtime_reqs":["tket2.futures","prelude","arithmetic.float.types"],"types":{},"values":{},"operations":{"LazyMeasure":{"extension":"tket2.qsystem","name":"LazyMeasure","description":"Lazily measure a qubit and lose it.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"Sum","s":"Unit","size":2}}],"bound":"A"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"LazyMeasureReset":{"extension":"tket2.qsystem","name":"LazyMeasureReset","description":"Lazily measure a qubit and reset it to the Z |0> eigenstate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"},{"t":"Opaque","extension":"tket2.futures","id":"Future","args":[{"tya":"Type","ty":{"t":"Sum","s":"Unit","size":2}}],"bound":"A"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"Measure":{"extension":"tket2.qsystem","name":"Measure","description":"Measure a qubit and lose it.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Sum","s":"Unit","size":2}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"MeasureReset":{"extension":"tket2.qsystem","name":"MeasureReset","description":"Measure a qubit and reset it to the Z |0> eigenstate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"},{"t":"Sum","s":"Unit","size":2}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"PhasedX":{"extension":"tket2.qsystem","name":"PhasedX","description":"PhasedX gate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"},{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"QFree":{"extension":"tket2.qsystem","name":"QFree","description":"Free a qubit (lose track of it).","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"Reset":{"extension":"tket2.qsystem","name":"Reset","description":"Reset a qubit to the Z |0> eigenstate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"Rz":{"extension":"tket2.qsystem","name":"Rz","description":"Rotate a qubit around the Z axis. Not physical.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"TryQAlloc":{"extension":"tket2.qsystem","name":"TryQAlloc","description":"Allocate a qubit in the Z |0> eigenstate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[],"output":[{"t":"Sum","s":"General","rows":[[],[{"t":"Q"}]]}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"ZZMax":{"extension":"tket2.qsystem","name":"ZZMax","description":"Maximally entangling ZZ gate.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]},"ZZPhase":{"extension":"tket2.qsystem","name":"ZZPhase","description":"ZZ gate with an angle.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"},{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.qsystem"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.1.0","name":"tket2.qsystem.random","runtime_reqs":["prelude"],"types":{"context":{"extension":"tket2.qsystem.random","name":"context","description":"The linear RNG context type","params":[],"bound":{"b":"Explicit","bound":"A"}}},"values":{},"operations":{"DeleteRNGContext":{"extension":"tket2.qsystem.random","name":"DeleteRNGContext","description":"Discard the given RNG context.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"output":[],"runtime_reqs":["tket2.qsystem.random"]}},"binary":false,"lower_funcs":[]},"NewRNGContext":{"extension":"tket2.qsystem.random","name":"NewRNGContext","description":"Seed the RNG and return a new RNG context. Required before using other RNG ops, can be called only once.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"output":[{"t":"Sum","s":"General","rows":[[],[{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}]]}],"runtime_reqs":["tket2.qsystem.random"]}},"binary":false,"lower_funcs":[]},"RandomFloat":{"extension":"tket2.qsystem.random","name":"RandomFloat","description":"Generate a random floating point value in the range [0,1).","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"output":[{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"},{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"runtime_reqs":["tket2.qsystem.random"]}},"binary":false,"lower_funcs":[]},"RandomInt":{"extension":"tket2.qsystem.random","name":"RandomInt","description":"Generate a random 32-bit unsigned integer.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":5}],"bound":"C"},{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"runtime_reqs":["tket2.qsystem.random"]}},"binary":false,"lower_funcs":[]},"RandomIntBounded":{"extension":"tket2.qsystem.random","name":"RandomIntBounded","description":"Generate a random 32-bit unsigned integer less than `bound`.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"},{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":5}],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":5}],"bound":"C"},{"t":"Opaque","extension":"tket2.qsystem.random","id":"context","args":[],"bound":"A"}],"runtime_reqs":["tket2.qsystem.random"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.2.0","name":"tket2.qsystem.utils","runtime_reqs":["prelude"],"types":{},"values":{},"operations":{"GetCurrentShot":{"extension":"tket2.qsystem.utils","name":"GetCurrentShot","description":"Get current shot number.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[],"output":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"BoundedNat","n":6}],"bound":"C"}],"runtime_reqs":["tket2.qsystem.utils"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.1.1","name":"tket2.quantum","runtime_reqs":[],"types":{},"values":{},"operations":{"CRz":{"extension":"tket2.quantum","name":"CRz","description":"CRz","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"},{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"CX":{"extension":"tket2.quantum","name":"CX","description":"CX","misc":{"commutation":[[0,"Z"],[1,"X"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"CY":{"extension":"tket2.quantum","name":"CY","description":"CY","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"CZ":{"extension":"tket2.quantum","name":"CZ","description":"CZ","misc":{"commutation":[[0,"Z"],[1,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"}],"output":[{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"H":{"extension":"tket2.quantum","name":"H","description":"H","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Measure":{"extension":"tket2.quantum","name":"Measure","description":"Measure","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"},{"t":"Sum","s":"Unit","size":2}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"MeasureFree":{"extension":"tket2.quantum","name":"MeasureFree","description":"MeasureFree","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Sum","s":"Unit","size":2}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"QAlloc":{"extension":"tket2.quantum","name":"QAlloc","description":"QAlloc","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"QFree":{"extension":"tket2.quantum","name":"QFree","description":"QFree","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Reset":{"extension":"tket2.quantum","name":"Reset","description":"Reset","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Rx":{"extension":"tket2.quantum","name":"Rx","description":"Rx","misc":{"commutation":[[0,"X"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Ry":{"extension":"tket2.quantum","name":"Ry","description":"Ry","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Rz":{"extension":"tket2.quantum","name":"Rz","description":"Rz","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"S":{"extension":"tket2.quantum","name":"S","description":"S","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Sdg":{"extension":"tket2.quantum","name":"Sdg","description":"Sdg","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"T":{"extension":"tket2.quantum","name":"T","description":"T","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Tdg":{"extension":"tket2.quantum","name":"Tdg","description":"Tdg","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Toffoli":{"extension":"tket2.quantum","name":"Toffoli","description":"Toffoli","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"},{"t":"Q"},{"t":"Q"}],"output":[{"t":"Q"},{"t":"Q"},{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"TryQAlloc":{"extension":"tket2.quantum","name":"TryQAlloc","description":"TryQAlloc","misc":{"commutation":[]},"signature":{"params":[],"body":{"t":"G","input":[],"output":[{"t":"Sum","s":"General","rows":[[],[{"t":"Q"}]]}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"X":{"extension":"tket2.quantum","name":"X","description":"X","misc":{"commutation":[[0,"X"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Y":{"extension":"tket2.quantum","name":"Y","description":"Y","misc":{"commutation":[[0,"Y"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"Z":{"extension":"tket2.quantum","name":"Z","description":"Z","misc":{"commutation":[[0,"Z"]]},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Q"}],"output":[{"t":"Q"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]},"symbolic_angle":{"extension":"tket2.quantum","name":"symbolic_angle","description":"Store a sympy expression that can be evaluated to an angle.","misc":{},"signature":{"params":[{"tp":"String"}],"body":{"t":"G","input":[],"output":[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"runtime_reqs":["tket2.quantum"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.1.0","name":"tket2.result","runtime_reqs":["arithmetic.int.types","arithmetic.float.types","collections.array"],"types":{},"values":{},"operations":{"result_array_bool":{"extension":"tket2.result","name":"result_array_bool","description":"Report an array of boolean results.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":null}],"body":{"t":"G","input":[{"t":"Opaque","extension":"collections.array","id":"array","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":null}},{"tya":"Type","ty":{"t":"Sum","s":"Unit","size":2}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_array_f64":{"extension":"tket2.result","name":"result_array_f64","description":"Report an array of floating-point results.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":null}],"body":{"t":"G","input":[{"t":"Opaque","extension":"collections.array","id":"array","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":null}},{"tya":"Type","ty":{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_array_int":{"extension":"tket2.result","name":"result_array_int","description":"Report an array of signed integer results.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":null},{"tp":"BoundedNat","bound":7}],"body":{"t":"G","input":[{"t":"Opaque","extension":"collections.array","id":"array","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":null}},{"tya":"Type","ty":{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"Variable","idx":2,"cached_decl":{"tp":"BoundedNat","bound":7}}],"bound":"C"}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_array_uint":{"extension":"tket2.result","name":"result_array_uint","description":"Report an array of unsigned integer results.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":null},{"tp":"BoundedNat","bound":7}],"body":{"t":"G","input":[{"t":"Opaque","extension":"collections.array","id":"array","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":null}},{"tya":"Type","ty":{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"Variable","idx":2,"cached_decl":{"tp":"BoundedNat","bound":7}}],"bound":"C"}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_bool":{"extension":"tket2.result","name":"result_bool","description":"Report a boolean result.","misc":{},"signature":{"params":[{"tp":"String"}],"body":{"t":"G","input":[{"t":"Sum","s":"Unit","size":2}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_f64":{"extension":"tket2.result","name":"result_f64","description":"Report a floating-point result.","misc":{},"signature":{"params":[{"tp":"String"}],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_int":{"extension":"tket2.result","name":"result_int","description":"Report a signed integer result.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":7}],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":7}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]},"result_uint":{"extension":"tket2.result","name":"result_uint","description":"Report an unsigned integer result.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"BoundedNat","bound":7}],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.int.types","id":"int","args":[{"tya":"Variable","idx":1,"cached_decl":{"tp":"BoundedNat","bound":7}}],"bound":"C"}],"output":[],"runtime_reqs":["tket2.result"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.1.0","name":"tket2.rotation","runtime_reqs":[],"types":{"rotation":{"extension":"tket2.rotation","name":"rotation","description":"rotation type expressed as number of half turns","params":[],"bound":{"b":"Explicit","bound":"C"}}},"values":{},"operations":{"from_halfturns":{"extension":"tket2.rotation","name":"from_halfturns","description":"Construct rotation from number of half-turns (would be multiples of PI in radians). Returns None if the float is non-finite.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[{"t":"Sum","s":"General","rows":[[],[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}]]}],"runtime_reqs":["tket2.rotation"]}},"binary":false,"lower_funcs":[]},"from_halfturns_unchecked":{"extension":"tket2.rotation","name":"from_halfturns_unchecked","description":"Construct rotation from number of half-turns (would be multiples of PI in radians). Panics if the float is non-finite.","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"output":[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"runtime_reqs":["tket2.rotation"]}},"binary":false,"lower_funcs":[]},"radd":{"extension":"tket2.rotation","name":"radd","description":"Add two angles together (experimental).","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"},{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"runtime_reqs":["tket2.rotation"]}},"binary":false,"lower_funcs":[]},"to_halfturns":{"extension":"tket2.rotation","name":"to_halfturns","description":"Convert rotation to number of half-turns (would be multiples of PI in radians).","misc":{},"signature":{"params":[],"body":{"t":"G","input":[{"t":"Opaque","extension":"tket2.rotation","id":"rotation","args":[],"bound":"C"}],"output":[{"t":"Opaque","extension":"arithmetic.float.types","id":"float64","args":[],"bound":"C"}],"runtime_reqs":["tket2.rotation"]}},"binary":false,"lower_funcs":[]}}},{"version":"0.1.0","name":"guppylang","runtime_reqs":[],"types":{},"values":{},"operations":{"partial":{"extension":"guppylang","name":"partial","description":"A partial application of a function. Given arguments [*a],[*b],[*c], represents an operation with type `(*c, *a -> *b), *c -> (*a -> *b)`","misc":{},"signature":{"params":[{"tp":"List","param":{"tp":"Type","b":"A"}},{"tp":"List","param":{"tp":"Type","b":"A"}},{"tp":"List","param":{"tp":"Type","b":"A"}}],"body":{"t":"G","input":[{"t":"G","input":[{"t":"R","i":0,"b":"A"},{"t":"R","i":1,"b":"A"}],"output":[{"t":"R","i":2,"b":"A"}],"runtime_reqs":[]},{"t":"R","i":0,"b":"A"}],"output":[{"t":"G","input":[{"t":"R","i":1,"b":"A"}],"output":[{"t":"R","i":2,"b":"A"}],"runtime_reqs":[]}],"runtime_reqs":["guppylang"]}},"binary":false,"lower_funcs":[]},"unsupported":{"extension":"guppylang","name":"unsupported","description":"An unsupported operation stub emitted by Guppy.","misc":{},"signature":{"params":[{"tp":"String"},{"tp":"List","param":{"tp":"Type","b":"A"}},{"tp":"List","param":{"tp":"Type","b":"A"}}],"body":{"t":"G","input":[{"t":"R","i":1,"b":"A"}],"output":[{"t":"R","i":2,"b":"A"}],"runtime_reqs":["guppylang"]}},"binary":false,"lower_funcs":[]}}}]} ```
@ss2165
Copy link
Member Author

ss2165 commented Mar 19, 2025

Failing test in #2006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants