Expand description
Channel<W> — unified abstraction for gates and noise.
Every operation on a PauliSum (Clifford gate, Pauli rotation,
arbitrary unitary, noise channel) maps a single Pauli string to a small
weighted sum of Pauli strings. The trait formalizes that mapping; the
engine consumes it via the sort-merge pipeline (see engine).
Built-ins in this module:
Clifford1Q,Clifford2Q— table-driven Clifford gates withMAX_FANOUT = 1.PauliRotation—exp(-i·θ·P/2)withMAX_FANOUT = 2(commuting inputs collapse to fanout-1 at runtime).GeneralUnitary1Q,GeneralUnitary2Q— generic unitaries stored as Pauli-expansion tables.Depolarizing,Dephasing— coefficient-rescaling noise (MAX_FANOUT = 1).AmplitudeDamping— the one built-in withMAX_FANOUT = 2.IdentityChannel— pass-through, used in tests and as a neutral composition element.
See design doc §6.
§Implementing a custom channel
Implement the trait directly; the engine treats your type as just another
Box<dyn Channel<W>> inside a Circuit. Three required methods
plus an optional Channel::apply_adjoint override.
use paulistrings::{Channel, OutputBuffer};
use num_complex::Complex64;
/// Multiplies every input coefficient by a complex factor, with no
/// support and `MAX_FANOUT = 1`.
struct GlobalPhase {
support: [u32; 0],
factor: Complex64,
}
impl<const W: usize> Channel<W> for GlobalPhase {
fn max_fanout(&self) -> usize { 1 }
fn support(&self) -> &[u32] { &self.support }
fn apply(
&self,
input_x: &[u64; W],
input_z: &[u64; W],
coeff: Complex64,
out: &mut OutputBuffer<'_, W>,
) {
out.push(*input_x, *input_z, coeff * self.factor);
}
}
let ch = GlobalPhase {
support: [],
factor: Complex64::new(0.0, 1.0),
};
let _: Box<dyn Channel<1>> = Box::new(ch);Re-exports§
pub use clifford::Clifford1Q;pub use clifford::Clifford2Q;pub use identity::IdentityChannel;pub use noise::AmplitudeDamping;pub use noise::Dephasing;pub use noise::Depolarizing;pub use rotation::PauliRotation;pub use unitary::GeneralUnitary1Q;pub use unitary::GeneralUnitary2Q;
Modules§
- clifford
- Clifford gates (table-driven, branchless). See §6.
- identity
IdentityChannel— no-op channel that emits its input unchanged.- noise
- Noise channels: Depolarizing, Dephasing, AmplitudeDamping. See §6.
- rotation
- Pauli rotation
exp(-i * theta * P / 2). See §6. - unitary
- General unitaries pre-decomposed into Pauli expansions. See §6.
Structs§
- Output
Buffer - Pre-allocated, fixed-capacity SoA scratch buffer for channel outputs.
Traits§
- Channel
- Anything that maps a Pauli string to a small weighted sum of Pauli strings.