How DeepETT Forecasts Traffic at Uber Scale

Peter Bubenik · Uber AI · · Source
How DeepETT Forecasts Traffic at Uber Scale

After studying this material, you should be able to:

  1. Explain how real-time traffic forecasting works at scale using deep learning
  2. Describe the architectural decisions behind a production ML system (DeepETT)
  3. Distinguish between resolution and calibration as forecast quality components
  4. Understand how segment-level predictions compound into trip-level outcomes
  5. Apply system design principles like fixed compute graphs, contracts, and real-time calibration to ML problems

Step-by-Step Study Guide

Step 1: Understand the Problem Domain

What is Traffic Forecasting?

Traffic forecasting means predicting how long it takes to drive each road segment at any given future time.

GPS Ping (every 4 seconds)
        ↓
Road Segment Traversal Time Measured
        ↓
Forecast Future Traversal Times (ETTs)
        ↓
Routing Engine Sums ETTs Along Route
        ↓
Arrival Time Estimate Delivered to Rider

Why Does It Matter?

Downstream SystemDepends On Traffic Forecasts
Route SelectionNeeds fastest path
Arrival Time (ETA)Sums segment ETTs
PricingReflects trip duration
Driver NavigationTurn-by-turn guidance

Key Insight: Traffic forecasting sits upstream of everything. Small improvements here compound across millions of trips daily.

Scale Context

  • ~100 million road segments globally
  • Tens of billions of GPS pings per day
  • Forecasts updated every few minutes
  • Up to 3-hour future horizons
  • 2 million predictions served per second

Step 2: Understand Why a New System Was Needed

The Old System's Limitations

The legacy system blended:

  • Recent observations
  • Historical patterns

This worked well but struggled in three specific scenarios:

Scenario 1: Rapidly Changing Conditions
├── Incidents, weather, major events
└── Old system reacts too slowly

Scenario 2: Sparse Roads
├── Outside dense urban areas
├── Few observations available
└── Old system lacks generalization

Scenario 3: Long Trips
├── Small segment errors multiply
└── Final ETA becomes significantly wrong

The Solution Direction

These gaps pointed toward deep learning because it can:

  • Adapt quickly to new patterns
  • Generalize across different geographies
  • Learn from massive data volumes

Step 3: Learn the Critical Scoping Decisions

Before any modeling began, two major decisions were made. Understanding why these decisions were made is as important as knowing what they were.

Decision 1: Separate Traffic Forecasting from Routing

Option A (Rejected): End-to-End Training

[Traffic Model] → [Routing Engine] → [Trip Outcome] → Optimize
  • Theoretically appealing
  • Practically risky: routing engine is complex and mature
  • Would massively expand project scope

Option B (Chosen): Clean Boundary

[Traffic Model] → outputs ETTs → [Routing Engine consumes them]
  • Simpler, lower risk
  • Faster to ship
  • Trade-off: cannot directly optimize trip-level metrics during training

Lesson: In production ML, shippability beats theoretical elegance.


Decision 2: Fixed-Size Input vs. Dynamic Graph

Option A: Dynamic Compute Graph (e.g., GNN)

Raw observations (variable count) → Model
Problem: Must downsample at scale → loses information

Option B: Fixed-Size Compute Graph (Chosen)

Pre-aggregated observations (fixed shape) → Model
Benefit: Predictable inference, uses all available data
PropertyDynamic GraphFixed-Size Graph
Input sizeVariableFixed
Downsampling neededYesNo
Inference latencyUnpredictableConstant
Production friendlinessHarderEasier

Lesson: System design constraints should drive architecture choices, not the other way around.


Step 4: Understand the Two Contracts

A contract defines exactly what the system promises to deliver. DeepETT has two:

Contract 1: Segment-Level Forecasts

Input:  Segment ID + Timestamp + Horizon (0–180 min)
Output: Expected traversal time (ETT) in milliseconds
Metric: Mean Squared Error (MSE)
Frequency: Every 5 minutes

Why MSE? Routing needs an expected value to make consistent fastest-path decisions. MSE optimizes for the mean, which is exactly what routing needs.

Contract 2: Trip-Level Forecasts

Input:  Sum of segment ETTs along a route
Output: Unrefined arrival time estimate
Metric: Mean Absolute Error (MAE)

Why is this harder?

Even if every segment prediction improves under MSE, the sum of those predictions is not guaranteed to improve under MAE at the trip level.

This is the segment-to-trip paradox — a critical concept explained in the next step.


Step 5: Master the Resolution vs. Calibration Framework

This is the most conceptually important section of the article.

Two Independent Components of Forecast Quality

Forecast Quality
├── Resolution  → Information content
└── Calibration → Systematic error

Resolution Explained

Resolution = How much of real-world variability does the forecast explain?

  • Reported as variance explained (%)
  • Higher is better (1.0 = perfect)
  • Decays as you forecast further into the future (naturally)
Example:
Segment-level resolution: ~30% variance explained
Trip-level resolution:    ~85% variance explained

Why the jump? Small gains at segment level COMPOUND across many segments.

Calibration Explained

Calibration = Are predictions systematically too high or too low?

Perfect calibration:
Predicted = Observed (flat residual line at y=0)

Poor calibration:
Predicted consistently 10% too high (curve drifts above y=0)

Key property: Calibration error can be corrected after training. Resolution cannot — it must be built into the model.

The Paradox Resolved

Segment MSE improves → Resolution improves ✓
                     → Calibration may drift ✗
                     → Trip MAE could worsen ✗

