PythiloLesson 3 of 8 · progress kept in this browser

Practice in Lab: Project conflicting task gradients without mutating their owners →

Project conflicting task gradients without mutating their owners

Multi-task objectives can produce gradients that oppose one another even when the shared model is differentiable. PCGrad edits a task gradient by removing conflicting components relative to original peer gradients. Projection order matters with three or more tasks, so order and randomness are part of the reproducibility contract. Returning separate rows preserves the distinction between surgery and the later task-weighting decision. This is a local vector algorithm; it does not claim a Pareto optimum or execute distributed reduction.

Your task

Return a detached [tasks, parameters] matrix of PCGrad gradients. For each task, visit the other ORIGINAL task gradients in a seed-local shuffled order. If the current projected gradient has a negative dot product with an original peer, remove that component. Skip zero-norm peers. Do not mutate the input or global RNG. The caller chooses how to combine the projected rows; this Lab does not assert that a mean improves every task.

This lesson uses torch, which Python in this browser does not include. Read it here, and run and check it in the Pythilo app on iPhone or iPad.