nvalchemi.dynamics.HostMemory#

class nvalchemi.dynamics.HostMemory(capacity)[source]#

CPU-resident buffer for storing batched atomic data.

This buffer ensures all data is stored on CPU memory, regardless of the input batch’s device. It is useful for staging data before disk I/O or for CPU-side processing.

Parameters:

capacity (int) – Maximum number of samples to store.

capacity#

Maximum storage capacity.

Type:

int

Examples

>>> host_buffer = HostMemory(capacity=1000)
>>> host_buffer.write(gpu_batch)  # Data moved to CPU
>>> cpu_batch = host_buffer.read()
__init__(capacity)[source]#

Initialize the host memory buffer.

Parameters:

capacity (int) – Maximum number of samples to store.

Return type:

None

Methods

__init__(capacity)

Initialize the host memory buffer.

drain()

Read all stored samples and clear the sink.

read()

Retrieve all stored data as a CPU-resident Batch.

write(batch[, mask])

Store a batch of atomic data on CPU.

zero()

Clear all stored data and reset the buffer.

Attributes

capacity

Return the maximum storage capacity.

global_rank

Return the global rank of this data sink.

is_full

Check if the buffer has reached capacity.

local_rank

Return the local rank of this data sink.