Skip to content

Incorrect order of outputs when decoding circuits with partial output signature #1303

@aborgna-q

Description

@aborgna-q

Test case:

fn circ_discard_first_qubit() -> Circuit {
    let input_t = vec![qb_t(), qb_t()];
    let output_t = vec![qb_t()];
    let mut h =
        FunctionBuilder::new("discard_first_qubit", Signature::new(input_t, output_t)).unwrap();

    let [q1, q2] = h.input_wires_arr();

    h.add_dataflow_op(TketOp::MeasureFree, [q1]).unwrap();

    let [q2] = h.add_dataflow_op(TketOp::X, [q2]).unwrap().outputs_arr();

    let hugr = h.finish_hugr_with_outputs([q2]).unwrap();
    hugr.into()
}

After running serialize::pytket::tests::encoded_circuit_roundtrip on it, the final result is

graph LR
    subgraph 0 ["(0) Module"]
        direction LR
        subgraph 1 ["(1) [**FuncDefn: #quot;discard_first_qubit#quot;**]"]
            direction LR
            style 1 stroke:#832561,stroke-width:3px
            7["(7) Input"]
            8["(8) Output"]
            9["(9) tket.quantum.X"]
            10["(10) tket.quantum.Measure"]
            11["(11) tket.quantum.QFree"]
            7--"0:0<br>qubit"-->10
            7--"1:0<br>qubit"-->9
            9--"0:0<br>qubit"-->11
            10--"0:0<br>qubit"-->8
        end
    end
Loading

Notice that we're connecting q1 to the output rather than q2. We need to track the ignored qubits on the pytket circuit somehow, (or again just put them on the CircuitInfo)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions