pub struct TraceSession { /* private fields */ }Expand description
Streaming trace session writing TensorFlow-Profiler-style span JSONL.
Implementations§
Source§impl TraceSession
impl TraceSession
Sourcepub fn open(path: impl AsRef<Path>, run: ProfileRun) -> Result<Self>
pub fn open(path: impl AsRef<Path>, run: ProfileRun) -> Result<Self>
Open a trace and own its single root span until Self::finish.
Sourcepub fn begin_span(
&self,
name: impl Into<String>,
kind: SpanKind,
) -> SpanGuard<'_>
pub fn begin_span( &self, name: impl Into<String>, kind: SpanKind, ) -> SpanGuard<'_>
Begin a nested span; parent is the top of the session span stack (TF Profiler call tree).
Sourcepub fn begin_measurement(&self, name: impl Into<String>) -> SpanGuard<'_>
pub fn begin_measurement(&self, name: impl Into<String>) -> SpanGuard<'_>
Begin the single caller-controlled region used for total-time comparisons.
Sourcepub fn begin_step_span(
&self,
name: impl Into<String>,
step: ExecutionStep,
kind: SpanKind,
) -> SpanGuard<'_>
pub fn begin_step_span( &self, name: impl Into<String>, step: ExecutionStep, kind: SpanKind, ) -> SpanGuard<'_>
Begin a span tagged with a PyTorch-style training step (forward / backward / optimizer).
Sourcepub fn record_completed_host_span(
&self,
name: impl Into<String>,
kind: SpanKind,
start_ns: u64,
duration_ns: u64,
) -> Result<SpanId>
pub fn record_completed_host_span( &self, name: impl Into<String>, kind: SpanKind, start_ns: u64, duration_ns: u64, ) -> Result<SpanId>
Record already-completed host work without changing the live span stack.
start_ns is a monotonic offset from this session’s start and duration_ns must be
positive. The interval must have completed before this call. The closed span is attached
directly to the session root, so it may overlap live nested spans without implying a
synchronous parent/child call relationship.
pub fn elapsed_ns(&self) -> u64
Sourcepub fn host_timestamp_ns(&self, instant: Instant) -> Result<u64>
pub fn host_timestamp_ns(&self, instant: Instant) -> Result<u64>
Convert an Instant from this process into this trace session’s
monotonic nanosecond clock without an independently sampled anchor.
Sourcepub fn record_op(&self, span_id: SpanId, op: OpRecord<'_>) -> Result<()>
pub fn record_op(&self, span_id: SpanId, op: OpRecord<'_>) -> Result<()>
Record a timed op observation attached to span_id.
Sourcepub fn record_tensor(
&self,
span_id: SpanId,
tensor: TensorRecord<'_>,
) -> Result<()>
pub fn record_tensor( &self, span_id: SpanId, tensor: TensorRecord<'_>, ) -> Result<()>
Record tensor metadata. Logical allocation lifetimes require explicit memory events.
Sourcepub fn record_scalar(
&self,
span_id: SpanId,
label: &str,
value: f64,
) -> Result<()>
pub fn record_scalar( &self, span_id: SpanId, label: &str, value: f64, ) -> Result<()>
Record one application-computed scalar observation (loss term, gate value, clip fraction, cosine, …) already available on the host.
No device reductions or readbacks are triggered; the value is stored as a single-element labeled statistic on the tensor-stats plane, so series and comparison tooling treat it like any other labeled mechanism observation. The evidence is observational; it never claims causal attribution.
Sourcepub fn record_tensor_stats(
&self,
span_id: SpanId,
label: &str,
tensor: &Tensor,
) -> Result<()>
pub fn record_tensor_stats( &self, span_id: SpanId, label: &str, tensor: &Tensor, ) -> Result<()>
Record device-reduced numerical statistics for a caller-labeled Candle tensor.
Sourcepub fn record_memory_alloc(
&self,
span_id: SpanId,
mem: MemoryRecord<'_>,
) -> Result<()>
pub fn record_memory_alloc( &self, span_id: SpanId, mem: MemoryRecord<'_>, ) -> Result<()>
Record an explicit tensor allocation (TensorFlow memory timeline).
Sourcepub fn record_memory_free(
&self,
span_id: SpanId,
mem: MemoryRecord<'_>,
) -> Result<()>
pub fn record_memory_free( &self, span_id: SpanId, mem: MemoryRecord<'_>, ) -> Result<()>
Record an explicit tensor deallocation.
Sourcepub fn record_device_memory(&self, sample: DeviceMemoryRecord<'_>) -> Result<()>
pub fn record_device_memory(&self, sample: DeviceMemoryRecord<'_>) -> Result<()>
Record a device-level memory checkpoint (cudaMemGetInfo-style).
pub fn record_device_interval( &self, span_id: SpanId, interval: DeviceIntervalRecord<'_>, ) -> Result<()>
pub fn record_call_edge( &self, from: SpanId, to: SpanId, duration_ns: u64, ) -> Result<()>
pub fn record_data_edge(&self, from_tensor: &str, to_tensor: &str) -> Result<()>
Sourcepub fn record_gradient(
&self,
root: impl Into<String>,
key: impl Into<String>,
state: GradientState,
norm: Option<f64>,
) -> Result<()>
pub fn record_gradient( &self, root: impl Into<String>, key: impl Into<String>, state: GradientState, norm: Option<f64>, ) -> Result<()>
Record one parameter gradient fact from a probe run.
Present requires a finite positive norm, Zero requires positive zero, and Missing or
NonFinite require None. Exact-contract captures emit one event per (root, key).
pub fn flush(&self) -> Result<()>
Auto Trait Implementations§
impl !Freeze for TraceSession
impl !RefUnwindSafe for TraceSession
impl !Sync for TraceSession
impl Send for TraceSession
impl Unpin for TraceSession
impl UnsafeUnpin for TraceSession
impl UnwindSafe for TraceSession
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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