---
title: "Scaling Model Evaluation at Pinterest with Ray (Part 4)"
description: "Pinterest fused model-evaluation metric computation into its Ray batch inference jobs, removing the separate Spark/Ray metrics job and the write-predictions-to-S3-then-reread handoff."
url: "https://swe.quest/articles/scaling-model-evaluation-at-pinterest-with-ray-part-4-ba1e956bb72b960e"
canonical: "https://medium.com/pinterest-engineering/scaling-model-evaluation-at-pinterest-with-ray-part-4-4a96cd12cc11"
source: "Pinterest Engineering"
published: "2026-11-04"
difficulty: "medium"
kind: "Case study"
reading_minutes: 11
tags: ["ml-platform","evals","recommendation-systems","data-pipelines","python"]
---

# Scaling Model Evaluation at Pinterest with Ray (Part 4)

A post on [Pinterest Engineering](https://swe.quest/sources/pinterest.md), published 2026-11-04, 11 min read, Case study. Original: [https://medium.com/pinterest-engineering/scaling-model-evaluation-at-pinterest-with-ray-part-4-4a96cd12cc11](https://medium.com/pinterest-engineering/scaling-model-evaluation-at-pinterest-with-ray-part-4-4a96cd12cc11)

## Summary

Pinterest fused model-evaluation metric computation into its Ray batch inference jobs, removing the separate Spark/Ray metrics job and the write-predictions-to-S3-then-reread handoff. The fusion relies on a metric contract (preprocess, compute partials per batch, reduce partials) that covers decomposable metrics like MAE, holistic metrics like ROC-AUC (approximated via per-threshold confusion matrices), and group-wise metrics like Precision@K. Group-wise metrics use Spark to pack complete segments into buckets so no segment spans a bucket. Overlapping CPU metric work with GPU inference via Ray's shared object store cut end-to-end evaluation time by 25–32% at 100 feature-importance experiments, with runtime scaling linearly in experiment count.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [ML platforms](https://swe.quest/tags/ml-platform.md) (AI & ML)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [Recommendations & ranking](https://swe.quest/tags/recommendation-systems.md) (AI & ML)
- [Data pipelines](https://swe.quest/tags/data-pipelines.md) (Data & databases)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Ray batch inference ([easy posts on Inference & serving](https://swe.quest/tags/inference.md?difficulty=easy))
- ML evaluation metrics like ROC-AUC ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))
- Apache Spark basics ([easy posts on Data pipelines](https://swe.quest/tags/data-pipelines.md?difficulty=easy))

## Keywords

Ray, Apache Spark, ROC-AUC, Precision@K, feature importance, Pinterest

## Related posts

- [Beyond Two Towers: Launching the 3-Tower Engagement Co-Train Model (Part 2)](https://swe.quest/articles/beyond-two-towers-launching-the-3-tower-engagement-co-train-model-part-2-9d501e5f993d9614.md): Pinterest Engineering · 2026-09-17 · Hard · 13 min read · Recommendations & ranking, Ads, Inference & serving, Performance engineering, Machine learning
  Pinterest's ads lightweight ranking adds a third cross tower to its two-tower engagement model.
- [Shopify's Playbook for Scaling Machine Learning](https://swe.quest/articles/shopify-s-playbook-for-scaling-machine-learning-01ef31091481dd96.md): Shopify Engineering · 2022-02-11 · Easy · 12 min read · ML platforms, Machine learning, Threat detection, E-commerce
  Shopify's approach to scaling machine learning grew out of its first ML product, an order fraud detector that replaced a rule-based system with a high false-positive rate.
- [Introducing Trackio: A Lightweight Experiment Tracking Library from Hugging Face](https://swe.quest/articles/introducing-trackio-a-lightweight-experiment-tracking-library-from-hugging-face-7dee3b3ee964ad19.md): Hugging Face · 2025-07-29 · Medium · 7 min read · ML platforms, Observability, Python, Open source
  Trackio is a free, open-source Python experiment tracking library that works as a drop-in replacement for wandb's init/log/finish API.
- [GEM Training: How Meta Doubled the Efficiency of Its LLM-Scale Ads Foundation Model](https://swe.quest/articles/gem-training-how-meta-doubled-the-efficiency-of-its-llm-scale-ads-foundation-1bf8547a323404ba.md): Meta Engineering · 2026-08-03 · Hard · 21 min read · Model training, Recommendations & ranking, Performance engineering, Hardware, Ads
  Meta doubled end-to-end training efficiency of GEM, its LLM-scale ads recommendation foundation model, to 20–25% MFU while scaling training FLOPs 4x in a year, by co-designing kernels, precision, parallelism, networking and memory.
- [F3 Lightning: How Meta Accelerates Ads ML Features to Production at Scale](https://swe.quest/articles/f3-lightning-how-meta-accelerates-ads-ml-features-to-production-at-scale-22b2343e1fb13d44.md): Meta Engineering · 2026-11-03 · Medium · 10 min read · ML platforms, Recommendations & ranking, Performance engineering, Deployment, Ads
  F3 Lightning decouples feature releases from shared execution in Meta's ads ML feature framework, so each of 20,000+ features is compiled, validated, deployed and rolled back independently instead of shipping as one all-or-nothing merged DAG.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
