Foundations to Frontier
Tests
C. Programming, Tools and HPC › C7 Scientific Data Formats

Data Versioning with DVC

Code is versioned with Git, but datasets, models and experiment outputs are too large for it, and an ML or analysis result is only reproducible if you know exactly which data produced it. Data versioning tools keep small metadata files in Git that point to content-addressed copies of the data in a cache and remote storage. This topic covers DVC's model (.dvc files, cache, remotes, pipelines with dvc.yaml and dvc.lock, experiments), content addressing and deduplication, alternatives (Git LFS, lakeFS, Delta Lake/Iceberg, Xet) and practical workflows. In the exercises you build a miniature DVC with a content-addressed cache, directory manifests, push and pull that transfer only missing objects, and a pipeline that reruns only stale stages; then you measure how much storage and transfer eight dataset versions cost under full copies, file-level addressing, fixed-size blocks and content-defined chunking.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Git for data, without putting data in Git

Imagine labelling a library’s books by a fingerprint of their contents instead of by title. If two copies are identical they get the same fingerprint, so you only keep one, and a small card in your notebook (“the dataset for experiment 7 is fingerprint 3f9a…”) is enough to get exactly that data back years later. DVC does this: Git stores the small cards, and a cache or cloud bucket stores the data under its fingerprints.

Fixed blocks versus content-defined chunks
chunking:
version 1 (9 chunks)
time,temp,volt⏎0,20.1,12.0⏎1,20.4,12.1⏎2,20.9,11.9⏎3,21.3,12.0⏎4,21.0,12.2⏎5,20.6,12.1⏎6,20.2,11.8⏎7,19.9,12.0⏎8,19.7,12.1⏎9,19.8,12.3⏎
version 2 (9 chunks, orange = not already stored)
time,temp,volt⏎0,20.1,12.0⏎1,220.0,0.4,12.1⏎2,20.9,11.9⏎3,21.3,12.0⏎4,21.0,12.2⏎5,20.6,12.1⏎6,20.2,11.8⏎7,19.9,12.0⏎8,19.7,12.1⏎9,19.8,12.3⏎
new bytes to store and transfer: 41 of 140 for an edit of 5
With fixed blocks, every block after the insertion shifts and must be stored again. Content-defined chunking places boundaries where the hash of the last 4 bytes is divisible by 12, so after the edit the boundaries realign with the old ones and only the chunks around the change are new. File-level versioning (DVC, Git LFS) would store the whole file again.
Why engineers care

A flight-software ML model or a mission-analysis result must be traceable to the exact telemetry, simulation runs and labels it came from. Versioning data like code makes results reproducible and auditable, and stops “final_v3_really_final.csv”.

📝 Quick check (Level 0)
0/3 answered
  1. 1. What does Git store when you use DVC?
  2. 2. Two identical files under content addressing are stored…
  3. 3. In the demo, an insertion with fixed blocks…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The DVC workflow

git init && dvc init
dvc add data/telemetry.parquet          # → data/telemetry.parquet.dvc (commit to Git); file moved to the cache
git add data/telemetry.parquet.dvc data/.gitignore && git commit -m "Add telemetry v1"
dvc remote add -d storage s3://lab-bucket/dvc
dvc push                                 # upload cache objects the remote lacks
# later, on another machine
git clone … && dvc pull                  # fetch data for the checked-out commit
git checkout v1.0 && dvc checkout        # time-travel data together with code

A .dvc file is small YAML: outs: - md5: 3f9a…, size: 52428800, path: telemetry.parquet. The cache stores the object at .dvc/cache/files/md5/3f/9a…; directories get a .dir manifest listing each file’s hash.

📝 Quick check (Level 1)
0/3 answered
  1. 1. dvc push uploads…
  2. 2. To get the data matching an old commit:
  3. 3. A tracked directory is described by…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Content addressing

An object’s key is a hash of its bytes (MD5 in DVC, SHA-256 in Git LFS and most newer systems). This gives deduplication across files and versions for free, integrity checking on every read, and immutable, cache-friendly storage. Updating a version transfers only objects the other side lacks.

Pipelines

dvc.yaml declares stages (cmd, deps, outs, params, metrics); dvc.lock records the hashes of every dependency and output after a run. dvc repro walks the DAG in topological order and reruns a stage only if its recorded hashes no longer match. If an upstream stage reruns but produces an identical output, downstream stages are skipped. dvc exp run runs parameter variants as lightweight experiments.

stages:
  prepare: {cmd: python prepare.py, deps: [raw.csv, prepare.py], outs: [clean.parquet]}
  train:   {cmd: python train.py, deps: [clean.parquet, train.py], params: [lr, epochs], outs: [model.pt]}
  evaluate: {cmd: python eval.py, deps: [model.pt, clean.parquet], metrics: [metrics.json]}
