tf.data: A Machine Learning Data Processing Framework

Derek Gordon Murray, Jiri Simsa, Ana Klimovic, Ihor Indyk

Abstract

Modern machine learning (ML) models are increasingly bottlenecked by data ingestion rather than computation. As accelerators like GPUs and TPUs grow more powerful, the CPU-bound task of reading, augmenting, and batching data often fails to keep pace. This paper introduces tf.data, a declarative framework designed to unbottleneck ML input pipelines. By combining a high-level functional API with an optimizing runtime that automatically tunes parallelism and buffering, tf.data enables researchers to saturate hardware without manual performance engineering.

Introduction: The Input Pipeline Bottleneck

In the race for larger models and faster hardware, the "plumbing" of AI—the input pipeline—is frequently overlooked. Before a GPU performs a matrix multiplication, data must be fetched from storage, decrypted, decompressed, shuffled, and augmented. When these tasks are inefficient, expensive accelerators sit idle, a state known as being "input-bound."

Analysis of Google’s production fleet reveals the scale of this issue: approximately 20% of all ML jobs spend more than one-third of their total compute time solely on data ingestion. Historically, resolving these bottlenecks required manual tuning of thread counts and buffer sizes—parameters that are brittle and highly dependent on specific hardware configurations.

Cumulative fraction of jobs versus the fraction of compute time spent in the input pipeline.

System Design and Implementation

tf.data addresses these challenges through a two-tiered architecture: a declarative API and an optimizing runtime.

Declarative API

Users define pipelines by chaining functional transformations on Dataset objects (e.g., .map(), .batch(), .prefetch()). This approach creates a symbolic graph of the data flow. Because the pipeline is defined as a graph rather than imperative code, the system can reason about the entire process before execution begins.

Optimizing Runtime

The runtime applies both static and dynamic optimizations:

  1. Static Optimizations: The system performs graph rewrites, such as fusing map and batch operations, to reduce framework overhead.
  2. Dynamic Auto-tuning: The core innovation is an analytical model based on M/M/1/k queuing theory. The runtime monitors pipeline latency in real-time and uses gradient descent to automatically adjust parallelism and buffer sizes. This "AUTOTUNE" feature removes the need for manual performance knobs.

Evaluation and Results

The framework was evaluated using industry-standard MLPerf benchmarks (including ResNet-50 and Transformer) and a large-scale study of Google’s internal fleet.

Throughput and Efficiency

In isolated tests, tf.data achieved throughput speedups between 2.7x and 63x compared to sequential baselines. For end-to-end training, a ResNet-50 model saw a 10.4x decrease in the time required to reach target accuracy when using optimized pipelines.

Automated vs. Manual Tuning

A critical finding was that the automated tuning mechanism matches or exceeds the performance of "expert-tuned" pipelines. This allows researchers to focus on model architecture rather than low-level systems optimization.

Comparison of input processing speedups between expert-tuned and autotuned pipelines across various model architectures.

Key Insights from Fleet Analysis

The authors' analysis of millions of production jobs yielded several counter-intuitive insights:

  • The Value of Caching: Many jobs re-execute identical pipelines. Caching the top 10% of materialized datasets could reclaim 72% of the CPU resources currently dedicated to preprocessing.
  • Data Shrinkage: In 75% of jobs, the final "materialized" dataset is actually smaller than the raw data on disk due to filtering and feature extraction.
  • Non-determinism: While reproducibility is often prioritized, allowing non-deterministic data ordering can significantly improve performance by mitigating the impact of "straggler" nodes in distributed environments.

Conclusion and Future Directions

tf.data demonstrates that high-level abstractions can deliver superior performance by enabling system-wide optimizations. As accelerators continue to evolve, future work will likely focus on disaggregated data processing—moving preprocessing to dedicated clusters—and "pushing" filtering operations directly into the storage layer to conserve network bandwidth.

Summary updated

BibTeX
@article{murray2021tf,
  author = {Derek Gordon Murray and Jiri Simsa and Ana Klimovic and Ihor Indyk},
  title = {{tf.data: A Machine Learning Data Processing Framework}},
  journal = {Proc. VLDB Endow.},
  year = {2021},
  doi = {10.14778/3476311.3476374},
}
Figure