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 deps #247

Merged
merged 3 commits into from
Nov 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
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ homepage = "https://github.com/CQCL/tket2"
license-file = "LICENCE"
# authors

[workspace.lints.rust]
missing_docs = "warn"

[workspace.dependencies]

tket2 = { path = "./tket2" }
quantinuum-hugr = { git = "https://github.com/CQCL/hugr", rev = "c261bea" }
quantinuum-hugr = { git = "https://github.com/CQCL/hugr", rev = "e7473f2" }
portgraph = { version = "0.10" }
pyo3 = { version = "0.20" }
itertools = { version = "0.11.0" }
itertools = { version = "0.12.0" }
tket-json-rs = { version = "0.3.0" }
tracing = "0.1.37"
portmatching = { git = "https://github.com/lmondada/portmatching", rev = "738c91c" }
portmatching = { version = "0.3.0" }
4 changes: 3 additions & 1 deletion tket2-py/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ rust-version = { workspace = true }
homepage = { workspace = true }
license-file = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[lib]
name = "tket2"
crate-type = ["cdylib"]
Expand Down
2 changes: 0 additions & 2 deletions tket2-py/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
//! Python bindings for TKET2.
#![warn(missing_docs)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this inherited now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the

[lints]
workspace = true

in Cargo.toml (since rust 1.74)


pub mod circuit;
pub mod optimiser;
pub mod passes;
Expand Down
3 changes: 3 additions & 0 deletions tket2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ rust-version = { workspace = true }
homepage = { workspace = true }
license-file = { workspace = true }

[lints]
workspace = true

[lib]
bench = false
name = "tket2"
Expand Down
2 changes: 2 additions & 0 deletions tket2/benches/bench_main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Benchmarks for the tket2 crate.

#[allow(dead_code)]
mod benchmarks;

