Home▸Articles▸Data Science

Gradient Surgery: Resolving Conflicting Task Gradients (PCGrad)

A novel approach in machine learning that addresses the challenges of conflicting gradients during multi-task optimization.

mysimulator teamUpdated June 2026≈ 4 min read▶ Open the simulation

What is Gradient Surgery (PCGrad)?

Gradient surgery, specifically the Projection with Conflicting Gradients (PCGrad) method, is a technique used in multi-task learning scenarios where multiple tasks are optimized simultaneously. It addresses the issue of conflicting gradients that can arise when optimizing for different objectives, leading to suboptimal solutions or even divergence.

The core idea behind PCGrad is to project each gradient onto a subspace orthogonal to the gradients of other tasks at any given step, thereby mitigating the negative impact of conflicting gradients and allowing the model parameters to move more effectively towards a common optimum.

How Does It Work?

PCGrad operates by computing the projection of each gradient onto a subspace that is orthogonal to all other gradients. This means that at any step during optimization, only non-conflicting components of the gradients are considered for updating the model parameters. Mathematically, this can be represented as projecting the gradient vector Δ into a space where it is orthogonal to the gradients from other tasks.

This approach ensures that when multiple objectives pull the model in different directions, the optimization process can still make progress by focusing on the non-conflicting parts of each gradient. This helps in stabilizing the training process and improving convergence.

live demo · related simulation● LIVE

Why Does It Matter?

In multi-task learning scenarios, conflicting gradients are a common challenge that can hinder model performance and stability. PCGrad addresses this by providing a systematic way to resolve these conflicts, leading to more robust and efficient training processes.

By mitigating the negative effects of conflicting gradients, PCGrad enables better optimization outcomes in complex models with multiple objectives, which is crucial for applications such as multi-task learning in natural language processing, computer vision, and other areas where multiple related tasks need to be optimized simultaneously.

Real-World Examples

PCGrad has been applied successfully in various machine learning tasks. For instance, in natural language processing, it can help improve the performance of models trained on multiple languages or aspects of a single language by resolving conflicting gradients that arise from different linguistic features.

In computer vision tasks involving object detection and segmentation, PCGrad can stabilize training when optimizing for both accuracy and speed, ensuring that the model performs well across all objectives without getting stuck in local optima.

Frequently asked questions

How does PCGrad differ from other gradient-based optimization methods?

PCGrad specifically addresses the issue of conflicting gradients by projecting each gradient onto a subspace orthogonal to others, whereas traditional methods like stochastic gradient descent (SGD) or Adam simply sum the gradients without considering their conflicts.

Can PCGrad be used for single-task learning?

While it is primarily designed for multi-task scenarios, PCGrad can still be applied to single-task learning as a form of regularization, potentially improving convergence and stability in certain cases.

What are the potential downsides of using PCGrad?

PCGrad may introduce additional computational overhead due to the projection calculations. It also might not always be beneficial if tasks have very similar gradients or if the conflict angles are minimal, as it could overly restrict the gradient updates.

Is PCGrad applicable to all types of machine learning models?

PCGrad is generally applicable to any model where multiple objectives need to be optimized simultaneously. However, its effectiveness can vary depending on the specific tasks and their gradients.

Try it live

Everything above runs in your browser — open Gradient Surgery: Resolving Conflicting Task Gradients (PCGrad) and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Gradient Surgery: Resolving Conflicting Task Gradients (PCGrad) simulation

What did you find?

Add reproduction steps (optional)