---
title: 'PCGrad: Resolving Gradient Conflicts in MTL'
url: https://www.emergentmind.com/topics/projecting-conflicting-gradients-pcgrad
type: topic
---

# PCGrad: Resolving Gradient Conflicts in MTL

Projecting Conflicting Gradients (PCGrad) is a gradient manipulation scheme designed to address the optimization challenges inherent in multi-task learning and composite neural optimization objectives. The method operates by identifying and resolving destructive interference between gradients associated with different task-specific loss terms, directly intervening in the standard gradient aggregation mechanism to promote constructive update directions and mitigate negative transfer. PCGrad was first introduced in the context of deep multi-task learning and has since found applications across supervised, reinforcement, and physics-informed learning paradigms [2001.06782, 2112.00220, 2409.01793, 2604.14808].

## 1. Motivation and Theoretical Foundations

Multi-task learning (MTL) and multi-loss frameworks, such as physics-informed neural networks (PINNs), aggregate loss terms $\{\mathcal{L}_i\}_{i=1}^K$ corresponding to different objectives, constraints, or tasks. Optimization traditionally proceeds via summing the gradients $g = \sum_i \nabla_\theta \mathcal{L}_i$. However, when individual gradients are (i) highly imbalanced in magnitude or (ii) oriented in conflicting directions (i.e., negative cosine similarity), naïve aggregation leads to destructive interference. This results in oscillations, slow convergence, suboptimal solutions, and the phenomenon of negative transfer, where improvement in one task comes at the expense of another [2001.06782, 2112.00220].

Theoretical analysis shows that when task gradients $g_i$ and $g_j$ satisfy
\[
\omega(g_i, g_j) = \frac{g_i \cdot g_j}{\|g_i\|\|g_j\|} < 0,
\]
inter-task gradient conflict occurs, violating aligned descent for the shared parameter vector [2001.06782]. Empirical studies further reveal that such conflicts are both common and detrimental across domains, motivating algorithmic intervention.

## 2. Mathematical Formulation and Algorithm

PCGrad operates by "surgically" removing components of a task's gradient that directly oppose other task gradients. The core update for a pair of conflicting gradients is:
\[
g_i \longleftarrow g_i - \frac{g_i \cdot g_j}{\|g_j\|^2} g_j, \quad \text{if } g_i \cdot g_j < 0
\]
where $g_i$ and $g_j$ are gradients of task $i$ and $j$ with respect to the shared model parameters. This projection ensures that, post-modification, the updated $g_i$ is non-conflicting with $g_j$.

The PCGrad algorithm proceeds as follows [2001.06782, 2112.00220, 2409.01793]:

1. For each task $i$, initialize $g_i^{PC} \leftarrow g_i$.
2. Randomly order the tasks; for each $i$:
    - Randomly select another task $j \neq i$.
    - If $g_i^{PC} \cdot g_j < 0$, project $g_i^{PC}$ onto the normal plane of $g_j$ using the formula above.
3. Form the aggregated update $g^{PC} = \sum_{i=1}^K g_i^{PC}$.
4. Update parameters: $\theta \leftarrow \theta - \eta\,\mathcal{O}(g^{PC})$, where $\mathcal{O}$ is any base optimizer.

PCGrad is hyperparameter-free, requires only minor modification to the optimizer's gradient aggregation step, and is compatible with any first-order optimization method [2001.06782, 2112.00220].

## 3. Implementation and Computational Considerations

PCGrad introduces minimal computational overhead. For $K$ tasks, each iteration requires $K$ backward passes (unless gradient sharing is used) and $\mathcal{O}(K)$ inner products per projection. For small $K$ (e.g., $2$ or $3$ tasks), such as multi-component physics-informed losses or asymmetric two-task setups (LLM unlearning), the cost is negligible [2112.00220, 2604.14808]. The framework is readily integrated with standard neural optimization libraries without additional hyperparameters.

In "A generic physics-informed neural network-based framework for reliability assessment of multi-state systems" [2112.00220], PCGrad is used with PINNs where $\mathcal{K}=2$ or $\mathcal{K}=M+2$ (M denotes the number of ODE residuals). In large-scale multi-task vision or RL (e.g., MT10, MT50), the overhead remains manageable by batching and vectorized dot-product computation [2001.06782, 2409.01793].

## 4. Empirical Performance and Applications

PCGrad yields consistent performance improvements in supervised learning, reinforcement learning, physics-informed learning, and LLM unlearning:

- **Supervised Learning**: On CIFAR-100 (20 tasks), PCGrad raises average test accuracy from 67.7% (single-task) to 77.5% (routing nets + PCGrad) [2001.06782]. On NYUv2 (3 tasks), it improves mean IoU and pixel accuracy, achieving best-in-class metrics for multi-task vision backbones.
- **Reinforcement Learning**: In the Meta-World MT10/MT50 suite, SAC with PCGrad achieves 100%/70% multi-task success rates with significantly fewer samples than independent training [2001.06782].
- **Physics-Informed Learning**: For PINN-based reliability assessment, RMSE is reduced by up to 96.6% on a 12-state system when incorporating PCGrad, and convergence accelerates by an order of magnitude in iteration count [2112.00220].
- **Unlearning in LLMs**: In asymmetric two-task setups (retention vs. forgetting), module-wise PCGrad projections increase retention performance (e.g., MMLU recovery from 25.1% to 53.0%) at matched forgetting strength, shifting solutions toward the Pareto frontier [2604.14808].

## 5. Extensions, Variants, and Theoretical Insights

PCGrad's pairwise projection mechanism can be generalized:

- **Weighted PCGrad (wPCGrad)**: Task projection order is made probabilistically dependent on task priority or loss, allowing adaptive focus on underperforming or high-loss tasks [2409.01793]. This yields further performance gains in datasets such as nuScenes, CIFAR-100, and CelebA.
- **Module-Wise and Layer-Wise PCGrad**: Fine-grained projection is applied at the module or layer level (e.g., for LLM unlearning), improving granularity and empirical retention [2604.14808].
- **Algorithmic Hybrids**: PCGrad can be combined with dynamic weighting schemes such as GradNorm or incorporated alongside global cone-based constraints (ConicGrad) and higher-order subspace projections (GradOPS) to navigate multi-objective trade-offs [2502.00217, 2503.03438].

Theoretical results guarantee that, post-projection, the aggregated gradient remains a valid descent direction for the combined loss. For two-task convex problems, PCGrad guarantees convergence to either an optimum or a saddle point where gradients are exactly opposed. In the nonconvex regime, removing only the destructive components prevents regressive interference, stabilizes joint descent, and empirically supports faster convergence [2001.06782].

## 6. Limitations and Potential Directions

PCGrad assumes task equality—projections are performed only when direct conflict is present and without explicit re-weighting of loss scales. Scenarios with very large $K$ confront increased computational cost, advocating for sampling or layer-wise approximations [2112.00220, 2001.06782]. PCGrad does not enforce full strong non-confliction as in GradOPS, nor does it solve a global max–min as in ConicGrad, so it is possible for PCGrad solutions to remain suboptimal with respect to some Pareto objectives [2502.00217, 2503.03438]. Further extensions combine projection-based conflict resolution with adaptive weighting, meta-learned task prioritization, or global geometric constraints.

## 7. Comparative Table: PCGrad and Related Methods

| Method       | Principle                           | Computational Complexity per Step | Trade-off Control                |
|--------------|-------------------------------------|-----------------------------------|----------------------------------|
| PCGrad       | Pairwise conflict projection        | $\mathcal{O}(K^2 M)$              | Implicit; projection only        |
| wPCGrad      | Weighted conflict projection        | $\mathcal{O}(K M)$                | Adaptive anchor selection        |
| GradOPS      | Subspace orthogonal projection      | $\mathcal{O}(K^2 M)$              |   $\alpha$ parameter (trade-off) |
| ConicGrad    | Cone-constrained max–min solution   | $\mathcal{O}(M)$ (via SMW)        |   Cone width $c = \cos\alpha$    |

Here, $K$ is the number of tasks and $M$ the parameter count. PCGrad provides a practical, model-agnostic, hyperparameter-free deconfliction strategy effective for a broad range of multi-objective learning problems, with theory and empirical results validating substantial improvements in accuracy, convergence, and optimization stability [2001.06782, 2112.00220, 2409.01793, 2502.00217, 2503.03438, 2604.14808].

Source: https://www.emergentmind.com/topics/projecting-conflicting-gradients-pcgrad