Expand Down
5 changes: 2 additions & 3 deletions tket2/src/circuit/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,13 @@ impl<'circ, Circ: Circuit> Command<'circ, Circ> {
/// Returns the number of inputs of this command.
#[inline]
pub fn input_count(&self) -> usize {
let optype = self.optype();
optype.signature().input_count() + optype.static_input().is_some() as usize
self.optype().value_input_count() + self.optype().static_input_port().is_some() as usize
}

/// Returns the number of outputs of this command.
#[inline]
pub fn output_count(&self) -> usize {
self.optype().signature().output_count()
self.optype().value_output_count() + self.optype().static_output_port().is_some() as usize
}

/// Returns the port in the command given a linear unit.
Expand Down
13 changes: 7 additions & 6 deletions tket2/src/circuit/units.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub use filter::FilteredUnits;

use std::iter::FusedIterator;

use hugr::ops::OpTrait;
use hugr::types::{EdgeKind, Type, TypeRow};
use hugr::CircuitUnit;
use hugr::{Direction, Node, Port, Wire};
Expand Down Expand Up @@ -136,17 +135,19 @@ where
// We should revisit it once this is reworked on the HUGR side.
fn init_types(circuit: &impl Circuit, node: Node, direction: Direction) -> TypeRow {
let optype = circuit.get_optype(node);
let sig = optype.signature();
let sig = circuit.signature(node).unwrap_or_default();
let mut types = match direction {
Direction::Outgoing => sig.output,
Direction::Incoming => sig.input,
};
if let Some(other) = optype.static_input() {
if direction == Direction::Incoming {
types.to_mut().push(other);
if direction == Direction::Incoming {
if let Some(static_port) = optype.static_input_port() {
if let Some(EdgeKind::Static(static_type)) = optype.port_kind(static_port) {
types.to_mut().push(static_type);
}
}
}
if let Some(EdgeKind::Static(other)) = optype.other_port(direction) {
if let Some(EdgeKind::Static(other)) = optype.other_port_kind(direction) {
types.to_mut().push(other);
}
types
Expand Down
1 change: 0 additions & 1 deletion tket2/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use hugr::extension::prelude::PRELUDE;
use hugr::extension::{ExtensionId, ExtensionRegistry, SignatureError};
use hugr::hugr::IdentList;
use hugr::ops::custom::{ExternalOp, OpaqueOp};
use hugr::ops::OpName;
use hugr::std_extensions::arithmetic::float_types::{extension as float_extension, FLOAT64_TYPE};
use hugr::types::type_param::{CustomTypeArg, TypeArg, TypeParam};
use hugr::types::{CustomType, FunctionType, Type, TypeBound};
Expand Down
2 changes: 1 addition & 1 deletion tket2/src/extension/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn abinop_sig(arg_values: &[TypeArg]) -> Result<FunctionType, SignatureError> {

fn aunop_sig(extension: &Extension) -> Result<FunctionType, SignatureError> {
let angle = type_var(0, extension)?;
Ok(FunctionType::new_linear(vec![angle]))
Ok(FunctionType::new_endo(vec![angle]))
}

fn angle_def(extension: &Extension) -> &TypeDef {
Expand Down
2 changes: 1 addition & 1 deletion tket2/src/json/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl JsonDecoder {
}
wire_map.insert((register, 0).into(), i);
}
let sig = FunctionType::new_linear(
let sig = FunctionType::new_endo(
[vec![QB_T; num_qubits], vec![LINEAR_BIT.clone(); num_bits]].concat(),
);
// .with_extension_delta(&ExtensionSet::singleton(&TKET1_EXTENSION_ID));
Expand Down
16 changes: 9 additions & 7 deletions tket2/src/json/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,15 @@ impl TryFrom<&OpType> for JsonOp {
let mut num_qubits = 0;
let mut num_bits = 0;
let mut num_params = 0;
for ty in op.signature().input.iter() {
if ty == &QB_T {
num_qubits += 1
} else if *ty == *LINEAR_BIT {
num_bits += 1
} else if ty == &FLOAT64_TYPE {
num_params += 1
if let Some(sig) = op.dataflow_signature() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not for this PR but we might be able to use op: & impl DataflowOpTrait in this function instead

for ty in sig.input.iter() {
if ty == &QB_T {
num_qubits += 1
} else if *ty == *LINEAR_BIT {
num_bits += 1
} else if ty == &FLOAT64_TYPE {
num_params += 1
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions tket2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![warn(missing_docs)]

//! TKET2: The Hardware Agnostic Quantum Compiler
//!
//! TKET2 is an open source quantum compiler developed by Quantinuum. Central to
Expand Down
6 changes: 3 additions & 3 deletions tket2/src/portmatching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ impl PEdge {
return Ok(Self::InputEdge { src });
}
let port_type = circ
.get_optype(node)
.signature()
.get(src)
.signature(node)
.unwrap()
.port_type(src)
.cloned()
.ok_or(InvalidEdgeProperty::UntypedPort(src))?;
let is_reversible = type_is_linear(&port_type);
Expand Down
6 changes: 3 additions & 3 deletions tket2/src/portmatching/pattern.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Circuit Patterns for pattern matching

use hugr::IncomingPort;
use hugr::{ops::OpTrait, Node, Port};
use hugr::{Node, Port};
use itertools::Itertools;
use portmatching::{patterns::NoRootFound, HashMap, Pattern, SinglePatternMatcher};
use std::fmt::Debug;
Expand Down Expand Up @@ -62,8 +62,8 @@ impl CircuitPattern {
return Err(InvalidPattern::NotConnected);
}
let (inp, out) = (circuit.input(), circuit.output());
let inp_ports = circuit.get_optype(inp).signature().output_ports();
let out_ports = circuit.get_optype(out).signature().input_ports();
let inp_ports = circuit.signature(inp).unwrap().output_ports();
let out_ports = circuit.signature(out).unwrap().input_ports();
let inputs = inp_ports
.map(|p| circuit.linked_ports(inp, p).collect())
.collect_vec();
Expand Down
10 changes: 5 additions & 5 deletions tket2/src/rewrite/ecc_rewriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//! of the Quartz repository.

use derive_more::{From, Into};
use hugr::ops::OpTrait;
use hugr::PortIndex;
use itertools::Itertools;
use portmatching::PatternID;
Expand Down Expand Up @@ -247,12 +246,13 @@ fn get_patterns(rep_sets: &[EqCircClass]) -> Vec<Option<(CircuitPattern, Vec<usi

/// The port offsets of wires that are empty.
fn empty_wires(circ: &impl Circuit) -> Vec<usize> {
let inp = circ.input();
circ.node_outputs(inp)
let input = circ.input();
let input_sig = circ.signature(input).unwrap();
circ.node_outputs(input)
// Only consider dataflow edges
.filter(|&p| circ.get_optype(inp).signature().get(p).is_some())
.filter(|&p| input_sig.out_port_type(p).is_some())
// Only consider ports linked to at most one other port
.filter_map(|p| Some((p, circ.linked_ports(inp, p).at_most_one().ok()?)))
.filter_map(|p| Some((p, circ.linked_ports(input, p).at_most_one().ok()?)))
// Ports are either connected to output or nothing
.filter_map(|(from, to)| {
if let Some((n, _)) = to {
Expand Down