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

← Back to blog

How to Contribute to Lightning

Learn how to:

Make a contribution to Lightning’s open-source ecosystem.

Contributing to open-source projects is a great way to improve your coding skills, gain relevant experience, interact with amazing developers from around the world, and give back to the community. This blog post will cover how you can contribute to Lightning’s open-source libraries.

Lightning AI has built an open-source ecosystem with libraries for model training, deployment, and shipping AI products Lightning fast. Those libraries are:

  • PyTorch Lightning: Build, train and deploy PyTorch models
  • Lightning Fabric: Scale PyTorch foundation models with expert-level control
  • TorchMetrics: 90+ Easy to use, PyTorch metrics optimized for distributed training
  • Lightning Apps: Quickly and easily build full-stack AI apps.

 

Different ways to contribute

If you want to help with an open-source project, there are several ways you can go about doing so. These can be categorized into code and non-code contributions.

A code contribution is when you change the source code and create a pull request to merge those changes into the official project repository. To contribute to the source code, you should first find an issue that you’d like to resolve. An issue could be a new feature request, a bug, or a general typo in the code.

You can make a non-code contribution by sharing a project over social media, presenting it at a meetup or conference, and writing a tutorial or documentation for it. These are great ways to make sure a project you’re passionate about gets the attention it deserves, and reaches the audience you want it to reach. It’s also a great way to become part of the thriving (and growing!) open-source community.

How to find issues to work on

Github repositories have an issue section that contains bug reports and feature requests from its users and project maintainers.

For instance, here’s Lightning’s issue section:

 

And here’s what’s going on inside:

 

 

Maintainers label issues to improve search and tracking and indicate the difficulty level of fixing them. The label Good first issue is used for generic, easier issues and is especially helpful for newcomers.

How do I make changes to the official repository?

Once you have found an issue to work on, read the project’s contribution guidelines, then fork the repository and clone it to your local machine. Create a new branch for the fix, and make changes to the codebase. Commit the code changes after testing them and push them to the git server. Then create a pull request with a clear description of the changes you made and why they are necessary.

I am going to fix this beginner-friendly issue and show the step-by-step procedure.

Ask the maintainer to assign the issue

It is a good practice to ask the maintainers to assign the issue so that you or someone else doesn’t work on the same issue.

I asked Borda, who maintains the lightning project to assign the issue to me. After getting assigned I can start making changes to the repo.

Fork and clone the repo

You need to create a copy of the official repo to your GitHub account. This process is called a fork. To fork a repository on GitHub, open the project and click on the Fork button which will automatically copy this repo to your GitHub account.

My forked repo looks like this:

To clone the fork on your local system, run git clone https://github.com/YOUR-USERNAME/lightning.git in the terminal.

Make the code changes

This example issue requires restructuring example code by category: Apps, PyTorch Lightning, and Fabric.

 

After reorganizing my code, I committed the changes and push them to my GitHub fork.



git add lightning/examples
git commit -m "refactor examples"
git push

Check test cases and create PR

To run the test cases for Lightning, you need to run make test in the terminal. If all the tests pass successfully, you can create a pull request to the official repository.

When creating your pull request, describe the code changes you made and link the issue those changes solve. Be sure to also link any references that you might have used.

Code owners will then approve or give feedback on your changes. You should apply those suggestions to your PR.

Once all the feedback has been taken into consideration and the test cases pass, code owners will approve and merge your changes to the main branch.

🎉 Yay!

If you’ve followed along to this point, then you’re ready to contribute to Lightning’s open-source ecosystem or any open-source project.

The final, most important point of contributing to open-source is “Never hesitate to ask for help. 💜

Summary

Contributing to open-source projects is a great way to improve your coding skills and build a robust profile. You get to interact with great developers from different parts of the world and learn from a huge variety of talented people. To contribute to any open-source project, here are the key steps:

  1. Check for issues, and filter by Good first issue
  2. Ask the maintainers to assign the issue to you
  3. fork the project and make changes to fix the issue
  4. Create a PR and incorporate any feedback

 

Looking to get started with a contribution to Lightning? Come chat with us on Discord!

 

Join the Lightning Discord