Chapter 12
Training Data Platform and Release Engineering
On this page
- Data pipeline system design
- End-to-end design: speculative-decoding data
- Production readiness checklist
A data pipeline becomes a training platform when it can reproduce releases, absorb partial failure, enforce policy, explain examples, and connect every selected sequence to the models and evaluations that consumed it.
Data pipeline system design¶
Immutable objects carry payloads; a lineage catalog records how they were acquired and transformed. Selection combines versioned features with policy and mixture rules, then publishes a manifest that identifies the training inputs.
At large scale, the architecture should make the correct path reproducible and the incorrect path visible. Separate immutable payloads, metadata and lineage, distributed transforms, indexes, scores, release manifests, and policy decisions.
Logical architecture¶
1. Acquisition gateway¶
- authenticates sources and records source contracts;
- assigns source-revision and raw-content IDs;
- applies size, media, malware, and decompression limits;
- writes immutable raw objects and acquisition envelopes.
2. Metadata and lineage catalog¶
- stores source, rights, policy, schema, transform, and parent-child edges;
- supports forward and reverse impact queries;
- separates factual metadata from mutable review decisions.
3. Distributed transformation plane¶
- parses, normalizes, segments, detects language, and extracts structure;
- uses idempotency key
(input_id, transform_version, config_hash); - writes new immutable outputs rather than overwriting inputs.
4. Index and feature plane¶
- exact-hash tables, MinHash/LSH indexes, evaluation fingerprints, embeddings, and model-based scores;
- versions every model, seed, tokenizer, and threshold;
- keeps expensive features reusable across release candidates.
5. Selection and mixture plane¶
- applies policy eligibility, duplicate representative rules, quality weights, quotas, and deterministic sampling;
- produces a release manifest without copying payload bytes unnecessarily.
6. Tokenization and packing plane¶
- pins tokenizer and packing policy;
- records example-to-sequence spans and loss masks;
- prevents protected boundaries or access classes from merging.
7. Release registry¶
- stores manifest digest, shard digests, row and token statistics, lineage root, approvals, validation results, and supersession history;
- makes aliases such as
production-currentpointers to immutable versions, never mutable datasets.
8. Consumption and feedback¶
- training jobs resolve a manifest digest and emit consumed-shard receipts;
- evaluations, incidents, and serving failures create new metadata or candidate records rather than modifying the old release.
Immutable layers and materialization¶
A useful organization is:
- raw: source-faithful bytes and acquisition metadata;
- parsed: structured documents with recoverable boundaries;
- eligible: policy-approved, normalized records plus features;
- candidate release: selected IDs, scores, weights, and split assignments;
- published release: frozen manifest, tokenization, and validation report.
Not every layer needs a full physical copy. Content-addressed objects and manifests can share unchanged payloads. But logical immutability matters: rerunning a parser must create a new version even if most output bytes match.
Idempotence and partial reruns¶
For transform F_v:
output_id = H(input_id || F_v || config_hash || deterministic_seed).
Encode this tuple unambiguously with a transform-identity type tag, as in the source-identity contract in Chapter 9; raw string concatenation is insufficient.
A retry first checks whether that output already exists and verifies its digest. Generation identity includes generator checkpoint, decoding configuration, and per-record seed, but a seed alone does not guarantee identical outputs across execution backends. For nondeterministic transforms, use this identity as an idempotency key: publish one completed artifact atomically and retain its actual content digest. Retries reuse that artifact rather than silently replacing it with another sample.
Partition work by stable input IDs rather than worker count so changing cluster size does not reshuffle identity. Store per-partition completion manifests. A failed 10,000-partition job should rerun failed partitions, not rewrite successful output.
Idempotence does not imply semantic correctness. A broken normalizer can reproducibly corrupt every record; validation and version rollback are still required.
Capacity and yield example¶
Suppose acquisition begins with 100 million documents averaging 2 KiB of normalized text. Normalized payload alone is about 190.7 GiB. A 128-by-64-bit MinHash adds about 95.4 GiB before indexing.
Assume stage yields:
- parse success:
0.95; - policy eligibility:
0.98; - quality selection:
0.60; - exact-dedup representatives:
0.90; - near-dedup representatives:
0.80.
Expected retained documents:
100M * 0.95 * 0.98 * 0.60 * 0.90 * 0.80 ~= 40.2M.
This estimate sizes downstream scoring and tokenization. It is not a quality target: surprising yield changes should trigger investigation, not threshold adjustment to force the forecast.
If parsing sustains 100,000 documents per second, ideal compute time is 1,000 seconds, but end-to-end time also includes object reads, skew, shuffle, index writes, retries, and stragglers. Quote both compute throughput and wall-clock critical path.
Shuffles, skew, and backpressure¶
Exact deduplication groups by content hash; LSH groups by band key; balancing groups by domains. Each creates a shuffle. Hot keys from empty documents, boilerplate, or one enormous source can overload reducers.
Mitigations include:
- early quarantine of empty and low-information records;
- key salting with a second merge stage for hot buckets;
- size-aware partitioning;
- capped candidate postings and a separately audited overflow path;
- spillable external sorting;
- backpressure into acquisition rather than dropping records silently.
Dropping failed or slow partitions biases the dataset toward easy-to-parse sources. Completeness metrics must include missing source partitions and retry exhaustion.
Release validation¶
Every release candidate should pass gates:
| Gate | Required evidence |
|---|---|
| Integrity | Shard digests, schema validation, no missing partitions, deterministic sample replay |
| Rights and policy | Eligible source coverage, decision versions, unresolved-policy count |
| Composition | Documents, unique tokens, domains, languages, sources, time, lengths, and weights |
| Deduplication | Exact and near-duplicate rates, candidate recall audit, cluster-size tails |
| Quality | Score distributions, threshold precision, slice false-rejection audit |
| Leakage | Evaluation overlap by severity, source-family checks, private-registry scan |
| Safety and privacy | Classifier and sampled-review results, PII or secret handling |
| Training behavior | Small-pilot loss, capabilities, memorization, safety, and regressions |
| Reproducibility | Manifest reconstruction, transform versions, seeds, tokenizer, and packing |
Compare every metric to the previous release with explicit tolerances. A row-count drop of 20 percent, disappearance of a language, or sudden rise in average quality score can all indicate a pipeline bug.
Deletion, incident response, and model impact¶
Deletion is a state transition, not an object-store command:
- receive and authenticate a source or subject request;
- resolve matching raw and logical identities;
- mark future-use eligibility false;
- traverse descendants and release memberships;
- invalidate indexes, caches, pending jobs, and derived manifests;
- publish replacement releases;
- identify affected checkpoints and downstream artifacts;
- apply the model governance policy and record completion.
Removing data from future releases does not remove its influence from an existing model. Keep the model impact record separate: retraining, machine unlearning, access restriction, or documented residual exposure may be required by the applicable policy.
For a quality or leakage incident, preserve the faulty release for forensics, revoke its production alias, and roll consumers back to the last approved immutable manifest. Overwriting the bad version destroys evidence.
Observability¶
Monitor:
- documents, bytes, and tokens entering and leaving every stage;
- yield and error code by source, language, parser, and worker version;
- duplicate cluster sizes and hot LSH buckets;
- quality-score drift and slice retention;
- contamination matches and evaluation-registry access;
- synthetic generation yield, verifier disagreement, and cost;
- mixture weights, expected epochs, and effective sample size;
- lineage edge completeness and deletion service-level objective;
- release-to-checkpoint consumption.
Data bugs are often silent because a training job still receives valid tensors. Alert on distribution and lineage invariants, not only job failure.
End-to-end design: speculative-decoding data¶
Consider generating training data for a draft model used in speculative decoding. The draft should approximate the target model on the serving prompt distribution while being much cheaper to execute.
1. Contract¶
Each example contains:
- production-like prompt prefix and optional conversation state;
- target-model token distribution or sampled continuation under a pinned tokenizer;
- decoding configuration and target checkpoint;
- draft context limit and serving policy;
- provenance, privacy classification, and retention limit.
The goal is not to imitate arbitrary teacher prose. It is to improve target-token agreement and downstream acceptance under the exact speculative algorithm.
2. Acquisition and privacy¶
Sample consented or otherwise permitted prompt traffic with stable event IDs and bounded retention. Remove secrets and disallowed content through explicit policy gates. Add curated rare shapes: long prefixes, code, multilingual text, tool syntax, and safety-sensitive prompts.
Separate train, calibration, and final evaluation by user or conversation family and time. Do not let online acceptance metrics from the final holdout drive prompt generation repeatedly.
3. Generation¶
Run the pinned target model and store logits only when the training objective requires them; full-vocabulary logits are expensive. Alternatives include top-m logits plus residual mass, sampled target tokens, or online teacher inference. Record temperature and truncation because they change the target distribution.
Generate counterfactual prompt variants only when privacy and semantic-validity checks pass. Synthetic prompts receive generator-family IDs and separate mixture accounting.
4. Verification¶
Verify tokenizer identity, finite logits, probability mass, sequence alignment, stop-token handling, and reproducibility. Replay a sample through the target checkpoint. Deduplicate prompt families and scan against private evaluations.
The strongest downstream verifier is an offline speculative-decoding simulation that measures:
- target acceptance rate by proposed position;
- accepted tokens per target call;
- draft and target latency;
- distributional correctness of the final sampler;
- slice regressions and worst-case tails.
5. Balance and publish¶
Weight examples toward the serving prompt distribution, with floors for rare high-cost failures and caps on user, template, source, and synthetic family. Report effective epochs and ESS. Publish a manifest binding prompts, target outputs, tokenizer, objective, weights, and verification results.
6. Feedback loop¶
After deployment, join acceptance and latency telemetry back to coarse, privacy-safe slices. Add failure examples to the next candidate release, not directly to the training set. Require a fresh holdout gate before replacing the draft.
Production readiness checklist¶
Before publishing a training dataset, verify:
- contract: intended use, unit, tokenizer, rights, policy, retention, and owners;
- identity: source revision, raw and normalized hashes, duplicate and family IDs;
- transforms: pinned code, models, configs, random seeds, and resource limits;
- lineage: forward and reverse impact queries across synthetic and packed descendants;
- quality: label rubric, calibration, threshold operating point, bias and adversarial audits;
- leakage: frozen evaluation registry, multi-layer scan, split families, and residual risk;
- synthetic: generator/verifier independence, false-accept estimate, yield, novelty, and recursion depth;
- mixture: token-level weights, constraints, reuse caps, expected epochs, and ESS;
- release: immutable manifest, digests, validation report, rollback pointer, and approvals;
- operations: partial reruns, backpressure, deletion, incident response, cost, and monitoring.
A release platform earns trust when its artifacts support these claims through deletion, contamination, partial failure, and a changed mixture.