Skip to content
Open
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
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ You can use [`release-plz`](https://release-plz.ieni.dev/) to automatically gene
# If you have cargo-semver-checks installed,
# release-plz will ensure your changes don't break the semver rules.
cargo install cargo-semver-checks --locked
# Analyze the new comments to generate the changelogs / bump the versions
# Analyse the new comments to generate the changelogs / bump the versions
release-plz update
```

Expand Down Expand Up @@ -287,7 +287,7 @@ For historical reasons, the repository hosting this project is called `tket2`.

`pytket` / `tket` (a.k.a. `tket1`) was the first version of the tket library, written in C++ and Python.
`TKET2` was the grounds-up rewrite of the compiler, based on the HUGR IR and aimed at
optimising quantum programs with complex classical control flow, type generics, etc.
optimizing quantum programs with complex classical control flow, type generics, etc.

For simplicity, the `tket2` libraries were renamed to `tket`. Throughout the
project we refer to the new codebase as _tket_, while the old codebase is
Expand Down
2 changes: 1 addition & 1 deletion docs/quantum.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ operations we can state the program only uses `N` qubits.
## Angles

The "angle" extension defines a specialized `angle<N>` type which is used
to express parameters of rotation gates. The type is parametrized by the
to express parameters of rotation gates. The type is parameterized by the
_log-denominator_, which is an integer $N \in [0, 53]$; angles with
log-denominator $N$ are multiples of $2 \pi / 2^N$, where the multiplier is an
unsigned `int<N>` in the range $[0, 2^N]$. The maximum log-denominator $53$
Expand Down
2 changes: 1 addition & 1 deletion pg-libs/pg-core/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pg-core
Core IR definitions for the `pg-libs` optimisation stack.
Core IR definitions for the `pg-libs` optimization stack.
This crate provides:

- A `PauliGraph` IR that also serves as a quantum circuit representation, supporting common circuit operations.
Expand Down
2 changes: 1 addition & 1 deletion pg-libs/pg-kernels/pg-bitpacked/src/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ make_simd_tq_gate!(simd_zz_gate, zz_gate);
///
/// XY gate: `gz0=0u64, gx0=u64::MAX, gz1=u64::MAX, gx1=u64::MAX`
///
/// Compared to the specialised functions (e.g., `simd_xx_gate`), this function
/// Compared to the specialized functions (e.g., `simd_xx_gate`), this function
/// avoids branching prediction penalties in some loop scenarios.
pub fn apply_branchless_tqe_simd<const N: usize>(
zs0: &mut [u64],
Expand Down
4 changes: 2 additions & 2 deletions pg-libs/pg-passes/pg-greedy-synth/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ The reducer creates a `PackedPGSlice`, a `Frontier` and a `GatePool`.

It loads commuting sets into the lookahead slice, reduces the first visible set
and appends the resulting gates to the output graph. It also handles black boxes
and recursively synthesises conditional boxes. After reducing every operation
set, it synthesises the remaining Clifford tableau.
and recursively synthesizes conditional boxes. After reducing every operation
set, it synthesizes the remaining Clifford tableau.

### `PackedPGSlice`

Expand Down
2 changes: 1 addition & 1 deletion pg-libs/pg-passes/pg-greedy-synth/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pg-greedy-synth

`pg-greedy-synth` provides `GreedySynthPass`, which uses a greedy heuristic to
synthesise a canonical Pauli graph. It processes commuting operation sets in
synthesize a canonical Pauli graph. It processes commuting operation sets in
order and selects TQEs that reduce the current operations while taking nearby
operations into account.

Expand Down
2 changes: 1 addition & 1 deletion pg-libs/pg-passes/pg-greedy-synth/TUNING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Defined in [synthesis/greedy.rs](src/synthesis/greedy.rs).
| `SPARSE_WEIGHTING_MAX_DENSITY` | `0.25` | `ExpandedSimdWeightedSum` strategy uses sparse iteration below this mask density, avoiding work on zero bits. | [expanded.rs](src/backend/weighted_sum/expanded.rs) |
| `ALPHA` | `0.588` | Factor by which to discount the weight of each successive set, favouring nearby operations. | [greedy.rs](src/backend/greedy.rs) |
| `MAX_SELECTION_CANDIDATES` | `5` | Limits depth comparison to this many current candidates with the lowest costs. | [gate_pool.rs](src/reducer/gate_pool.rs) |
| `DEPTH_WEIGHT` | `0.3` | Weights normalised depth relative to normalised gate cost. Larger values favour depth more strongly. | [gate_pool.rs](src/reducer/gate_pool.rs) |
| `DEPTH_WEIGHT` | `0.3` | Weights normalized depth relative to normalized gate cost. Larger values favour depth more strongly. | [gate_pool.rs](src/reducer/gate_pool.rs) |
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl GatePool {
/// Selects the best candidate using gate cost and projected TQE depth.
///
/// Selection examines at most five current entries with the lowest costs. It
/// normalises cost and depth, then gives depth a weight of 0.3. These values are
/// normalizes cost and depth, then gives depth a weight of 0.3. These values are
/// inherited tuning heuristics and should only change with representative
/// benchmarks and an output quality comparison. Unselected candidates are
/// returned to the pool only when they are disjoint from the chosen gate.
Expand Down
6 changes: 3 additions & 3 deletions pg-libs/pg-passes/pg-greedy-synth/src/reducer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ where
/// This fills a [`PackedPGSlice`], rebuilds a [`Frontier`] for its
/// first visible set, emits operations with zero cost and repeatedly
/// applies a sampled TQE from the cheapest positive cost bucket. Once all
/// sets are retired, it synthesises the remaining Clifford tableau with the
/// sets are retired, it synthesizes the remaining Clifford tableau with the
/// same frontier and candidate pool machinery.
pub(crate) fn reduce(&mut self, input: &PauliGraph) -> PauliGraph {
let mut qubit_depth = vec![0; input.get_n_qubits()];
Expand Down Expand Up @@ -162,11 +162,11 @@ where
}
}

/// Synthesises all operations in the current front set.
/// Synthesizes all operations in the current front set.
///
/// Black boxes and conditional boxes are standalone sets. A black box first
/// emits the Clifford tableau captured immediately before it. A conditional
/// box is decoded, canonicalised and reduced recursively, then its condition
/// box is decoded, canonicalized and reduced recursively, then its condition
/// is copied to every emitted gate.
fn reduce_front_set(
&mut self,
Expand Down
6 changes: 3 additions & 3 deletions pg-libs/pg-passes/pg-greedy-synth/src/synthesis/greedy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ macro_rules! impl_pass_configuration {
self
}

/// Selects the parallelisation policy for candidate costing.
/// Selects the parallelization policy for candidate costing.
///
/// The default is [`ParallelMode::Auto`].
pub fn with_parallel_mode(mut self, mode: ParallelMode) -> Self {
Expand All @@ -220,7 +220,7 @@ macro_rules! impl_pass_configuration {
};
}

/// Greedily synthesises a canonical Pauli graph with scalar packed kernels.
/// Greedily synthesizes a canonical Pauli graph with scalar packed kernels.
///
/// The pass expects the output of `CanonicalFormPass` followed by
/// `GroupCommutingOpsPass`. Output contains Clifford gates on individual
Expand All @@ -246,7 +246,7 @@ impl PGPass for GreedySynthPass {
}
}

/// Greedily synthesises a canonical Pauli graph with portable SIMD kernels.
/// Greedily synthesizes a canonical Pauli graph with portable SIMD kernels.
#[cfg(feature = "simd")]
pub struct GreedySynthSimdPass {
config: GreedySynthConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const PARALLEL_COSTING_THRESHOLD: usize = 150_000;

/// Parallelisation mode for gate costing.
/// Parallelization mode for gate costing.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ParallelMode {
/// Always use sequential execution.
Expand Down
4 changes: 2 additions & 2 deletions pg-libs/pg-passes/pg-optimise/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pg-optimise

This crate contains 2 optimisation passes for `PauliGraph`s.
This crate contains 2 optimization passes for `PauliGraph`s.

## Passes

Expand All @@ -14,5 +14,5 @@ Greedily merges Pauli rotations with the same Pauli string when they commute
with every operation between them. Clifford rotations are folded into
tableaux.

Consider running `CanonicalFormPass` before either optimisation pass so that
Consider running `CanonicalFormPass` before either optimization pass so that
the input operations are in the expected form.
2 changes: 1 addition & 1 deletion pg-libs/pg-passes/pg-optimise/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Optimisation passes for Pauli graphs.
//! Optimization passes for Pauli graphs.

mod commuting_sets;
mod packed_op;
Expand Down
2 changes: 1 addition & 1 deletion pg-libs/pg-qm-tableau/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ impl Tableau {
}
}

/// Initialise an identity Tableau
/// Initialize an identity Tableau
pub fn eye(n_qubits: usize) -> Self {
let n_images = n_qubits * 2;
let mut qubit_slices_z_bits = Vec::with_capacity(n_qubits);
Expand Down
2 changes: 1 addition & 1 deletion tket/badger-optimiser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static PEAK_ALLOC: peak_alloc::PeakAlloc = peak_alloc::PeakAlloc;
#[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

/// Optimise circuits using Quartz-generated ECCs.
/// Optimize circuits using Quartz-generated ECCs.
///
/// Quartz: <https://github.com/quantum-compiler/quartz>
#[derive(Parser, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion tket/badger-optimiser/src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Setup routines for tracing and logging of the optimisation process.
//! Setup routines for tracing and logging of the optimization process.
use std::fs::File;
use std::io::BufWriter;
use std::path::PathBuf;
Expand Down
4 changes: 2 additions & 2 deletions tket/qis-compiler/rust/gpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl GpuCodegen {
/// message from the GPU library - which might contain verbose information
/// pertinent to the failure.
///
/// As such we utilise the verify_gpu_call helper to emit a panic directly
/// As such we utilize the verify_gpu_call helper to emit a panic directly
/// via selene's panic_str function, which can handle c strings.
fn emit_get_context<'c, H: HugrView<Node = Node>>(
&self,
Expand Down Expand Up @@ -678,7 +678,7 @@ fn emit_api_validation<'c, H: HugrView<Node = Node>>(
/// we emit a panic with the error message from the library.
/// If no error message is available, we use a default message.
///
/// Utilises the selene panic_str function to emit the panic,
/// Utilizes the selene panic_str function to emit the panic,
/// rather than the size-restricted QIS panic.
fn emit_panic_with_gpu_error<'c, H: HugrView<Node = Node>>(
ctx: &EmitFuncContext<'c, '_, H>,
Expand Down
2 changes: 1 addition & 1 deletion tket/tket-eccs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[py-version]: https://img.shields.io/pypi/pyversions/tket-eccs
[pypi]: https://img.shields.io/pypi/v/tket-eccs

This is an auxiliary Python package containing compiler rewrite sets used for `tket`'s optimisation passes.
This is an auxiliary Python package containing compiler rewrite sets used for `tket`'s optimization passes.

This package is intended to be used as an internal dependency for `tket`.
See https://pypi.org/project/tket/ for the main package.
Expand Down
2 changes: 1 addition & 1 deletion tket/tket-eccs/src/tket_eccs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""`tket-eccs` is a Python package containing compiler rewrite sets used for `tket`'s optimisation passes.
"""`tket-eccs` is a Python package containing compiler rewrite sets used for `tket`'s optimization passes.

This package is intended to be used as an internal dependency for `tket`.
"""
Expand Down
34 changes: 17 additions & 17 deletions tket/tket-py/src/optimiser.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! PyO3 wrapper for the Badger circuit optimiser.
//! PyO3 wrapper for the Badger circuit optimizer.

use std::io::BufWriter;
use std::{fs, num::NonZeroUsize, path::PathBuf};
Expand All @@ -23,18 +23,18 @@ pub fn module(py: Python<'_>) -> PyResult<Bound<'_, PyModule>> {
/// Wrapped [`DefaultBadgerOptimiser`].
///
/// Currently only exposes loading from an ECC file using the constructor
/// and optimising using default logging settings.
/// and optimizing using default logging settings.
#[pyclass(name = "BadgerOptimiser", skip_from_py_object)]
#[derive(Clone, From)]
pub struct PyBadgerOptimiser(BadgerOptimiser<PyRewriter, DefaultBadgerStrategy>);

/// The cost function to use for the Badger optimiser.
/// The cost function to use for the Badger optimizer.
#[derive(Debug, Clone, Copy, Default)]
pub enum BadgerCostFunction {
/// Minimise CX count.
/// Minimize CX count.
#[default]
CXCount,
/// Minimise Rz count.
/// Minimize Rz count.
RzCount,
}

Expand Down Expand Up @@ -91,46 +91,46 @@ impl PyBadgerOptimiser {
BadgerOptimiser::new(PyRewriter::ECC(rewriter), strategy).into()
}

/// Run the optimiser on a circuit.
/// Run the optimizer on a circuit.
///
/// Returns an optimised circuit and optionally log the progress to a CSV
/// Returns an optimized circuit and optionally log the progress to a CSV
/// file.
///
/// # Parameters
///
/// * `circ`: The circuit to optimise.
/// * `circ`: The circuit to optimize.
///
/// * `timeout`: The maximum time (in seconds) to run the optimiser.
/// * `timeout`: The maximum time (in seconds) to run the optimizer.
///
/// If `None` the optimiser will run indefinitely, or until
/// If `None` the optimizer will run indefinitely, or until
/// `progress_timeout` is reached.
///
/// * `progress_timeout`: The maximum time (in seconds) to search for new
/// improvements to the circuit. If no progress is made in this time,
/// the optimiser will stop.
/// the optimizer will stop.
///
/// If `None` the optimiser will run indefinitely, or until `timeout` is
/// If `None` the optimizer will run indefinitely, or until `timeout` is
/// reached.
///
/// * `max_circuit_count`: The maximum number of circuits to process before
/// stopping the optimisation.
/// stopping the optimization.
///
///
/// For data parallel multi-threading, (split_circuit=true), applies on
/// a per-thread basis, otherwise applies globally.
///
/// If `None` the optimiser will run indefinitely, or until `timeout` is
/// If `None` the optimizer will run indefinitely, or until `timeout` is
/// reached.
///
/// * `n_threads`: The number of threads to use. Defaults to `1`.
///
/// * `split_circ`: Whether to split the circuit into chunks and process
/// each in a separate thread.
///
/// If this option is set to `true`, the optimiser will split the
/// If this option is set to `true`, the optimizer will split the
/// circuit into `n_threads` chunks.
///
/// If this option is set to `false`, the optimiser will run `n_threads`
/// If this option is set to `false`, the optimizer will run `n_threads`
/// parallel searches on the whole circuit (default).
///
/// * `queue_size`: The maximum size of the circuit candidates priority
Expand Down Expand Up @@ -168,7 +168,7 @@ impl PyBadgerOptimiser {
}

impl PyBadgerOptimiser {
/// The Python optimise method, but on Hugrs.
/// The Python optimize method, but on Hugrs.
pub(super) fn optimise(
&self,
circ: Circuit,
Expand Down
16 changes: 8 additions & 8 deletions tket/tket-py/src/passes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Passes for optimising circuits.
//! Passes for optimizing circuits.

pub mod chunks;
mod inline_funcs;
Expand Down Expand Up @@ -82,9 +82,9 @@ create_py_exception!(
"Errors from the QSystem pre-LLVM pass."
);

/// Flatten the structure of a Guppy-generated program to enable additional optimisations.
/// Flatten the structure of a Guppy-generated program to enable additional optimizations.
///
/// This should normally be called first before other optimisations.
/// This should normally be called first before other optimizations.
///
/// Parameters:
/// - resolve_modifiers: Whether to resolve modifier operations.
Expand Down Expand Up @@ -140,18 +140,18 @@ fn greedy_depth_reduce(circ: &mut CompilationState) -> PyResult<u32> {
Ok(n_moves)
}

/// Badger optimisation pass.
/// Badger optimization pass.
///
/// HyperTKET's best attempt at optimising a circuit using circuit rewriting
/// and the given Badger optimiser.
/// HyperTKET's best attempt at optimizing a circuit using circuit rewriting
/// and the given Badger optimizer.
///
/// Will use at most `max_threads` threads (plus a constant). Defaults to the
/// number of CPUs available.
///
/// The optimisation will terminate at the first of the following timeout
/// The optimization will terminate at the first of the following timeout
/// criteria, if set:
/// - `timeout` seconds (default: 15min) have elapsed since the start of the
/// optimisation
/// optimization
/// - `progress_timeout` (default: None) seconds have elapsed since progress
/// in the cost function was last made
/// - `max_circuit_count` (default: None) circuits have been explored.
Expand Down
2 changes: 1 addition & 1 deletion tket/tket-py/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Program state definition.
//!
//! This module defines [`CompilationState`], a wrapper around a rust-defined
//! [`hugr::Hugr`] that is optimised for compilation and rewriting.
//! [`hugr::Hugr`] that is optimized for compilation and rewriting.

mod base;
mod cost;
Expand Down
2 changes: 1 addition & 1 deletion tket/tket-py/tket/_state/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __call__(self, q: ComWire) -> Command:

Measure = MeasureDef()

# TODO use angle type once extension is serialised.
# TODO use angle type once extension is serialized.
_RzSig = tys.FunctionType([tys.Qubit, FLOAT_T], [tys.Qubit])


Expand Down
Loading
Loading