search_ads_recsys / 25 · multi-agent rl lesson 25 / 39

Multi-agent reinforcement learning

Single-agent RL assumes one decision-maker in a world that holds still while it learns. The moment a second learner shares that world, the ground moves: each agent's policy update silently rewrites every other agent's environment. The Markov guarantees you leaned on in lesson 16 quietly stop holding. This lesson is about what breaks, why, and the narrow set of cases where the cure is worth its price.

The limit this lesson removes
Lesson 16 framed recommendation as one agent maximizing a discounted return against a fixed (if unknown) environment P(s′|s,a). That stationarity assumption is load-bearing — it is what makes the Bellman fixed point exist and Q-learning converge. But a real ad system has many learning decision-makers at once: a retrieval stage, a ranking stage, thousands of auto-bidding advertisers. Each one's transition and reward distributions are a function of what every other agent is currently doing. From any single agent's seat, the environment is no longer stationary — it is a moving target shaped by other minds that are also moving. That is the entire problem multi-agent RL (MARL) exists to confront.

Where the agents actually are in a recsys / ads stack

"Multi-agent" sounds abstract until you name the agents in a system you already know. Three concrete groupings recur, and an interviewer wants you to reach for them immediately:

Why independent learners fail

The tempting first move: give each agent its own DQN or PPO, let each treat everyone else as part of "the environment," and train them all at once. This is independent learning (e.g. IQL — independent Q-learning), and it fails for two compounding reasons.

1 · Non-stationarity

From agent i's view, the effective transition is P(s′ | s, aᵢ, a₋ᵢ) — it depends on every other agent's action a₋ᵢ. While the others are also learning, a₋ᵢ's distribution keeps changing, so the environment agent i sees is non-stationary. The Bellman target it bootstraps toward is computed against opponents that no longer exist by the time the update lands. Convergence guarantees evaporate; experience replay makes it worse, because replayed transitions were generated by stale opponent policies that misrepresent the current game.

2 · Multi-agent credit assignment

If the agents share a team reward, each one faces a harder version of the credit problem from lesson 16: not just "which of my past actions earned this reward?" but "of the joint reward we all just received, how much was me?" A lazy agent can free-ride on a good teammate and still see high reward — the gradient cannot tell them apart. Independent learners have no mechanism to disentangle individual contribution from the team outcome.

The non-stationarity trap, stated precisely
Single-agent RL works because the environment is a fixed (if unknown) function you can sample until the estimate converges. With several simultaneous learners, the function you are estimating changes every time anyone updates — including you. You are no longer hitting a stationary target; you are chasing a target that flinches every time you reach for it. No amount of more data fixes a moving distribution. This is why "just run a DQN per agent" looks fine in a single-agent unit test and oscillates or diverges the instant the other learners are turned on.

The dominant fix: centralized training, decentralized execution

CTDE is the paradigm that organizes nearly all practical cooperative MARL. The idea is a clean asymmetry between train time and serve time:

Why does this resolve non-stationarity? Because the critic — the thing that defines the learning target — conditions on a₋ᵢ explicitly. Once the other agents' actions are inputs to the value function rather than hidden noise folded into the environment, the target is again a well-defined, stationary function of its inputs. The environment stops looking non-stationary to the critic precisely because the moving part (everyone else's actions) is now observed, not marginalized away.

