Lightning AI Studios: Never set up a local environment again →

Log in or create a free Lightning.ai account to track your progress and access additional course materials  

10.2 Fabric – Scaling PyTorch Models without Boilerplate Code

References

Code

  • Part 2, Training an LLM with PyTorch and Fabric: 10.2-fabric/

What we covered in this video lecture

In this lecture, we learned about Fabric, an open-source library designed for scaling PyTorch models without requiring a significant rewriting of code.

Fabric integrates with PyTorch, allowing the implementation of features such as mixed precision training and multi-GPU training, typically found in the Lightning Trainer, without the need to restructure our code around a Lightning Module, which can be useful if we adopt or port existing PyTorch code.

Additional resources if you want to learn more

Fabric supports many advanced use cases, including loggers and callback, which we didn’t cover in this lecture. To learn more about those, I recommend checking out the official Fabric documentation.

Moreover, as a small fun-fact: The Lit-LLaMA repository for implementing state-of-the-art LLM techniques (such as distributed training and efficient finetuning) makes use of Fabric as well!

Log in or create a free Lightning.ai account to access:

  • Quizzes
  • Completion badges
  • Progress tracking
  • Additional downloadable content
  • Additional AI education resources
  • Notifications when new units are released
  • Free cloud computing credits

Quiz: 10.2 Fabric - Scaling PyTorch Models without Boilerplate Code [Part 1]

How do we back-propagate to compute the gradient of the loss when using Fabric?

Incorrect. This is the regular PyTorch call.

Correct. This replaces the regular PyTorch call loss.backward().

Incorrect. This syntax does not exist.

Incorrect. This syntax does not exist.

Please answer all questions to proceed.

Quiz: 10.2 Fabric - Scaling PyTorch Models without Boilerplate Code [Part 2]

Which of the following are valid settings for training a model with 16-bit mixed precision training?

-1" name="question-1" value="

fabric(...,-precision="16-full")

-1">

Incorrect. This would result in full 16-bit training, not mixed precision training.

-2" name="question-1" value="

fabric(...,-precision="16")

-2">

Correct. This is a valid way for 16-bit mixed-precision training.

-3" name="question-1" value="

fabric(...,-precision="16-mix")

-3">

Correct. This is a valid way for 16-bit mixed-precision training.

Incorrect. This setting does not exist.

Please answer all questions to proceed.
Watch Video 1

Unit 10.2

Videos