pub struct TPUQuantumSimulator { /* private fields */ }Expand description
TPU-accelerated quantum simulator
Implementations§
Source§impl TPUQuantumSimulator
impl TPUQuantumSimulator
Sourcepub fn new(config: TPUConfig) -> Result<Self>
pub fn new(config: TPUConfig) -> Result<Self>
Create a new TPU quantum simulator.
HONEST AVAILABILITY GATE: this build links no TPU runtime (no
JAX/XLA/libtpu), so it cannot place tensors on, or dispatch work to, a
physical Cloud/Edge TPU. Requesting a real device type
(TPUv2..TPUv5p) therefore fails loudly rather than fabricating that
the silicon is present.
TPUDeviceType::Simulated is explicitly supported: it is a CPU-side
numerical simulation of the device math (the gate applications below
compute the exact state-vector linear algebra on the CPU). It never
claims a TPU executed anything.
Sourcepub fn execute_batch_circuit(
&mut self,
circuits: &[InterfaceCircuit],
initial_states: &[Array1<Complex64>],
) -> Result<Vec<Array1<Complex64>>>
pub fn execute_batch_circuit( &mut self, circuits: &[InterfaceCircuit], initial_states: &[Array1<Complex64>], ) -> Result<Vec<Array1<Complex64>>>
Execute batched quantum circuit
Sourcepub fn compute_expectation_values_tpu(
&mut self,
states: &[Array1<Complex64>],
observables: &[String],
) -> Result<Array2<f64>>
pub fn compute_expectation_values_tpu( &mut self, states: &[Array1<Complex64>], observables: &[String], ) -> Result<Array2<f64>>
Compute Pauli-observable expectation values (CPU numerical simulation).
Each observable is a compact single-qubit Pauli string of the form
"<P><qubit>", e.g. "Z0", "X1", "Y2" (identity on every other
qubit). The result <psi|P|psi> is computed exactly from the amplitudes;
no value is fabricated.
Sourcepub const fn get_device_info(&self) -> &TPUDeviceInfo
pub const fn get_device_info(&self) -> &TPUDeviceInfo
Get device information
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset performance statistics
Sourcepub const fn is_tpu_available(&self) -> bool
pub const fn is_tpu_available(&self) -> bool
Whether a real TPU runtime is available.
HONEST: this build links no TPU runtime, so a physical TPU is never
available. This returns false even though a CPU Simulated device is
in use — that is a numerical model, not real silicon. Use
Self::is_simulated to check for the CPU-simulation device.
Sourcepub fn is_simulated(&self) -> bool
pub fn is_simulated(&self) -> bool
Whether this simulator is the CPU-side numerical Simulated device.
Sourcepub const fn get_memory_usage(&self) -> (usize, usize)
pub const fn get_memory_usage(&self) -> (usize, usize)
Get memory usage
Sourcepub fn garbage_collect(&mut self) -> Result<usize>
pub fn garbage_collect(&mut self) -> Result<usize>
Reclaim memory held by tensor buffers that are no longer device-resident.
HONEST: this frees exactly the bytes of buffers whose on_device flag is
false (i.e. genuinely releasable in the model) and updates the
accounting accordingly. It does not fabricate a fixed “freed 10%” figure.
Returns the number of bytes actually reclaimed.
Auto Trait Implementations§
impl Freeze for TPUQuantumSimulator
impl RefUnwindSafe for TPUQuantumSimulator
impl Send for TPUQuantumSimulator
impl Sync for TPUQuantumSimulator
impl Unpin for TPUQuantumSimulator
impl UnsafeUnpin for TPUQuantumSimulator
impl UnwindSafe for TPUQuantumSimulator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.