Building large-scale machine learning systems has taught me that preparing training data is often as challenging as training the model itself.

At smaller scales, we can think of training data as something we extract, clean and transform before handing it to a model. At petabyte scale, that mental model becomes inadequate. Data is distributed across systems built for different purposes. Each has its own representation of entities, update frequency, quality assumptions and ownership. A single training example may depend on information from several of them.

The challenge is not simply processing a large volume of data. It is producing training examples that are correct, reproducible and efficient to regenerate as the underlying data changes.

I want to explore the architectural decisions behind these systems, drawing on my experience with large-scale ML infrastructure and comparing approaches used inside Google with the open-source ecosystem.

What exactly is a training example?

Before choosing a processing framework, I would start with a more fundamental question: what is the unit of data we are trying to construct?

Consider a biological ML system that combines genomic variants, gene expression measurements, clinical observations and experimental metadata.

A training example might represent a patient, a biological sample, a particular experiment or a sample collected at a particular time. Those are not interchangeable.

One patient can have multiple samples. One sample can have multiple assays. Clinical observations may span several time points. A genomic variant may be associated with annotations that are updated independently.

If we decide that the training example is a sample, we need to establish which measurements belong to it, which patient it came from and which observations were available at the time of interest.

Choosing the unit of a training example determines the join keys, split boundaries and leakage risks before any distributed processing begins.

For a different problem, such as training a language model from web documents, the unit of data changes completely. We may need to reason about documents, duplicate passages, sources and token sequences. For image models, it might be an image and its annotations. For multimodal foundation models, it could be a collection of related objects rather than a flattened record.

The training workload should determine the representation, not the convenience of the data pipeline.

Designing splits and preventing data leakage

The next decision is what we want validation and test performance to mean. I would define this before building the splits.

Physical partitioning determines where data lives and how it is distributed for processing. Train, validation and test splitting determines which observations a model can learn from and which are reserved for measuring generalization. A stable hash of sample IDs may produce repeatable physical partitions, but it does not make evaluation independent.

In biomedical data, a random split by sample can look reasonable while putting multiple samples from one patient in different sets. Related patients may also share genetic information. Samples from the same institution can share batch effects or measurement artifacts. If these dependencies cross the train-test boundary, a model may appear to generalize when it is partly recognizing patterns already represented in training.

The split must follow the question we want to answer:

  • Patient-grouped split: keep repeated measurements and samples from one patient in the same set.
  • Relatedness-aware split: separate closely related individuals when shared genetics could make evaluation overly optimistic.
  • Temporal split: train on earlier data and evaluate on later observations to approximate prospective use.
  • Site or cohort holdout: reserve institutions, studies or collection environments to test performance under distribution shift.

We may need more than one of these at once. A patient-grouped split does not establish that a model will generalize to a new hospital or to future data. Stratification can maintain class balance, but it does not make related observations independent.

Leakage can also occur after the split. Imputation, normalization, feature selection, dimensionality reduction and target encoding must be fitted only on training data, then applied to validation and test data. Features must have been available at the moment the prediction would be made; retrospective labels, post-treatment observations or later corrections can quietly reveal the answer.

I would store split assignments as versioned artifacts linked to the data snapshot and splitting rules, then validate that patients and relevant groups do not overlap. Near-duplicates, shared identifiers, related individuals and time-order violations deserve explicit checks. The test set should remain separate from model selection; repeated tuning against it eventually turns it into another validation set.

The important question isn't simply whether training and test rows differ. It is whether the test set represents genuinely unseen information for the deployment question we care about.

Bringing heterogeneous data together

Once we define an example, the next challenge is constructing it from independent sources.

Imagine six systems containing sample metadata, sequencing results, genomic variants, expression measurements, phenotype annotations and cohort information.

They may use different identifiers for the same entity. Some data may arrive in database tables, while other data lives in object storage as large files. A correction to a sample identifier in one system may not immediately propagate to the others.

I would separate this into two logical steps: normalizing each source into a consistent representation and resolving the identities needed to join records.

The second deserves particular attention.

An unsuccessful join is not always an obvious failure. A pipeline may complete successfully while silently excluding samples whose identifiers did not match. A model may then train on an incomplete or systematically biased population.

Entity resolution should therefore be an explicit, versioned part of the pipeline. I would track unmatched records, conflicting identifiers, join cardinality and changes in join coverage between data versions.

The cost of distributed joins

A common operation is bringing records with the same key together. In MapReduce-style systems, a shuffle redistributes records across workers so that related data can be processed together.

At petabyte scale, moving records through the network, spilling intermediate data to disk and coordinating large joins can become expensive. Data skew makes matters worse: a handful of entities with extremely large associated records can dominate a stage even if other partitions are evenly balanced.

