Design: data engine for autonomous driving

In one sentence

Cars run new models in shadow mode and upload clips when triggers fire; offline, big models auto-label the hard cases, training closes the loop, and scenario regressions plus simulation gate a staged OTA rollout.

Triggers decide what leaves the car; mining and auto-labeling decide what gets learned; regression sets, simulation and shadow mode decide what ships.

How it works

  • Every trigger needs a sample rate and caps: once per car-hour on ~2M cars yields ~3 PB/day.
  • Mine the long tail with metadata queries, embedding similarity and active learning, then dedupe hard.
  • Offline auto-labelers can be far larger and see future frames; humans move from drawing boxes to fixing them.
  • The worst failure is a rare safety regression hidden by an average: gate on every safety slice, never the mean.
  • Each fixed failure becomes a permanent regression set; in rollout, watch takeovers and hard braking per 1,000 miles.

Check yourself

Answer to mark it learned; your answers aren't scored.

You push a new "detection flicker" trigger to the fleet. Two days later it is using most of the daily upload budget, and triage shows the clips are mostly near-duplicates from rainy nights. What do you change?

Go deeper

Do this round in 45 minutes System design round
Full explanation

A data engine is the loop that turns a deployed fleet into better models: find where the model is wrong, collect more of exactly that, label it, retrain, prove nothing regressed, ship, repeat. Tesla has described this pattern publicly (Autonomy Day 2019, Karpathy's CVPR 2021 keynote, AI Day 2021 and 2022); the sizing, gates and privacy pipeline below are a generic design, not Tesla internals.

Requirements

Functional: collect rare, informative clips from the fleet, not all video; let engineers define a new trigger and get examples back within days; label 3D objects, lanes and motion at scale; retrain; block any release that regresses a safety scenario; ship over the air in stages. Non-functional: ~2M cars (assumed), uplink mostly over home Wi-Fi, petabytes of video, per-region privacy law, every shipped model traceable to its data, a loop measured in weeks.

Questions I'd ask:

  1. Sensors and on-car compute: cameras only? Headroom to run a second network in shadow?
  2. Upload budget per car: Wi-Fi only, cellular for safety events?
  3. Consent and privacy: opt-in, regions, retention, deletion?
  4. Which tasks: perception only, or planning and control too?
  5. Who signs off a release, and which metrics are hard gates?

The highest-cost failure is a regression on a rare, safety-critical scenario hidden by an average: a better mean score that misses stopped emergency vehicles at night. Here the cost is injuries, not churn.

High-level design

  1. On the car: the candidate network runs in shadow mode next to the active one, without actuating. Triggers (shadow-vs-driver disagreement, driver takeovers, hard braking, detection flicker, a small rare-object classifier pushed OTA) snapshot a ~10 s ring buffer and queue it for Wi-Fi upload, under per-car caps.
  2. Ingest: check consent, blur faces and plates, coarsen GPS, then store clips in a data lake with a metadata and Embeddings index (trigger, model version, weather, place).
  3. Mining: queries and similarity search build a pool per failure mode; active learning ranks by uncertainty and disagreement (Training data quality & curation).
  4. Auto-labeling: large offline models that see the whole clip, past and future frames, label it; humans QA a sample (Human evaluation & annotation).
  5. Training on a large GPU cluster (Distributed training: DP, TP, PP, FSDP), then Knowledge distillation and Quantization (INT8, INT4, FP8) to fit the car's accelerator (On-device & edge inference).
  6. Gates: per-scenario regression sets, closed-loop simulation, shadow mode on the fleet, then a staged OTA rollout with an automatic halt.
Code A trigger campaign pushed over the air (illustrative schema)
yamlA trigger campaign pushed over the air (illustrative schema)
# Illustrative schema, not Tesla's: hunt one failure mode without shipping a new model
campaign: stopped-emergency-vehicle-night-v3
target: {fleet_fraction: 0.10, regions: [US, CA], hardware: [hw4]}
expires: 2026-12-15            # stale triggers keep eating upload budget
triggers:
  - name: shadow_brake_disagreement
    when: shadow.planner.decel_mps2 > 3.0 and ego.decel_mps2 < 0.5
    sample_rate: 0.2           # common event: keep 1 in 5
  - name: driver_takeover
    when: autopilot.engaged and driver.takeover
    sample_rate: 1.0
  - name: rare_object_head
    when: shadow.rare_head["emergency_vehicle_stopped"] > 0.8 and env.is_night
    sample_rate: 1.0
clip:
  window_s: [-8, 4]            # pre-event frames already sit in the ring buffer
  cameras: all
  signals: [can, imu, speed, gps_coarse]
limits:
  per_car_per_day: 2
  fleet_per_day: 20000         # fleet-wide quota across all cars
upload:
  network: wifi_only           # cellular only for crash and safety events
  max_age_days: 7
privacy:
  requires_opt_in: true
  on_ingest: [blur_faces, blur_plates, drop_vehicle_link]
Real example

Illustrative numbers. Triage of takeover clips finds the planner braking hard for delivery vans double-parked with hazards on: 40 examples. An engineer pushes a campaign (shadow-brake disagreement near a stopped van with hazards) to 10% of the fleet and runs a similarity search over the lake: 9,000 matching clips in 2 days, 6,000 more from the fleet in a week. The auto-labeler labels all 15,000; humans QA 750 (5%) and fix 4% of them. 150 human-verified clips become a frozen regression set. After a fine-tune, false braking on that set drops from 31% to 4%, and no other safety slice moves beyond its confidence interval. A week of shadow mode shows 80% less disagreement on the slice; the OTA rollout goes employees → 1% → 10% → 100%.

Trade-offs +4 · −4

+ You gain

  • Triggers spend upload and labeling budget on clips that teach something, not on hours of uneventful highway.
  • Offline auto-labels use future frames and multiple trips, so they beat what the on-car model can see, at a fraction of manual cost.
  • Every fixed failure becomes a permanent regression set, so old bugs can't silently return.
  • Shadow mode tests a candidate on real roads with zero actuation risk before any car obeys it.

− You pay

  • Triggers find what someone thought to look for; unknown unknowns need disagreement and novelty signals, which are noisier.
  • Petabytes of video, data loading and labeling dominate cost and engineering effort, more than the model itself.
  • Auto-labels inherit the labeler's blind spots; without human QA, its errors loop back as training targets.
  • The loop is slow: weeks from first failure to OTA, since every release must pass the full gate.

Use it when

A deployed fleet of devices (cars, robots, drones, cameras) that sees far more data than you can upload or label, where rare events matter most and the device can run a second model.

Avoid it when

A small fleet (a few hundred test vehicles: collect with dedicated drivers and label everything), devices that can't run triggers or a shadow model, or errors that are uniform rather than long-tailed.

Numbers to know 5
  • Clip size: Tesla's CVPR 2021 dataset was 1.5 PB for one million 10-second clips ≈ 1.5 GB per clip at training quality.
  • Budget: 2M cars × ~1 h of driving/day (assumed) = 2M car-hours; a trigger firing once per car-hour yields 2M clips ≈ 3 PB/day, 20× a 100k-clip budget.
  • Ingest: 100k clips/day × 1.5 GB = 150 TB/day ≈ 14 Gbps sustained, ~55 PB/year before tiering and expiry.
  • Training I/O: one pass over 1.5 PB at 1.6 TB/s (Tesla's 2021 NVMe tier) ≈ 16 min; at ~100 GB/s from object storage ≈ 4 h. Data loading, not FLOPs, can set epoch time.
  • Zero failures in n miles bounds the rate below ~3/n at 95% confidence; RAND (2016): ~275M failure-free miles to show a fatality rate no worse than the US human 1.09 per 100M miles.
Common pitfalls 4
  • Uncapped triggers: one noisy trigger (detections flickering in rain) fills the upload budget with near-duplicates. Cap per car and fleet-wide, sample, and dedupe by embedding.
  • Evaluating on auto-labels from the same labeler: its errors look like agreement. Keep evaluation and regression sets human-verified.
  • Gating on the mean: +1 point of average mAP can hide −10 on night-time pedestrians. Gate every safety slice, with confidence intervals.
  • Oversampling the rare slice too hard: the model fixes vans with hazards and regresses on ordinary merges. Mix by per-scenario quotas and watch base-distribution metrics.
Interview questions 3

Answer out loud first, then reveal.

Almost all driving is boring. How do you find the clips that matter?Show answer

I let the fleet tell me where the model is wrong instead of sampling uniformly. Shadow mode gives a free comparison on every trip: where the candidate disagrees with the driver or the active stack, or flickers frame to frame, I have a candidate failure. On top, engineers push targeted triggers, including small classifiers for a hunted object, with sample rates and caps so one noisy trigger can't eat the budget. In the backend, similarity search grows 40 examples into thousands. I judge each trigger by yield, the share of its clips that end up changing training or evals, and retire the ones that don't.

How do you decide a new model is safe to ship?Show answer

With layered evidence, because no single test proves rare-event safety: RAND's math says you'd need hundreds of millions of failure-free miles. First, hard gates: every safety-critical regression set passes within its confidence interval, not just the average. Second, closed-loop simulation of replayed and perturbed scenarios. Third, shadow mode on the fleet: the candidate's would-be actions compared with the shipped model's on real miles. Only then a staged rollout, employees, 1%, 10%, all, with takeovers and hard braking per 1,000 miles watched against control and an automatic halt. If any gate fails, the loop goes back to mining.

Your auto-labeler is a model too. How do you keep its mistakes out of the car?Show answer

I treat it as a model with its own evals and releases. It has advantages the car lacks, like future frames, multi-trip reconstruction and bigger networks, but shared blind spots are the risk: if both miss the same object, training agrees with an error. So humans QA a stratified sample, oversampling low-confidence clips and new triggers; I track label precision and recall per class on a human-verified gold set; evaluation and regression sets are never auto-labeled only. When the labeler changes, I re-label, diff the outputs and review the biggest changes before any training run uses them.

Deep dive 5

Shadow mode and triggers

In shadow mode the candidate network runs on real inputs but never actuates, so its decisions can be compared with the driver's or the active stack's on every trip. Triggers are small predicates over those outputs: disagreement, takeovers, hard braking, detections flickering between frames, sensor mismatch, or a cheap classifier for a hunted object. In his CVPR 2021 keynote, Karpathy said 221 hand-written triggers ran on Tesla's fleet to build its vision-only depth and velocity dataset, over seven shadow-mode rounds. The constraint is budget, not ideas: a trigger firing once per car-hour on 2M cars yields millions of clips a day. So every trigger carries a sample rate, per-car and fleet-wide caps and an expiry; it is versioned like code and judged by the share of its clips that reach training.

Mining the long tail

Almost all driving is uneventful, so uniform sampling buys hours of empty highway. Mining starts from a handful of failures and expands: metadata queries (night, rain, trigger X), similarity search over clip embeddings (Contrastive learning & CLIP), and active learning that ranks by ensemble disagreement, predictions that flicker over time, or shadow-vs-driver mismatch. Dedupe hard: a roundabout 500 commuters drive daily is one scenario, not 500. Then build the training mix with per-scenario quotas: upweight the rare slices but keep the base distribution, or the model gets better at vans with hazards and worse at ordinary merges. Simulation and synthetic variants cover what the fleet can't show often enough, like a child running onto a highway (Synthetic data).

Auto-labeling and human QA

The offline labeler isn't bound by the car's latency or compute: it can be much larger, see future frames as well as past ones, and fuse several trips through the same place into one 3D reconstruction. Karpathy described Tesla's 2021 dataset as labeled offline by very large networks, the old radar and human annotators: one million 10-second clips, 1.5 PB, 6 billion object labels with depth and velocity. Humans move from drawing boxes to fixing them: review a stratified sample, oversample low-confidence and new-trigger clips, and track label accuracy on a gold set. Auto-labels inherit the labeler's blind spots, so evaluation sets stay human-verified, and a labeler change is versioned and re-run like a data migration.

Evaluation, simulation and release gates

Every fixed failure becomes a permanent regression set, a unit test for the network: at AI Day 2022 Tesla showed a crossing car wrongly predicted as parked, fixed with a 126-clip evaluation set and 13,900 mined clips. Gate on every safety slice with confidence intervals, never on the mean (Offline vs online evaluation). Open-loop metrics aren't enough for planning: replay logs in closed-loop simulation with reactive agents and perturbed variants. Then shadow mode compares the candidate with the shipped model on real miles. Rollout goes in waves, employees first, then 1%, 10% and all, watching takeovers and hard braking per 1,000 miles against the previous version, with an automatic halt and an OTA rollback ready. Rare-event safety can't be proven by fleet miles alone: the evidence comes in layers.

Privacy, storage and cost

Clips hold faces, plates and locations: personal data under GDPR. Tesla's privacy notice makes camera data sharing an owner opt-in and says clips aren't linked to the vehicle, except after safety events such as a crash. Beyond that, the design is mine: check consent on the car, coarsen GPS, keep EU clips in an EU region, and blur faces and plates in everything humans see; raw pixels for training stay in a locked, short-retention tier, because blurred pedestrians can hurt detection. Deletion must reach raw clips, crops and caches (PII & data privacy). Storage is tiered: hot NVMe for the active training set (Tesla's 2021 cluster: ~10 PB at 1.6 TB/s feeding 5,760 A100s), object storage for the lake, cold archive beyond, and clips no dataset used expire.