Skip to content

Module: tide.storage

Snapshot storage helpers for backward propagation.

  • storage_mode_to_int
  • device: snapshots stay on compute device, fastest and most memory-heavy
  • cpu: host-backed storage, lower device memory use
  • disk: file-backed storage, smallest memory footprint and highest latency
  • none: disable snapshot storage

The user-facing APIs also accept auto, which chooses mode based on configured byte limits.

Maps mode strings to backend integer constants used by native kernels.

  • storage_compression supports none and bf16 on default compute path
  • bf16 storage is valid for float32 workflows

Application code should construct StorageOptions rather than call backend integer helpers:

storage = tide.StorageOptions(
mode=tide.StorageMode.CPU,
compression=False,
bytes_limit_device=None,
bytes_limit_host=None,
chunk_steps=0,
)

Internally, resolve_snapshot_storage converts this policy into an immutable SnapshotStorageSpec containing normalized mode, representation, sample count, and shot shape. SnapshotAllocator then owns the concrete device, host, or disk buffers. Disk allocations use tempfile.TemporaryDirectory; the allocator retains its lifetime and cleanup responsibility.

auto placement considers configured byte limits, not every allocation in the process. Reserve headroom for live fields, model gradients, optimizer state, receiver tensors, and runtime libraries. Validate the resolved mode during a small run before scaling the shot batch.