Skip to content

Perforated AI OGBN Example #9926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 58 commits into from
Apr 22, 2025
Merged

Conversation

RorryB
Copy link
Contributor

@RorryB RorryB commented Jan 8, 2025

This PR is to include an example of how Perforated Backpropagation can be used to improve pytorch_geometric models. It adds on the previous PR which added a scheduler, both of which improve upon the test accuracy of the original ogbn_train.py example.

Perforated Backpropagation empowers each neuron in a PyTorch network with Dendrite nodes. These nodes are outside the network, but able to inform the neurons inside the network to make better decisions by leveraging a covariance based learning rule to reduce residual error. The PyTorch add-on combines modern neuroscience with modern software to create neural networks that are smarter, smaller, and more accurate.

Run docker from torch_geometric directory

docker run --gpus all -i --shm-size=8g -v .:/pai -w /pai -t nvcr.io/nvidia/pyg:24.11-py3 /bin/bash

Within Docker

pip install -e .
pip install safetensors
pip install perforatedai

Ran original with:

CUDA_VISIBLE_DEVICES=0 python examples/ogbn_train.py --dataset ogbn-products --batch_size 128 --model sage

Results:

Test Accuracy: 77.06%

Run PAI with:

PAIEMAIL=YourEmail PAITOKEN=YourToken CUDA_VISIBLE_DEVICES=0 python ogbn_train_perforatedai.py --dataset ogbn-products --batch_size 128 --saveName ogbnPAI --model sage

Results:

Test Accuracy: 78.05%

Update: Example updated to include base usage with default SGFormer.

Original:

CUDA_VISIBLE_DEVICES=0 python ogbn_train.py --dataset ogbn-products --batch_size 128

Results:

Test Accuracy: 80.86%

PAI:

    PAIEMAIL=YourEmail PAITOKEN=YourToken CUDA_VISIBLE_DEVICES=0 python ogbn_train_perforatedai.py --dataset ogbn-products --batch_size 128 --saveName ogbnPAI

Results:

Test Accuracy: 81.27%

@RorryB RorryB requested a review from wsad1 as a code owner January 8, 2025 22:01
Copy link
Contributor

@puririshi98 puririshi98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I would like @akihironitta to take a look since he may have a different opinion on how best to expose Perforated AI for PyG

Copy link
Member

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is to include an example of how Perforated Backpropagation can be used to improve pytorch_geometric models. It adds on the previous PR which added a scheduler, both of which improve upon the original results.

I'm trying to understand the change at a high level, and sorry I may not have enough context here. Could you elaborate more on the change in the PR description? Could you link the previous PR (and relevant issues if there is)? What is Perforated AI? What are the original results?

@RorryB
Copy link
Contributor Author

RorryB commented Mar 26, 2025

This PR is to include an example of how Perforated Backpropagation can be used to improve pytorch_geometric models. It adds on the previous PR which added a scheduler, both of which improve upon the original results.

I'm trying to understand the change at a high level, and sorry I may not have enough context here. Could you elaborate more on the change in the PR description? Could you link the previous PR (and relevant issues if there is)? What is Perforated AI? What are the original results?

@akihironitta PR description has now been updated to include these details.

@RorryB
Copy link
Contributor Author

RorryB commented Mar 31, 2025

Example has been updated to include usage with default SGFormer.

Copy link
Member

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, and thanks for the example! Looks cool :)

I feel like this is a kind of example that should be maintained by https://github.com/PerforatedAI/PerforatedAI-API. Given our current bandwidth, I'm not confident that we can keep this example maintained and up-to-date in the future.

@puririshi98
Copy link
Contributor

@RorryB i think the best way forward is to copy this example over to your public PAI repo, then make a reference to that in our README. so this PR would just be an update to PyG examples readme and the main example code would go in your own repo.

@RorryB
Copy link
Contributor Author

RorryB commented Apr 4, 2025

That sounds great! Just updated the PR to only include changes to the README and CHANGELOG with a link to the Perforated AI examples repository.

Copy link
Contributor

@puririshi98 puririshi98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@puririshi98 puririshi98 enabled auto-merge (squash) April 22, 2025 03:30
auto-merge was automatically disabled April 22, 2025 13:17

Invalid email address

@puririshi98 puririshi98 merged commit e543964 into pyg-team:master Apr 22, 2025
17 checks passed
chrisn-pik pushed a commit to chrisn-pik/pytorch_geometric that referenced this pull request Jun 30, 2025
This PR is to include an example of how Perforated Backpropagation can
be used to improve pytorch_geometric models. It adds on the [previous
PR](pyg-team#9877) which added
a scheduler, both of which improve upon the test accuracy of the
original ogbn_train.py example.

Perforated Backpropagation empowers each neuron in a PyTorch network
with Dendrite nodes. These nodes are outside the network, but able to
inform the neurons inside the network to make better decisions by
leveraging a covariance based learning rule to reduce residual error.
The PyTorch add-on combines modern neuroscience with modern software to
create neural networks that are smarter, smaller, and more accurate.

Run docker from torch_geometric directory

docker run --gpus all -i --shm-size=8g -v .:/pai -w /pai -t
nvcr.io/nvidia/pyg:24.11-py3 /bin/bash

Within Docker

    pip install -e .
    pip install safetensors
    pip install perforatedai

    
Ran original with:

CUDA_VISIBLE_DEVICES=0 python examples/ogbn_train.py --dataset
ogbn-products --batch_size 128 --model sage

Results:

    Test Accuracy: 77.06%
    
Run PAI with:

PAIEMAIL=YourEmail PAITOKEN=YourToken CUDA_VISIBLE_DEVICES=0 python
ogbn_train_perforatedai.py --dataset ogbn-products --batch_size 128
--saveName ogbnPAI --model sage
    
Results:

    Test Accuracy: 78.05%

Update: Example updated to include base usage with default SGFormer.

Original:

CUDA_VISIBLE_DEVICES=0 python ogbn_train.py --dataset ogbn-products
--batch_size 128
 
Results:

    Test Accuracy: 80.86%
 
PAI:

PAIEMAIL=YourEmail PAITOKEN=YourToken CUDA_VISIBLE_DEVICES=0 python
ogbn_train_perforatedai.py --dataset ogbn-products --batch_size 128
--saveName ogbnPAI
 
Results:

    Test Accuracy: 81.27%

---------

Co-authored-by: Akihiro Nitta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants