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

chore: update hugr dependency #192

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ members = ["pyrs", "compile-rewriter", "taso-optimiser"]

[workspace.dependencies]

quantinuum-hugr = { git = "https://github.com/CQCL-DEV/hugr", rev = "9254ac7" }
quantinuum-hugr = { git = "https://github.com/CQCL-DEV/hugr", rev = "9195d15" }
portgraph = { version = "0.9", features = ["serde"] }
pyo3 = { version = "0.19" }
itertools = { version = "0.11.0" }
Expand Down
7 changes: 3 additions & 4 deletions src/passes/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ impl Chunk {
.unwrap_or_else(|e| panic!("The chunk circuit is no longer a dataflow graph: {e}"));
let node_map = circ
.insert_subgraph(root, &self.circ, &subgraph)
.expect("Failed to insert the chunk subgraph")
.node_map;
.expect("Failed to insert the chunk subgraph");

let mut input_map = HashMap::with_capacity(self.inputs.len());
let mut output_map = HashMap::with_capacity(self.outputs.len());
Expand Down Expand Up @@ -536,7 +535,7 @@ mod test {

let mut reassembled = chunks.reassemble().unwrap();

reassembled.infer_and_validate(&REGISTRY).unwrap();
reassembled.update_validate(&REGISTRY).unwrap();
assert_eq!(circ.circuit_hash(), reassembled.circuit_hash());
}

Expand Down Expand Up @@ -566,7 +565,7 @@ mod test {

let mut reassembled = chunks.reassemble().unwrap();

reassembled.infer_and_validate(&REGISTRY).unwrap();
reassembled.update_validate(&REGISTRY).unwrap();

assert_eq!(reassembled.commands().count(), 1);
let h = reassembled.commands().next().unwrap().node();
Expand Down
15 changes: 14 additions & 1 deletion src/passes/commutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ impl Rewrite for PullForward {

type ApplyResult = ();

type InvalidationSet<'a> = std::vec::IntoIter<Node>
where
Self: 'a;

const UNCHANGED_ON_FAILURE: bool = false;

fn verify(&self, _h: &impl HugrView) -> Result<(), Self::Error> {
Expand Down Expand Up @@ -294,6 +298,15 @@ impl Rewrite for PullForward {
}
Ok(())
}

fn invalidation_set(&self) -> Self::InvalidationSet<'_> {
// TODO: This could avoid creating a vec, but it'll be easier to do once
// return position impl trait is available.
let mut nodes = vec![self.command.node()];
let next_nodes = self.new_nexts.values().map(|c| c.node());
nodes.extend(next_nodes);
nodes.into_iter()
}
}

/// Pass which greedily commutes operations forwards in order to reduce depth.
Expand Down Expand Up @@ -603,7 +616,7 @@ mod test {
let node_count = case.node_count();
let depth_before = depth(&case);
let move_count = apply_greedy_commutation(&mut case).unwrap();
case.infer_and_validate(&REGISTRY).unwrap();
case.update_validate(&REGISTRY).unwrap();

assert_eq!(
move_count, expected_moves,
Expand Down