OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

Pytorch Pcgrad

Pytorch Pcgrad is a Python/PyTorch library that wraps an optimizer and applies PCGrad gradient modification to a list of per-task losses before an optimization step. Its repository includes a Multi-MNIST training example.

Independent OpenViST project profile, based on linked sources.

Pytorch Pcgrad — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use it when a PyTorch multi-task training loop already produces separate task losses and you want to apply PCGrad gradient modification before optimizer updates.

Who it is for

  • Developers implementing multi-task learning experiments in PyTorch.
  • Researchers who want to incorporate PCGrad gradient surgery into an optimizer-based training loop.

Documented uses

  • Wrap an existing optimizer so updates use PCGrad-modified gradients.
  • Pass losses for multiple tasks through the PCGrad backward method before an optimization step.
  • Consult or run the included Multi-MNIST training example.
Before you choose

Requirements & limits

  • The repository identifies PyTorch 1.6.0 as the implementation target.
  • The documented integration wraps an optimizer and calls pc_backward with a loss list before step.
  • The repository is licensed under BSD-3-Clause.
  • Cifar100-MTL is listed as “coming soon” in the README.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Add PCGrad to a PyTorch training loop

Use PCGrad to modify gradients computed from per-task losses before an optimizer update.

Before you start

  • A PyTorch training loop with a model and optimizer.
  • Project dependencies installed with pip install -r requirements.txt.
  • A list of per-task losses, with one loss for each task.

Steps

  1. Install the required packages from requirements.txt.

  2. Import PCGrad and wrap the chosen optimizer, for example by wrapping an Adam optimizer.

  3. Pass the per-task loss list to optimizer.pc_backward(losses).

  4. Apply the update with optimizer.step().

Expected outcome

The optimizer update uses gradients processed by PCGrad.

Guide limitations

  • The README identifies PyTorch 1.6.0 for the reimplementation.
  • The guide documents the optimizer integration pattern, not results for a particular model or task.
Source-based practical guide

Run the included Multi-MNIST training script

Use the repository’s documented command for its Multi-MNIST training example.

Before you start

  • The repository and its required packages installed.

Steps

  1. Install the required packages with pip install -r requirements.txt.

  2. Run python main_multi_mnist.py.

Expected outcome

The repository’s Multi-MNIST training script is started.

Guide limitations

  • The README provides no comparable run command for Cifar100-MTL, which it labels “coming soon.”
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
17 October 2026
Original website title
WeiChengTseng/Pytorch-PCGrad · Official homepage title · retained in its source language