Module channel

Module channel 

Source
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:

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§

OutputBuffer
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.