Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 8 min read Case study mediumAdept

A linear programming approach for optimizing features in ML models

Choosing which ML features to admit under limited infrastructure capacity can be framed as an integer linear program that maximizes model gain subject to per-service capacity constraints. Greedy picks by gain, or by gain per unit of storage, fall short once features consume several resources (storage, memory, CPU) and optional compression trades gain for capacity in another service. Meta's ads ranking team encodes these constraints with boolean selection variables in CVXPY. The same model is rerun across capacity values to quantify the marginal return on investing in each service and to map substitution tradeoffs between services, replacing a manual feature-approval process.

Assumes: linear programming basicsML feature engineeringNumPy/pandas

Related posts

  • Linear programming for fun and profit

    Modal mediumAdept

    Modal provisions GPU and CPU capacity across multiple clouds with a "resource solver" that formulates demand, prices, availability and per-instance limits as a linear program. It solves that program with Google's GLOP simplex solver from OR-Tools and outputs a delta of instances to spin up or down. Cheap preprocessing heuristics, such as pruning instance types, keep solves to fractions of a second rather than minutes, trading a little optimality for predictable scaling latency. Background workers make the actual cloud requests and feed observed capacity-limit failures back into later solves. The approach lets Modal exploit price arbitrage, such as H200s priced below H100s, and saves millions per year.

  • Intelligent Delivery: Making Every Unit of Compute Serve Better Ads

    Meta Engineering mediumAdept

    Meta's Intelligent Delivery is an ML-driven layer that allocates serving compute across requests, models, hardware fleets and ranking stages by predicting the marginal utility of each unit of compute, adding about 10% ads ranking performance since 2017. A shared Resource Core Model (6B sparse, 20M dense parameters) runs before retrieval and is fine-tuned into predictors of outcome, compute cost and latency, improving identification of high-impact requests by about 20% offline. A hierarchy of decision engines then routes traffic between regions, matches workloads to CPU/GPU/MTIA SKUs, and solves per-host constrained optimization under tail-latency SLOs. AI agents now propose and run about 20% of optimizations, cutting tuning cycles from months to weeks, with engineers approving every change.

  • Turning Opportunistic AI Inference Capacity Into Better Ads Recommendations

    Meta Engineering mediumAdept

    Meta aggregates locally idle inference capacity, stranded by peak provisioning, delivery timing, resource-ratio and accelerator-type mismatches, into a preemptible opportunistic pool used to improve ads recommendations. Two elasticity levers consume it: Rank More Ads (RMA) raises the number of candidates through the ranking stages and needs both CPU and accelerator surplus, while Serve Better Models (SBM) routes a larger share of requests to a more powerful model and needs only accelerator surplus. Baseline serving is protected by physical isolation for SBM and a logical global budget for RMA. A PID controller driven by tail latency sets RMA candidate volume, and an explore/exploit router picks SBM requests by request value. Because the central loops act on the order of minutes, millisecond-level value-aware load shedding on both servers and clients removes low-value optional work when capacity is suddenly reclaimed.

  • Design Once, Deploy at Scale: Building a Template-Driven ML Ecosystem

    Meta Engineering easyNovice

    Meta standardized its fragmented ads ranking model fleet into a small set of Standard Model Templates (SMT). These are opinionated, composable bundles of architecture, feature logic, training settings and hardware-aware serving configs, so that new techniques are tuned once on representative models and propagated to every model on a template. Multi-model optimization weighs aggregate gain against regression rate, then validates on held-out models before a technique enters the next template version. Over two years this cut per-model engineering time by 92%, shipped 80 techniques across 5000+ technique-model combinations, and delivered 0.63% average offline quality gain at neutral serving capacity plus 0.86% cumulative online lift. The templates also give AI agents a bounded search space for automated model improvement.

  • Network hose: Managing uncertain network demand with model simplicity

    Meta Engineering hardMaster

    Meta plans its backbone network capacity against per-data-center aggregate ingress/egress forecasts (the "network hose") instead of a pairwise traffic matrix. This cuts per-service forecast inputs from O(N^2) to O(N) and builds statistical multiplexing into the forecast. The hard part is that infinitely many traffic matrices satisfy the hose constraints. Meta handles this by deriving a small set of reference demand matrices from simple geographic (straight-line) network cuts, each maximizing traffic across its cut, and feeding them into an integer linear programming cost model under a failure protection policy. Simulations showed the extra capacity cost is small, while the approach lets services treat network as a per-data-center consumable and eliminates many pairwise traffic-surge alarms.

The quest for software engineering knowledge.

Look:
Layout: