In deep learning, we often want a single model to do many things at once: a robot that walks and balances, a vision model that detects objects across different lighting conditions, or a language model that learns new instructions without forgetting old ones. However, training on multiple objectives simultaneously often leads to a "tug-of-war" where the gradient updates for one task actively sabotage the performance of another.
This phenomenon, known as gradient interference or negative transfer, occurs when the optimization directions for different tasks point away from each other. Researchers have developed a suite of techniques collectively known as gradient surgery to resolve these conflicts by geometrically manipulating update vectors before they are applied to the model's parameters.
The Geometry of Conflict
When we train a model on two tasks, $A$ and $B$, we calculate two gradient vectors, $g_A$ and $g_B$. In standard multi-task learning, we simply average them. But as Jun Yu and colleagues explain in their comprehensive survey, if these vectors form an obtuse angle (negative cosine similarity), an update that improves Task A will necessarily increase the loss for Task B.
The core intuition of gradient surgery is to identify these "conflicting" components and remove them. If $g_A$ and $g_B$ conflict, we project $g_A$ onto the normal plane of $g_B$. This geometric transformation effectively subtracts the component of $g_A$ that opposes $g_B$, resulting in a new vector that is at least orthogonal to the other task's needs. By ensuring that no update direction has a negative projection onto another, the model can converge toward a Pareto-optimal solution where no task is sacrificed for the sake of another.
Harmonizing Diverse Objectives
This mechanism has proven essential in fields where objectives are inherently at odds. For example, in Physics-Based Flow Matching, Giacomo Baldan and Nils Thuerey use conflict-free gradient updates to balance the need to match data distributions with the need to obey rigid physical laws (PDEs). Without surgery, the model's attempt to look "realistic" often violates the laws of physics, and vice versa.
Similarly, in robotics, David Howard and his team developed GCR-PPO (Scalable Multi-Objective Robot Reinforcement Learning through Gradient Conflict Resolution) to prevent a robot's speed objective from "washing out" its energy-saving objective. By calculating individual gradients for every reward term and resolving their directional conflicts, they achieve stable optimization even as the number of tasks scales.
Beyond Simple Projection
While basic projection (often called PCGrad) is effective, recent work has introduced more sophisticated ways to align task gradients:
- Rotation and Homogenization: Adrián Javaloy and Isabel Valera introduced Rotograd (Rotograd: Dynamic Gradient Homogenization for Multitask Learning), which doesn't just project gradients but actively rotates them. By using task-specific rotation matrices, the model learns to align the orientation of gradients so they can collaborate on shared parameters rather than just avoiding interference.
- Directional Constraints: In the context of fine-tuning foundation models, Chengyue Huang and Junjiao Tian proposed DiGraP (Directional Gradient Projection for Robust Fine-Tuning of Foundation Models). They treat the goal of "learning a new task" and "staying close to the pre-trained weights" as two competing objectives, using surgery to ensure that new learning doesn't destroy the model's original robust representations.
- Deterministic Stability: To address the "seesaw dilemma" in long-tailed recognition—where improving rare "tail" classes often hurts frequent "head" classes—Zhe Zhao developed TS-MOF (TS-MOF: Two-Stage Multi-Objective Fine-tuning for Long-Tailed Recognition). This framework uses deterministic gradient projection to ensure that updates for different class groups are numerically stable and reproducible.
Applications in Modern AI
The reach of gradient surgery extends into nearly every corner of modern machine learning:
- Generative Models: AnhDung Dinh and Chang Xu applied these principles to diffusion sampling in PixelAsParams (PixelAsParam: A Gradient View on Diffusion Sampling with Guidance), resolving conflicts between image quality and conditional guidance to prevent the "diversity collapse" often seen at high guidance scales.
- Domain Generalization: Lucas Mansilla and colleagues demonstrated in Domain Generalization via Gradient Surgery that by neutralizing conflicting gradients between different training domains, models can be forced to ignore domain-specific noise and focus on features that generalize to unseen environments.
- Large Language Models: To prevent "catastrophic forgetting" during instruction tuning, researchers like Lingyong Yan use gradient projection in frameworks like Joint Flashback Adaptation (Joint Flashback Adaptation for Forgetting-Resistant Instruction Tuning) to ensure that learning new skills doesn't overwrite the model's existing internal knowledge.
By treating the training process as a geometric negotiation between competing goals, gradient surgery allows us to move past simple weighted averages of losses toward a more robust, multi-faceted intelligence.