class
MemoryStats
MemoryStats(impl: _C_engine.MemoryStats)Snapshot of allocator state at a single point in time.
Wraps the engine's memory tracker so user code can correlate peak
memory usage with specific phases of training or inference. Combined
with Profiler events, this is sufficient to diagnose memory
regressions and validate the effect of activation checkpointing.
Parameters
implobjectUnderlying engine
MemoryStats handle.Notes
Reported quantities are byte counts. The ratio is a coarse indicator of fragmentation overhead.
Examples
>>> import lucid
>>> with lucid.profiler.profile() as prof:
... _ = lucid.randn(1024, 1024)
>>> stats = prof.memory_stats()
>>> stats and stats.peak_bytesMethods (6)
dunder
__init__
→None__init__(impl: _C_engine.MemoryStats)Initialise the instance. See the class docstring for parameter semantics.
prop
current_bytes
→intcurrent_bytes: intCurrently allocated bytes.
prop
peak_bytes
→intpeak_bytes: intPeak allocated bytes since last reset.
prop
alloc_count
→intalloc_count: intNumber of allocations.
prop
free_count
→intfree_count: intNumber of deallocations.
dunder
__repr__
→str__repr__()Return a developer-facing string representation of the instance.