Utilities

September 17, 2026 ยท View on GitHub

Utility modules providing common functionality across Datarax. These are low-level helpers used internally and available for advanced use cases.

Available Utilities

UtilityPurposeKey Functions
PyTree UtilsBatch tree operationsBatch size, split, concatenate
ExternalLibrary adaptersIntegration helpers
CacheDataset cache layoutResolve/structure cache dirs
MultirateSignal alignmentAlign streams at different rates

!!! note "Key points"

- PyTree utils operate on `Element`/`Batch` structures
- Use these for custom operators and extensions
- Randomness helpers live in the core layer: [prng](../core/prng.md)

Quick Start

from datarax.utils.pytree_utils import get_batch_size

# Inspect a batch produced by a pipeline
size = get_batch_size(batch)

Modules

  • pytree_utils - Batch PyTree manipulation and transformation
  • external - External library adapters and integrations
  • cache - Dataset cache-layout helpers
  • multirate - Multirate signal-alignment helpers

Batch PyTree Operations

from datarax.utils.pytree_utils import (
    add_batch_dimension,
    split_batch_for_devices,
    concatenate_batch_sequence,
)

# Promote a single element to a batch of size 1
batch = add_batch_dimension(element)

# Split a batch across devices, then recombine
shards = split_batch_for_devices(batch, num_splits=4)
merged = concatenate_batch_sequence(shards)

See Also