🐍 Exercise 1: a miniature DVC
Hash files into a content-addressed cache and return .dvc metadata; track directories with a manifest; check out with hash verification; report status; push and pull only missing objects; order pipeline stages topologically (detecting cycles) and rerun only stages whose dependency or output hashes changed.
📝 Quick check (Level 2)
0/3 answered
  1. 1. dvc repro reruns a stage when…
  2. 2. An upstream stage reruns and produces identical output; downstream stages…
  3. 3. Integrity check on checkout compares…

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Choosing a tool

Tool Granularity Strength
DVC files and directories, Git-based metadata ML pipelines, experiments, any storage backend
Git LFS files, pointer files in Git simple, supported by Git hosts
lakeFS Git-like branches over object storage atomic commits for data lakes
Delta Lake / Apache Iceberg table snapshots, row-level changes time travel for Parquet tables (C7.1)
Xet, restic, borg content-defined chunks deduplicate edits inside large files

Practices. Version raw data immutably and derive everything else through a pipeline. Pin data versions in experiment tracking (MLflow, W&B) by hash. Keep many small files packed (C4.1, C6.7). Prefer append-friendly formats or partitioned tables for growing data, so new versions add files instead of rewriting them.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Best fit for versioning a large, growing Parquet table with row updates?
  2. 2. Why partition growing data into new files?
  3. 3. Tools that deduplicate edits inside large files use…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Versioning costs, measured

Exercise 1. Adding a CSV stores it once under files/md5/xx/…; a byte-identical copy adds no object; a corrupted cache object is caught on checkout. A three-file directory with one duplicate is stored as two objects plus a manifest. A second push of the same version sends 0 bytes; adding one 70-byte image sends only it and the new manifest. In the pipeline, appending a row that cleaning removes reruns only prepare; appending a valid row reruns all three stages; deleting metrics.json reruns only evaluate.

Exercise 2: eight versions of a dataset (start: 150 binary files with log-normal sizes, mean about 16 kB, plus a 20 000-row telemetry CSV, 2.7 MB in total). Each update adds 10 files, deletes 3, inserts 100 bytes into 8 files, corrects one CSV value mid-file (changing its length) and appends 1 000 rows. Chunk hashes use SHA-256; CDC uses a Gear rolling hash with 8 KiB average chunks (2–64 KiB).

Method Stored after 8 versions Transfer per update Objects
full copy per version 24.97 MB 3 176 kB 1 404
file-level content addressing (DVC, Git LFS) 7.48 MB 676 kB 278
fixed 8 KiB blocks 5.72 MB 425 kB 832
content-defined chunks 4.37 MB 232 kB 622

The truly new content per update is about 180 kB (ten new files and 1 000 rows). File-level addressing removes the copies of unchanged files (3.3× less storage), but each update still re-sends the whole CSV and every edited file. Fixed blocks dedupe the CSV’s unchanged start, but an insertion shifts every later block. Content-defined chunks realign after edits, so each update transfers within about 30% of the new content (2.9× less than file-level), at the cost of more, smaller objects to index. For tabular data the same effect is usually obtained more simply by appending new Parquet files or using a table format.

🐍 Exercise 2 (research): storage and transfer of dataset versions
Generate eight evolving versions of a dataset; store them as full copies, with file-level content addressing, with fixed 8 KiB blocks and with content-defined chunks from a vectorised Gear rolling hash; measure total storage, bytes transferred per update and number of objects.

Data versioning in AI, robotics and aerospace

  • ML datasets and models: DVC or lakeFS for training data, with model registries recording the data hash for each model.
  • Robotics logs: large bag and MCAP recordings versioned by content, with curated subsets defined as manifests.
  • Mission data: reproducible processing chains (calibration pipelines) where each product records the hashes of its inputs, as in provenance standards like W3C PROV.
  • Simulation campaigns: parameter sweeps tracked as experiments with versioned inputs and outputs.

References

  1. DVC documentation (dvc.org/doc): data management, pipelines, experiments.
  2. A. Muthitacharoen, B. Chen, D. Mazières (2001). “A low-bandwidth network file system.” SOSP (content-defined chunking with Rabin fingerprints).
  3. W. Xia et al. (2016). “FastCDC: a fast and efficient content-defined chunking approach for data deduplication.” USENIX ATC.
  4. M. Armbrust et al. (2020). “Delta Lake: high-performance ACID table storage over cloud object stores.” PVLDB 13(12).
  5. Git LFS specification (git-lfs.com); lakeFS documentation (docs.lakefs.io).
  6. M. D. Wilkinson et al. (2016). “The FAIR Guiding Principles for scientific data management and stewardship.” Scientific Data 3, 160018.