Skip to main content
Adaptive Harmony provides common utilities for efficient concurrent processing of data. Use these functions to parallelize model inference, grading, and other async operations in your recipes.

async_map

Process all items concurrently with automatic progress tracking:
All tasks run concurrently. Progress is tracked automatically.

async_map_fallible

Same as async_map but silently skips failures instead of crashing. Failed samples are excluded from results
Use when you expect some samples to fail and want to continue processing the rest.

batch_process_fallible

Process items in controlled batches with failure handling:
Returns list[tuple[int, T]] where the int is the original index in the input data. Use this to track which samples succeeded. When to use:
  • Large datasets where running all at once would exceed memory
  • Want to report progress in batches
  • Need to preserve sample indices

async_map_batch

Process an iterator in batches with automatic retry on failure:
Parameters:
  • f - Async function to apply
  • data - Iterator (not list) of items
  • batch_size - Number of items per batch
  • max_failure_fraction - Max fraction of failures before raising exception (default 0.5)
Behavior:
  • Processes batch_size items concurrently
  • If a sample fails, pulls next item from iterator and retries
  • Fails if more than max_failure_fraction * batch_size samples fail
  • Results are not ordered
Use when:
  • Working with iterators
  • Want automatic retry with fresh samples on failure (as in training, where batch size must remain constant)
  • Don’t need to preserve ordering