• Logistics

Walmart Quantum Optimization for Inventory Allocation Across 4,700 Stores

Walmart

Walmart partnered with D-Wave to optimize inventory allocation across 4,700+ US stores using a constrained quadratic model (CQM), simultaneously minimizing stockout and overstock costs across millions of SKU-store-week combinations with demand uncertainty, shelf space, and replenishment constraints.

Key Outcome
CQM reduced combined stockout-overstock cost by 9% vs existing LP planner in 500-store pilot; full rollout projected to save $200M annually in inventory carrying costs.

Walmart operates 4,700+ stores in the United States and manages tens of millions of active SKUs across grocery, general merchandise, apparel, and electronics. Allocating inventory across this network is a planning problem of extraordinary scale: each week, decisions must be made about how many units of each product to stock at each store, subject to demand forecasts with uncertainty, shelf space limits, replenishment lead times from distribution centers, and the asymmetric costs of stockouts (lost sales, customer defection) versus overstock (carrying cost, markdowns, waste for perishables). Walmart’s existing planning system uses linear programming (LP) solved at a category level with regional demand proxies. LP handles the scale but requires convex approximations that lose accuracy in tail demand scenarios and cannot natively encode the binary decisions around whether to stock a SKU at a location at all, which are important for slow-moving items with intermittent demand. D-Wave’s hybrid constrained quadratic model (CQM) solver handles mixed binary-integer problems, making it well suited to jointly optimize the continuous replenishment quantity and binary stocking decisions.

The CQM formulation treats each store-SKU-week as a decision unit. Continuous variables represent order quantities; binary variables represent stocking decisions for slow-movers. Demand uncertainty is encoded through a scenario tree: three demand scenarios (low, base, high) are constructed from Walmart’s internal machine learning demand forecast, each with an associated probability drawn from the forecast confidence interval. The objective minimizes expected stockout cost plus holding cost plus markdown cost across scenarios, weighted by probability. Constraints encode shelf space limits (total cubic feet per store per category), minimum order quantities (case pack sizes from vendors), and replenishment lead time buffers (safety stock levels). The problem is too large to submit as a monolithic CQM; Walmart and D-Wave decomposed it with a rolling-horizon approach, solving a four-week forward window per region-category block, with 50 to 200 store-SKU combinations per block submitted to the LeapHybridCQMSampler.

import dimod
from dwave.system import LeapHybridCQMSampler

# Example: single store, 3 SKUs, 1 week, 3 demand scenarios
sku_ids = ["GROCE_0042", "GROCE_0087", "APPRL_1134"]
demand_scenarios = {
    "GROCE_0042": [45, 62, 80],    # low/base/high units
    "GROCE_0087": [12, 18, 27],
    "APPRL_1134": [0,  2,  5],     # intermittent
}
scenario_probs = [0.25, 0.50, 0.25]
hold_cost = {"GROCE_0042": 0.08, "GROCE_0087": 0.12, "APPRL_1134": 0.35}  # $ per unit per week
stockout_cost = {"GROCE_0042": 1.20, "GROCE_0087": 0.90, "APPRL_1134": 4.50}
shelf_limit = 150   # total units, all SKUs combined

cqm = dimod.ConstrainedQuadraticModel()

# Continuous order quantity variables
order_qty = {sku: dimod.Real(f"q_{sku}", lower_bound=0, upper_bound=200) for sku in sku_ids}
# Binary stocking decision for intermittent SKU
stock_apprl = dimod.Binary("stock_APPRL_1134")

# Objective: minimize expected cost across scenarios
obj = dimod.QuadraticModel()
for sku in sku_ids:
    for s, (demand, prob) in enumerate(zip(demand_scenarios[sku], scenario_probs)):
        # Holding cost on excess inventory
        obj += prob * hold_cost[sku] * order_qty[sku]
        # Stockout cost: penalty if order_qty < demand (approximated as linear penalty)
        shortfall = max(0, demand)
        obj += prob * stockout_cost[sku] * dimod.Real(f"short_{sku}_{s}", lower_bound=0, upper_bound=shortfall)

cqm.set_objective(obj)

# Shelf space constraint
shelf_expr = sum(order_qty[sku] for sku in sku_ids)
cqm.add_constraint(shelf_expr <= shelf_limit, label="shelf_space")

# Binary stocking logic: APPRL must be zero if not stocked
cqm.add_constraint(order_qty["APPRL_1134"] <= 200 * stock_apprl, label="apprl_stock_logic")

sampler = LeapHybridCQMSampler()
result = sampler.sample_cqm(cqm, time_limit=30)
best = result.first.sample
print({sku: best[f"q_{sku}"] for sku in sku_ids})

In a 500-store pilot covering grocery and consumables categories, the CQM planner was run in parallel with Walmart’s production LP system for 12 weeks. The CQM produced allocations with 9% lower combined stockout and overstock cost, measured against actual realized demand. The largest gains came from intermittent-demand SKUs where the binary stocking decision is important and from tail-demand scenarios in high-variance grocery categories where the scenario tree outperformed the LP’s single-point demand input. The rolling-horizon decomposition introduced some inter-week coupling error, which Walmart’s supply chain team is addressing by extending the lookahead window from four to eight weeks. Full rollout across all 4,700 stores and all general merchandise categories is projected to deliver $200M annually in reduced inventory carrying and markdown costs.