Skip to content

Data pipelines: why the same command yields two different outputs

THE ARGUMENT

Reproducibility of a processing pipeline is decided by operator order, random sources and pinned versions together, and dropping any one makes recomputation impossible; what a delivery owes you is the config plus a manifest, with the output serving only as acceptance evidence.

On this page

The vendor sends a processing config and three lines of instructions: install the dependencies, run python run.py --config clean.yaml, expect roughly 1.06 million rows. You do exactly that and get 1,023,000. They got 1,061,000. Same config file, same input archives, a gap of thirty-eight thousand rows, 3.6 percent. Whose machine is wrong? Probably neither — the command never promised to produce the same result twice.

Start with the three-point-six percent

The numbers above (1,023,000 and 1,061,000) are invented to show the size of the gap, not taken from any real run. A discrepancy of a few percent is common in this setting and typically raises no error at all — both sides finish, both write files, both print a row count.

What makes this gap nasty is how quiet it is. A crash tells you immediately. A 3.6 percent difference makes you suspect you missed a shard, spend two days reconciling file lists, and find that the lists match perfectly.

Processing is unlike training in this respect. Training drift still converges to a similar model; processing drift means different data. And different data propagates: same evaluation set, same hyperparameters, two teams, two models — and part of the gap came from those thirty-eight thousand rows. Nothing in the chain announces that a fork occurred.

Breaking processing into operators solves a different problem

Systems like Data-Juicer break data processing into reusable operators, describe how those operators are chained into a pipeline through configuration, and support execution across a distributed cluster; they also provide analysers that compute dataset-level statistics which can drive the filtering rules.[1]

That design solves a practical problem. Processing used to live in hundreds of scripts, and nobody could say which step did what. Once broken into operators, every step has a name, parameters and an input-output boundary, and a pipeline becomes a file people can read, edit and pass around. That is a real engineering advance.[1]

It is not reproducibility. What the paper gives me is reusable operators and a configurable pipeline, which make processing describable. Between describable and two runs producing the same output sit three more things: order, randomness, versions. Leave any of them unstated and the same command yields two answers.

Concretely: if the config lists which operators to use but not in which order, then traversal order at the implementation level, dictionary ordering, and concurrent scheduling all change the result. A config can express intent, but not every source of uncertainty in execution — unless you write those uncertainties into the config too.

Five sources of drift and their symptoms

Laid out, the sources are five. The first two break the same command producing the same output; the last three break the pretence that it is the same command at all.

Source of driftTypical symptomHow to pin it
Operator orderDedup then filter versus filter then dedup often differ in row count: filtering changes the set that dedup seesDeclare the order explicitly and ship the config hash with the output
RandomnessSampling, approximate dedup and data mixing vary slightly run to runFix the seed and also fix the internal random source of approximate algorithms, or use a deterministic implementation
Code and dependency versionsResults change on another machine with no anomaly in the logsPin dependency versions and record the image digest, not the image tag
Upstream inputsThe path is unchanged but the content was replaced; row counts shifted quietlyRecord a hash and row count per input file and verify on receipt
Model-based operatorsA new language-ID or quality model moves the retained set wholesaleWrite the model name and version date into the config, not into a README

The first row deserves a note because it is the most often dismissed. Many people assume dedup-then-filter and filter-then-dedup differ only in efficiency. They do not: filtering first removes short texts that would otherwise have formed duplicate pairs, so the dedup set changes and what gets removed changes with it. Order is not an optimisation setting; it is part of the semantics.

The fifth row is recent. Language identification and quality scoring wrap a model, and when the model version changes the score distribution moves; the threshold stays the same while the pass rate does not. That drift is the hardest to find, because not a single character of the config has changed.

What a manifest shipped with the output looks like

For someone else to recompute your result you must hand over three things, and all three are required. The output itself, to verify content; the config, to describe intent; and a manifest, to pin the execution conditions. Most teams provide the first two. Almost nobody provides the third.

{
  "pipeline": "demo-clean-v3",
  "input": [
    {"path": "shard-0001.jsonl", "sha256": "sha256-of-shard-0001", "rows": 900000},
    {"path": "shard-0002.jsonl", "sha256": "sha256-of-shard-0002", "rows": 480000}
  ],
  "seed": 20261102,
  "ops": [
    {"name": "normalize_whitespace", "version": "1.2.0"},
    {"name": "filter_length", "version": "1.0.3", "params": {"min_chars": 200, "max_chars": 20000}},
    {"name": "filter_lang", "version": "2.1.0", "params": {"keep": ["zh", "en"]}, "model": "langid-x@2024-06"},
    {"name": "dedup_exact", "version": "1.0.0"},
    {"name": "sample", "version": "1.0.0", "params": {"rate": 0.9}}
  ],
  "output": {"rows": 1023000, "sha256": "sha256-of-combined-output"}
}

The manifest is invented; add or drop fields as your situation requires, but three cannot be omitted: input hashes and row counts, the seed value, and a version for every operator including model versions. With those three, another team can tell whether they ran the same command at all.

The numbers inside are also checkable. Two inputs total 1,380,000 rows; the output is 1,023,000 rows; retention is 74.1 percent. Retention is more useful than a row count because it compares across versions — counts move with the input, retention does not. If last release was 74.1 percent and this one is 71.2 percent, the rules got stricter, not the input smaller.

One more detail: the sampling operator at 0.9 is the most suspicious entry in the whole manifest. It is random and it runs last, so every small difference upstream gets amplified into part of those thirty-eight thousand rows. If two results differ by a few points, that is where I look first — but that is a hypothesis, not a substitute for comparing stage by stage.

How to verify at acceptance

  1. Have the vendor run the same command twice on the spot and compare row counts and hashes. If two runs differ, stop — that is not a configuration issue, the pipeline is not deterministic.
  2. Run it once on a different machine with a deliberately different core count and concurrency. If changing concurrency changes the result, ordering or aggregation carries hidden nondeterminism, which is the hardest kind to remove in production.
  3. Take only the config and the input manifest, and recompute from raw data yourself. This is the only way to separate genuinely reproducible from the output was copied again.
  4. Sample a hundred output rows and trace which operators each one passed and where it survived. If you cannot trace it, the operators keep no record and neither can you when something breaks.
  5. Ask for a version-to-version note: which category was removed, which was added back, and whether the row-count change reconciles. If it does not reconcile, something changed without being recorded.

Step three is the most expensive and the most effective. It requires the full config and input manifest, which hands over part of the processing capability, and many vendors refuse. Then step back: have them run it in their own environment while you watch, pick a shard at random and a subset at random, and see whether the result reconciles. The scope shrinks, but the question — can it be recomputed — still gets answered.

Full reproducibility costs money

Removing all uncertainty has a real price. Banning approximate dedup doubles memory and lengthens the run; pinning concurrency wastes a distributed cluster; freezing model versions means you cannot casually upgrade to a better language identifier. Reproducibility should therefore be graded, not treated as a binary compliance box.

A workable grading has three levels. Level one, byte-identical: the two outputs match exactly, the most expensive, appropriate for data that may end up in court or in a paper. Level two, same count and same sample: identical totals, identical content for a random ten-thousand-row sample, with order differences at shard boundaries tolerated. Level three, same distribution: counts within an agreed tolerance and no significant shift in key metrics. Most business cases need level two — and most vendors do not reach it.

One thing you can do immediately: at the next delivery, skip content validation and first ask the vendor to run the same command twice and send you the hashes of both output directories. Five minutes, and it filters out most pipelines that merely look reproducible. If the two hashes already differ, every later discussion about data quality is standing on unstable ground.

References

  1. Data-Juicer: A One-Stop Data Processing System for Large Language Models

Sign in to Padda

A code in your inbox. No password to remember.

Connecting to sign-in…