|
Mila
Deep Neural Network Library
|
Memory allocation breakdown for a single component. More...
Public Member Functions | |
| std::size_t | activeDeviceParameterBytes () const noexcept |
| Device parameter bytes a single token reads. | |
| MemoryStats & | operator+= (const MemoryStats &rhs) noexcept |
| Accumulate another MemoryStats into this one. | |
| std::string | toString () const |
| Produce a human-readable summary of this stats instance. | |
| std::size_t | totalBytes () const noexcept |
| Total memory allocated across all categories and locations. | |
| std::size_t | totalDeviceBytes () const noexcept |
| Total device memory allocated by this component. | |
| std::size_t | totalHostBytes () const noexcept |
| Total host memory allocated by this component. | |
Public Attributes | |
| std::size_t | device_gradient_bytes { 0 } |
| Input and parameter gradient buffers. | |
| std::size_t | device_inactive_parameter_bytes { 0 } |
| Of device_parameter_bytes, what a single token does not read: the unselected experts of a sparse layer. | |
| std::size_t | device_parameter_bytes { 0 } |
| Learnable parameter buffers (weights, biases). | |
| std::size_t | device_scratch_bytes { 0 } |
| The execution context's forward scratch: one buffer shared by every operation on the context, sized by the largest single request. | |
| std::size_t | device_state_bytes { 0 } |
| Forward and decode output buffers, KV cache. | |
| std::size_t | host_gradient_bytes { 0 } |
| Gradient buffers on host (if any). | |
| std::size_t | host_parameter_bytes { 0 } |
| Learnable parameter buffers pinned on host (if any). | |
| std::size_t | host_state_bytes { 0 } |
| Forward and decode output buffers on host (if any). | |
Memory allocation breakdown for a single component.
Reflects the current allocation state at the moment of the call. Categories map directly onto the component build lifecycle:
After construction nothing – construction allocates no device memory After build() parameters + state After setTrainingMode() parameters + state + gradients
Parameters are allocated in onBuilding(), not in the constructor. That is what lets Component::getRequiredMemory() report a footprint from a constructed but unbuilt graph. See Specifications/MemoryFootprint.md section 3.1.
All sizes are in bytes. Device and host allocations are tracked separately as they represent distinct, independently constrained resources.
|
inlinenodiscardnoexcept |
Device parameter bytes a single token reads.
Equals device_parameter_bytes when dense.
|
inlinenoexcept |
Accumulate another MemoryStats into this one.
Used by CompositeComponent and Network to aggregate child stats. Scratch is taken by maximum: every operation of a tree shares the one buffer.
|
inlinenodiscard |
Produce a human-readable summary of this stats instance.
| std::size_t Mila::Dnn::MemoryStats::device_gradient_bytes { 0 } |
Input and parameter gradient buffers.
Allocated lazily on first setTraining(true). Retained thereafter.
| std::size_t Mila::Dnn::MemoryStats::device_inactive_parameter_bytes { 0 } |
Of device_parameter_bytes, what a single token does not read: the unselected experts of a sparse layer.
Resident, never a separate allocation; zero when dense.
| std::size_t Mila::Dnn::MemoryStats::device_parameter_bytes { 0 } |
Learnable parameter buffers (weights, biases).
Allocated at construction. Static for the component lifetime.
| std::size_t Mila::Dnn::MemoryStats::device_scratch_bytes { 0 } |
The execution context's forward scratch: one buffer shared by every operation on the context, sized by the largest single request.
Combined by maximum, never summed. Reserved when a network is built.
| std::size_t Mila::Dnn::MemoryStats::device_state_bytes { 0 } |
Forward and decode output buffers, KV cache.
Allocated at build(). Static after build().