Solution strategy:

  1. Focus model training on maximizing resolution
  2. Fix calibration separately with a real-time calibration system

Step 6: Understand the Model Architecture

Data Pipeline: Spatiotemporal Views

Each road segment receives a fixed-size input matrix of views:

         │  Last Hour  │  Historical  │  Long-term  │
─────────┼─────────────┼──────────────┼─────────────┤
Segment  │     ✓       │      ✓       │      ✓      │
Neighbors│     ✓       │      ✓       │      ✓      │
Region   │     ✓       │      ✓       │      ✓      │

Why multiple fallback levels?

Dense urban road:
→ Model leans on recent segment-level observations

Sparse rural road:
→ Model shifts attention to neighborhood or regional aggregates

The model always receives the same shape of input but learns which views matter most in each situation.

Transformer Architecture

Each spatiotemporal view becomes a token:

View 1 (segment, last hour)    → Token 1 ─┐
View 2 (neighbors, last hour)  → Token 2  │
View 3 (region, historical)    → Token 3  ├→ Transformer Blocks → ETT Prediction
...                                        │
View N (context features)      → Token N ─┘

What the transformer learns:

  • "Real-time slowdown matters more than weekly pattern right now"
  • "This segment is sparse — rely on neighborhood data instead"
  • "It's a holiday — historical patterns don't apply"

Key Embedding Strategies

Feature TypeEmbedding Method
Segment IDsFeature hashing + in-model embeddings
Graph structurePre-computed message-passing embeddings
TimeMinute-of-week in local time
Holidays/EventsEvent embeddings + days until/since
Forecast horizonEmbedded as model input

One model answers both "right now" and "3 hours from now" queries by embedding the horizon as an input.


Step 7: Understand the Production Infrastructure

Data Pipelines

Apache Spark (Batch)
└── Precomputes historical and weekly feature aggregates

Apache Flink (Streaming)
└── Delivers real-time updates every few minutes

Serving Scale

Feature ingestion:  160,000 rows/second
Prediction serving: 2,000,000 predictions/second
Availability:       No downtime globally

Step 8: Understand Real-Time Calibration

The Problem That Emerged

After deployment, something unexpected happened:

Week 1 after retraining: Calibration error = Low ✓
Week 2: Calibration curve starts drifting
Week 3: Drift varies by city and time of day
Result: Downstream arrival time models degrade ✗

Why is drift dangerous?

Downstream model trained on:  "Forecast X means travel time Y"
After drift:                  "Forecast X now means travel time Z"
Result:                       Downstream model makes wrong predictions

Small segment-level miscalibrations snowball into large trip-level errors.

The Solution: Real-Time Calibration Pipeline

Step 1: Bucket forecasts by city into 10-minute travel-time bins
        ↓
Step 2: Join buckets with most recent observed traversal times
        ↓
Step 3: Learn correction factor
        ↓
Step 4: Apply correction → drives calibration error toward zero
        ↓
Result: Flat residuals, even during high-traffic events (e.g., NYE NYC)

Key Lesson: Calibrate once at training time = not enough. You need continuous, real-time calibration in production.


Step 9: Understand the Results

Measured Impact

MetricImprovement
Long-trip arrival time accuracy+6%
Forecast variance explained+19%
Navigation defects-2.73%
Annual revenue uplift~$100 million

Concrete Example

Same trip: Sao Paulo airport, 8:10am

Baseline system:
→ Route passes through slow city center segments
→ Arrival time error: 1.2 minutes

DeepETT:
→ Forecast captures slowdown patterns accurately
→ Route avoids congestion
→ Arrival time error: 2 seconds

Step 10: Synthesize the Key Lessons

Lesson 1: Define Contracts Before Writing Code

What does the model promise?
What metrics define success?
Where does the model's responsibility end?
→ Prevents scope creep, aligns teams

Lesson 2: Decompose Metrics into Resolution and Calibration

Resolution = can only be improved by better modeling
Calibration = can be fixed post-training
→ Focus model effort on resolution
→ Fix calibration separately and continuously

Lesson 3: Always Be Calibrating

Training-time calibration → drifts in production
Real-time calibration → stays locked
→ Especially critical when one model feeds another

Lesson 4: System Design Drives Architecture

Production constraints (latency, scale, reliability)
→ Fixed compute graph over dynamic GNN
→ Pre-aggregated views over raw observations
→ Transformer over recurrent model

Quick Reference Summary

DEEPETT IN ONE DIAGRAM

GPS Pings
    ↓
Road Segment Traversal Times
    ↓
Spatiotemporal Feature Aggregation (Spark + Flink)
    ↓
Fixed-Size Multi-View Input Matrix
    ↓
Graph-Aware Transformer (DeepETT)
    ↓
Segment ETT Prediction
    ↓
Real-Time Calibration (Flink)
    ↓
Calibrated ETT → Routing Engine
    ↓
Route Selection + Arrival Time Estimate
    ↓
Rider Experience

Self-Check Questions

  1. Why does segment-level MSE improvement not guarantee trip-level MAE improvement?
  2. What is the difference between resolution and calibration? Which can be fixed post-training?
  3. Why was a fixed-size compute graph chosen over a dynamic GNN?
  4. Why does the transformer treat each spatiotemporal view as a token?
  5. What causes calibration drift, and how does the real-time Flink pipeline address it?
  6. Why was end-to-end training with routing in the loop rejected?

More to study