Skip to content

strategy

strategy

strategy.py Data Loading Strategy

AsyncStrategy(strategy: Strategy, kwargs: Dict[str, Any])

Asynchronous data loading strategy using threading.

Parameters:

Name Type Description Default
strategy Strategy

The underlying strategy to fetch batches from

required
kwargs Dict[str, Any]

Arguments to pass to strategy.get_batch()

required

get_batch() -> Any

Get the next batch. Blocks until a batch is available.

Returns:

Type Description
Any

PyTree containing batch data

Raises:

Type Description
Exception

If the worker thread encountered an error.

close() -> None

Stop the worker thread and clean up.

__del__() -> None

Cleanup when object is garbage collected.

Strategy(spec: ExecutionSpec, block_size: int, mixture: list[Sampling])