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

Querying the linear inputs of a QFree command throws an error. #309

Closed
aborgna-q opened this issue Apr 12, 2024 · 0 comments · Fixed by #310
Closed

Querying the linear inputs of a QFree command throws an error. #309

aborgna-q opened this issue Apr 12, 2024 · 0 comments · Fixed by #310
Assignees
Labels
bug Something isn't working

Comments

@aborgna-q
Copy link
Collaborator

Test case:

let qb_row = vec![QB_T; 1];
let mut h = DFGBuilder::new(FunctionType::new(qb_row.clone(), vec![]))?;
let [q_in] = h.input_wires_arr();
h.add_dataflow_op(Tk2Op::QFree, [q_in])?;
let circ = h.finish_hugr_with_outputs([], &REGISTRY)?;

let mut cmds = circ.commands();
let free_cmd = cmds.next().unwrap();
assert_eq!(
    free_cmd.inputs().map(|(unit, _, _)| unit).collect_vec(),
    [CircuitUnit::Linear(0)]
);

Error:

thread 'circuit::command::test::alloc_free' panicked at tket2/src/circuit/command.rs:169:13:
Could not assign a linear unit to port Port(Incoming, 0) of node Node(3)
@aborgna-q aborgna-q added bug Something isn't working P-high labels Apr 12, 2024
@aborgna-q aborgna-q self-assigned this Apr 12, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 16, 2024
`Command` only stored the linear units assigned to its output ports, so
querying the input linear unit to a `QFree` operation panicked.

This pr tracks the `input_linear_units` in addition to the output ones.

Fixes #309.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant