{
  "video_id": "reddit_1upzxk2",
  "channel_slug": "MachineLearning",
  "channel_handle": "r/MachineLearning",
  "title": "TorchJD: Training with multiple losses in PyTorch [P]",
  "url": "https://www.reddit.com/r/MachineLearning/comments/1upzxk2/torchjd_training_with_multiple_losses_in_pytorch_p/",
  "external_url": null,
  "upload_date": "20260707",
  "published_at": "2026-07-07T16:20:47+00:00",
  "transcript": "Hi everyone! I wanted to share some recent progress on [TorchJD](https://github.com/SimplexLab/TorchJD) that might be useful to the machine learning community.\n\nWhen training models with multiple losses (multiple tasks, constraints, auxiliary losses, regularization terms, etc.), you typically have two options:\n\n* Scalarization: Various ways to combine those losses into a single loss (e.g. average them or combine them with trainable weights); then you can do gradient descent on it.\n* Jacobian descent: Compute the Jacobian of the vector of losses (i.e. one gradient per loss), and aggregate it into an update vector that will decrease each individual loss (rather than just the average loss). There are many ways to do this aggregation step.\n\nScalarization methods are generally cheaper in memory, but in some cases there is so much disagreement between your objectives that it's better to use a Jacobian descent method. In any case, thanks to our amazing new contributors, we've now finally implemented most existing methods of the literature from both categories into our library TorchJD, so that you can try anything in just a few line changes!\n\nRecently, TorchJD has been accepted into the PyTorch ecosystem, and we're trying to make it become the go-to library for training with multiple losses. If you'd like to help build the future of the project, come join us on Discord (link can be found in the readme of the repo). New ideas, contributions, bug reports, experiments, and any form of feedback are all welcome. We have many ideas on how to make all this even more efficient, and we will need help for that.\n\nIf you want to support us, a star on [GitHub](https://github.com/SimplexLab/TorchJD) also helps a lot!\n\n\n\n--- Top Comments ---\n\n\n[7 upvotes] This is great stuff! We’ve used torchJD for a few projects at my work. \n\n[5 upvotes] This is exactly the kind of thing that makes me wish I'd stuck with my ML courses beyond the intro level. The jump from scalarization to Jacobian descent sounds like a whole different universe of complexity but if you've wrapped it up in a clean API that's pretty huge. Starred the repo, looking forward to poking around when I have a weekend free.\n\n[4 upvotes] Very cool. Should I generally assume that JD methods will linearly increase the in-memory size of gradients? Do optimizers like ADAM which track statistics over time also take a heavier footprint?\n\n[4 upvotes] The advantage is not clear to me. Granted, I just skimmed through the paper, but the method seems to provide slightly faster convergence than traditional loss averaging. But since it also uses more memory, it requires smaller batch sizes, which likely leads to a slower convergence. \n\nActually, I think a more fair comparison in the paper would be to compare convergence times, not number of iterations. And to also consider same VRAM usage on both methods.\n\nUltimately, I feel you should focus more on empirical results for multi-objective optimization instead of convergence speed.",
  "transcript_chars": 3003,
  "ingested_at": "2026-07-08T01:30:31.820280+00:00",
  "source": "reddit",
  "yt_meta": {
    "score": 55,
    "upvote_ratio": 0.98,
    "num_comments": 20,
    "author": "Skeylos2",
    "is_self": true
  }
}