nemo_automodel.components.speculative.streaming.stores.shared_dir
nemo_automodel.components.speculative.streaming.stores.shared_dir
File-backed :class:FeatureStore for cross-process / cross-node streaming.
:class:SharedDirFeatureStore writes one <sample_id>.safetensors file
per produced sample into a shared directory. Reads return cloned
tensors the consumer can mutate; release deletes the file once
the last outstanding handle is dropped. Writes are atomic
(tmp file + os.replace) so a concurrent reader never observes a
partial write.
The store is the rendezvous for a multi-process run:
- Each process owns its own :class:
SharedDirFeatureStoreinstance pointing at the same shared directory. Producers write files; consumers in other processes materialize them bysample_idwithout needing a process-local ownership record. - The shared directory is the cross-process rendezvous; cross-rank
routing of which rank reads which
sample_idis left to distributed resharding layers above this store. - Distributed parallelism (FSDP / CP / EP) lives in the trainer’s forward / backward; this store is rank-local state plus a shared filesystem.
Backpressure is identical to :class:LocalFeatureStore: sample and
byte caps with the high / low-watermark hysteresis the queue reads.
Residency (:meth:health and the max_samples / max_bytes caps)
is scoped to the files this instance put, tracked in in-memory
counters. That keeps :meth:health off the filesystem hot path (the
queue polls it every poll_interval while a producer is paused) and
gives each rank its full configured budget instead of 1/N of a
directory-global measurement. Files other ranks wrote are not counted
here; disk-global capacity is the deployment’s responsibility.
Module Contents
Classes
Functions
Data
API
Bases: FeatureStore
:class:FeatureStore backed by one <sample_id>.safetensors per sample.
Thread safety: every public method holds a single
:class:threading.Lock. Cross-process / cross-node is supported
as long as distinct processes use distinct sample_id values;
the lock does not extend across processes.
Parameters:
Filesystem path used as the rendezvous. Created if it
does not exist. Concurrent producers and consumers in
separate processes / ranks coordinate via unique
sample_id values — collision is the caller’s problem.
Same residency contract as :class:LocalFeatureStore; the
queue’s HWM/LWM hysteresis reads them off
:meth:health.