pub struct QuantumEmbedding {
pub vocab_size: usize,
pub dim: usize,
pub angles: Vec<f32>,
}Expand description
Quantum embedding: maps vocab indices to density matrices.
Fields§
§vocab_size: usize§dim: usize§angles: Vec<f32>Per-token rotation angles [vocab_size × dim]. Learnable.
Each token gets dim angles that parameterize a unitary rotation.
Implementations§
Source§impl QuantumEmbedding
impl QuantumEmbedding
pub fn new(vocab_size: usize, dim: usize, seed: u64) -> Self
Sourcepub fn embed(&self, token: usize) -> DensityMatrixN
pub fn embed(&self, token: usize) -> DensityMatrixN
Embed a single token as a density matrix. Start with |k mod dim⟩, then apply parameterized rotations to spread the state across modes. The rotations are the learnable embedding.
Sourcepub fn embed_amplitude(&self, token: usize) -> Vec<Complex>
pub fn embed_amplitude(&self, token: usize) -> Vec<Complex>
Embed a single token as an amplitude vector (Fock space representation).
Returns the dim-dimensional complex state vector |ψ⟩ WITHOUT forming the density matrix ρ = |ψ⟩⟨ψ|. This is the Fock space representation: dim amplitudes instead of dim² matrix entries.
BA-62: At dim=86, this returns 688 bytes instead of 59,168 bytes (86× smaller). The populations |ψ_k|² are identical to the diagonal of ρ = |ψ⟩⟨ψ|.
Sourcepub fn num_params(&self) -> usize
pub fn num_params(&self) -> usize
Number of learnable parameters.
Trait Implementations§
Source§impl Clone for QuantumEmbedding
impl Clone for QuantumEmbedding
Source§fn clone(&self) -> QuantumEmbedding
fn clone(&self) -> QuantumEmbedding
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QuantumEmbedding
impl RefUnwindSafe for QuantumEmbedding
impl Send for QuantumEmbedding
impl Sync for QuantumEmbedding
impl Unpin for QuantumEmbedding
impl UnsafeUnpin for QuantumEmbedding
impl UnwindSafe for QuantumEmbedding
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more