Some useful techniques include partitioning frequently joined data by common keys, broadcasting small lookup tables, aggregating before a shuffle and handling unusually large keys separately. Materializing stable intermediate results can sometimes eliminate repeated joins.

Four strategies for optimizing distributed joins: partition by join key, broadcast small tables, aggregate before shuffling and handle skewed keys.

Common strategies for reducing data movement and handling skew in distributed processing.

No single optimization is always right. I would want to understand data size, cardinality, skew, how frequently inputs change and the actual execution plan before deciding.

Flume, Beam and Spark differ in their programming and execution models. At petabyte scale, I would compare them based on shuffle volume, intermediate materialization, data skew and the cost of repeated computation.

Reproducibility and incremental recomputation

A training dataset is rarely constructed just once.

New examples arrive. Source records are corrected. Labels are revised. Feature definitions change. Quality filters evolve.

If two training runs use a dataset with the same name, can we establish whether they actually used the same information?

Reproducibility needs a lineage record: source snapshots, identity-resolution rules, feature-generation code, filters, split assignments and produced artifacts. Versioned table formats such as Apache Iceberg and Delta Lake help maintain consistent snapshots, but a storage snapshot is not enough. The same inputs can produce different features when transformation code changes.

Reproducibility is a property of the whole pipeline, not merely its output files.

When one source changes, what must be rebuilt?

Suppose a genomic annotation database corrects a subset of variants. Which examples depend on those annotations?

The simplest answer is to run the entire pipeline again. That may be reasonable for smaller datasets, but repeated full computation is expensive when the inputs are enormous.

An incremental pipeline attempts to identify affected outputs, recompute those examples and preserve unchanged results. This requires stable identities, dependency tracking and explicit handling of corrections and deletions so stale features do not remain in the training set.

Incremental computation has costs of its own. Fine-grained dependency tracking complicates design, testing and recovery. Sometimes rebuilding a larger partition is more reliable than maintaining exact record-level update state.

I would compare approaches using the rate of source changes, the cost of a full rebuild, the fraction of affected examples and the complexity of maintaining the incremental system.

Designing storage for the training workload

The storage format should reflect how a model consumes training data.

For tabular ML, a feature matrix with one row per example can work well. Columnar formats such as Parquet enable efficient scans across selected columns. Apache Arrow provides a columnar in-memory representation that supports processing and data exchange.

But neither guarantees an efficient training pipeline. Foundation models may consume text sequences, images, genomic sequences or variable-length multimodal examples. They may need randomized sample order, complete-example reads, sequential streaming or frequent access to small metadata fields.

Physical layout matters. Very small files create request and metadata overhead. Large files can make random access and recovery inefficient or restrict parallelism. Compression lowers storage and transfer costs but consumes CPU during decoding.

I would benchmark the complete path from storage to the training worker rather than optimizing file formats in isolation. Useful measurements include reader throughput, decoding cost, request volume, worker utilization, accelerator idle time and recovery after a failed job.

The goal isn't maximum storage throughput by itself. It is getting the right examples to the model without leaving training compute idle.

What changes at petabyte scale?

Most individual techniques are recognizable from smaller systems. What changes is the cost of mistakes and the difficulty of diagnosing them.

A join mismatch that drops a small fraction of records may exclude millions of examples. A feature computation that accidentally scans an entire dataset may consume substantial resources. A schema change can break consumers maintained by teams that never interact directly.

I would want to know more than whether a pipeline succeeded. Did it produce the expected number of examples? Did join coverage, missingness or feature distributions change? Are the split boundaries still valid? How stale is the output? Which stage is responsible when costs increase?

Operational ownership is part of the design. Source systems belong to teams with different schedules and incentives. If changes in schemas, identifiers or collection practices are only discovered when training results shift, the pipeline isn't observable enough.

Google infrastructure and the open-source ecosystem

Having worked with large-scale ML infrastructure at Google, I find it useful to compare the internal stack with the open-source tools available today.

There are strong conceptual similarities. Flume and Beam express distributed processing pipelines. Spark offers another programming and execution model for many of the same workloads. Columnar storage and table formats address efficient reads and consistent views of evolving data.

The important differences often appear in integration and operational maturity.

Within a large organization, common infrastructure can provide shared conventions for storage, schemas, orchestration, metadata, monitoring and resource management. With open-source components, a team can assemble similar capabilities, but the pieces do not automatically form a coherent platform. Choices about catalogs, data formats, orchestration, schema evolution and monitoring become explicit architectural responsibilities.

That flexibility is valuable, but it comes with integration and operational costs. I would resist declaring a single stack best without knowing the workloads and the infrastructure a team already operates.

What I take away

When reviewing a large-scale training-data architecture, I ask a few key questions.

What exactly is the training example? What claim does the evaluation split support? Can we trace each example to its sources? Can we detect leakage and silent data loss? What happens when sources change? How much computation are we repeating? Is the output organized for the model that will consume it?