CENTRALIZED TRAINING │ DECENTRALIZED EXECUTION │ ┌──────────────────────────────────────────┐ │ │ CENTRALIZED CRITIC Q(x, a₁ … a_N) │ │ (critic discarded │ sees joint state x + ALL agents' actions │ │ at serving time) └────────┬───────────┬───────────┬──────────┘ │ gradient │ │ │ gradient │ ▼ ▼ ▼ │ ┌───────┐ ┌───────┐ ┌───────┐ │ ┌───────┐ ┌───────┐ ┌───────┐ │actor 1│ │actor 2│ │actor 3│ │ │actor 1│ │actor 2│ │actor 3│ │π(·|o₁)│ │π(·|o₂)│ │π(·|o₃)│ │ │ o₁→a₁ │ │ o₂→a₂ │ │ o₃→a₃ │ └───┬───┘ └───┬───┘ └───┬───┘ │ └───────┘ └───────┘ └───────┘ │ o₁ │ o₂ │ o₃ │ each acts on LOCAL obs only ▼ ▼ ▼ │ no cross-agent comms needed local local local │ obs obs obs │
Independent learners (IQL / per-agent PPO)CTDE (MADDPG / QMIX)
What the critic seesown obs + action onlyjoint state + all agents' actions
Environment from each agent's viewnon-stationary — others' policies driftstationary to the critic — others' actions are inputs
Credit assignmentnone — team reward is opaquevalue decomposition / per-agent advantage
Convergenceoscillates / diverges in practicefar more stable empirically
Serving costlocal — cheaplocal — cheap (critic is train-only)
Needs all logs at train time?noyes — the price of admission

MADDPG — a centralized critic per agent

MADDPG (multi-agent DDPG) is CTDE applied to continuous or mixed action spaces. Each agent i keeps its own deterministic actor μ_i(o_i) and its own centralized critic Q_i(x, a_1, …, a_N) that scores the joint action. The critic's Bellman target uses every agent's next action from their target actors:

L(θ_i) = E[ ( Q_i(x, a_1…a_N) − y )² ],   y = r_i + γ · Q_i(x′, a′_1…a′_N)   where  a′_j = μ_j(o′_j)

The actor update is the deterministic policy gradient, but pushed through the joint critic — agent i improves its own action while holding the others' actions fixed at their observed values:

θi J = E[ ∇θi μ_i(o_i) · ∇ai Q_i(x, a_1…a_N) |aii(oi) ]

The single load-bearing idea: because Q_i takes a₋ᵢ as an argument, it is a stationary function even while the other policies change — the gradient agent i follows is computed against the others' actual current actions, not against a stale average baked into the environment. Crucially MADDPG allows a different reward r_i per agent, so it handles cooperative, competitive, and mixed games — making it the natural fit for the auction setting where each advertiser has its own objective.

QMIX and value decomposition — the cooperative case

When the agents are purely cooperative and share one team reward (the ranking-cascade case), you do not need a critic per agent — you need to factorize a single joint value into per-agent pieces so each agent can act greedily on its own and still be globally optimal. Two designs, increasing in expressiveness:

Why the monotonicity constraint is the whole trick: if Q_tot is monotonically increasing in each Q_i, then maximizing Q_tot jointly is the same as each agent independently maximizing its own Q_i

argmaxa Q_tot(τ, a) = ( argmaxa₁ Q_1, …, argmaxa_N Q_N )   ⇐   ∂Q_tot / ∂Q_i ≥ 0

This is the IGM (Individual-Global-Max) property: decentralized argmax equals centralized argmax. So you train the mixer centrally (it sees the global state), but at execution each agent just takes argmax a_i Q_i from its local network — no mixer needed at serve time. VDN is the special case where the mixer is a fixed sum; QMIX buys richer (but still IGM-preserving) credit assignment at the cost of being unable to represent games where coordination requires non-monotonic interactions.

VDNQMIXMADDPG
Game typecooperative (shared reward)cooperative (shared reward)coop / competitive / mixed
Joint value formΣ_i Q_imonotonic mix f(Q_i; s)per-agent Q_i(x, a_1…a_N)
Action spacediscretediscretecontinuous / mixed
Per-agent reward?nonoyes
Key constraintadditivitymonotonicity (IGM)none — but N critics to train
Recsys fitweak baselinecooperating ranking stagescompeting bidders / advertisers

Cooperative, competitive, mixed — and what "optimal" even means

The single most important framing question in any multi-agent problem: what is the relationship between the agents' rewards?

GameReward structureSolution conceptRecsys/ads example
Cooperativeshared team rewardsocial optimum (maximize the sum)ranking cascade optimizing session value
Competitive (zero-sum)one's gain = another's lossminimax / Nash equilibriumtwo advertisers fighting for one slot
Mixed (general-sum)partly aligned, partly opposedNash equilibrium (often ≠ social optimum)auto-bidders: share the marketplace, compete for impressions

The crucial gap is between two notions of "good." A Nash equilibrium is a profile where no single agent can improve by unilaterally deviating — it is stable, the place selfish learners settle. A social optimum maximizes the sum of rewards — what a benevolent central planner would pick. In general-sum games these are different points, and the equilibrium can be strictly worse for everyone. The size of that gap is the cost of decentralized selfishness.

Tragedy of the commons — the auction failure mode
Picture every advertiser switching on an aggressive auto-bidder that "maximizes my conversions subject to my budget." Each one, acting rationally, bids up to its value. But every bid increase raises the clearing price for all the others (recall the second-price / GSP mechanics from lesson 09). At the new equilibrium everyone bids higher, the platform's clearing prices rise, and each advertiser's surplus is lower than if they had all bid modestly — yet no one can unilaterally back off without losing their slots. That is a Nash equilibrium strictly worse than the social optimum: a commons tragedy. It is why naive "everyone optimizes at once" analysis of auto-bidding is wrong, and why auction mechanism design (reserve prices, throttling, incentive-compatible formats) exists — to make the equilibrium and the social optimum coincide instead of diverge.

Interactive · two auto-bidders and the commons

Two auto-bidders share one marketplace. Each picks an output/intensity q (how hard it pushes into the auction). The marketplace value per unit falls as total pressure rises: p = a − (q_A + q_B), and each pays a marginal cost c, so each agent's payoff is π = q · (a − q_A − q_B − c). Under independent (Nash), each best-responds to maximize its own payoff; under coordinated, they jointly restrain output to maximize total payoff. This is a Cournot duopoly — the textbook tragedy of the commons. Toggle the mode and watch the efficiency gap open and close.

Independent (Nash) vs coordinated output — a commons
Same market value a and cost c — only the objective each agent optimizes changes. Independent optimization over-grazes the commons: more total output, lower joint payoff, and each firm individually worse off than under coordination.
quantity (q_A · q_B)
payoff A
payoff B
joint payoff
efficiency gap vs coordinated
Reading

The honest verdict — when MARL earns its complexity

Time for intellectual honesty, because an interviewer is testing whether you can resist a shiny tool. Full MARL in production recsys is mostly research, rarely shipped. The reasons are concrete: it inherits every hardship of single-agent RL (off-policy bias, reward design, the impossibility of free online exploration on real users — all from lesson 16) and adds non-stationarity, joint credit assignment, and the data plumbing to log every agent's observations and actions together. The complexity-to-payoff ratio is brutal.

The pragmatic moves that beat naive MARL in almost every real system:

The reduction you should always try first
Before reaching for QMIX or MADDPG, ask: "Can I write one reward that all these agents should be maximizing, and is each agent's local observation a sufficient statistic for its decision?" If yes, you usually have a centralized or shared-reward single-agent problem wearing a multi-agent costume — and the single-agent toolbox from lesson 16 will be simpler, more stable, and easier to debug. MARL earns its keep only when that reduction genuinely fails.

Interview prompts you should be ready for

  1. "Single-agent RL was working. Why does adding more learning agents break it?" (Non-stationarity: from any one agent's view the transition is P(s′|s,aᵢ,a₋ᵢ) and a₋ᵢ keeps changing as the others learn, so the environment is a moving target — Bellman convergence and replay both assume stationarity and break. Plus multi-agent credit assignment: a shared reward cannot tell who actually earned it.)
  2. "What is CTDE and why does it specifically fix non-stationarity?" (Centralized training, decentralized execution: a centralized critic conditions on the joint state and all agents' actions during training; actors run on local observations at serving. It fixes non-stationarity because once a₋ᵢ are explicit inputs to the value function, the target is a stationary function of its inputs rather than noise folded into a drifting environment.)
  3. "Contrast MADDPG with QMIX — when would you pick each?" (MADDPG: per-agent actor + per-agent centralized critic Qᵢ(x,a₁…a_N), allows distinct rewards rᵢ, handles competitive/mixed games and continuous actions — fits competing advertisers. QMIX: cooperative shared-reward only, factorizes one joint Q into per-agent Qs via a monotonic mixing network — fits cooperating ranking stages with discrete actions.)
  4. "Why does QMIX impose a monotonicity constraint, and how does it differ from VDN?" (Monotonicity ∂Q_tot/∂Qᵢ ≥ 0 guarantees the IGM property: decentralized per-agent argmax equals the centralized joint argmax, so agents can act greedily on local Qs at serve time. VDN is the special case where the mixer is a plain sum Σ Qᵢ; QMIX learns a state-conditioned monotonic mixer, strictly more expressive while preserving IGM.)
  5. "Every advertiser turns on an aggressive auto-bidder. What happens to the marketplace?" (Tragedy of the commons: each rational bid increase raises clearing prices for all, so the system settles at a high-bid Nash equilibrium where every advertiser's surplus is lower than at the modest social optimum, yet no one can unilaterally back off. The cure is mechanism design — reserves, IC formats, pacing — to align equilibrium with social optimum, not central control of bidders you don't own.)
  6. "Nash equilibrium vs social optimum — why does the distinction matter here?" (Nash = no agent gains by unilateral deviation; it's where selfish learners settle. Social optimum = maximizes the sum of rewards. In general-sum games they diverge and the equilibrium can be worse for everyone. The gap is the cost of decentralized selfishness, and closing it via mechanism design is often the real lever — not a fancier learning algorithm.)
  7. "Would you actually deploy MARL in a recommender? Defend your answer." (Usually no. It inherits all of single-agent RL's pain — off-policy bias, reward design, no free online exploration — and adds non-stationarity, joint credit assignment, and heavy logging. First try the reduction: one shared global reward + a single/cooperative agent, or solve competition with auction mechanism design. Reserve true MARL for strong coupling with genuinely private serve-time observations, or for offline marketplace stress-testing.)
Takeaway
Single-agent RL assumes a stationary environment; the instant several agents learn together, each one's policy change makes every other's world non-stationary, and the convergence guarantees fall over. The dominant fix is CTDE — a centralized critic that sees everyone's actions at train time, decentralized actors that run on local observations at serve time — instantiated as QMIX (cooperative, monotonic value decomposition, IGM-preserving) or MADDPG (per-agent centralized critics, handles competition). But the honest senior verdict is restraint: most "multi-agent" recsys problems collapse to one shared reward, and most competition is better handled by auction mechanism design than by learning. MARL earns its complexity only when the shared-reward reduction provably fails and the agents truly have private signals they cannot share.