Skip to content

Add TokenGT model#9834

Closed
michailmelonas wants to merge 36 commits intopyg-team:masterfrom
michailmelonas:add-token-gt
Closed

Add TokenGT model#9834
michailmelonas wants to merge 36 commits intopyg-team:masterfrom
michailmelonas:add-token-gt

Conversation

@michailmelonas
Copy link
Copy Markdown

@michailmelonas michailmelonas commented Dec 9, 2024

PyG implementation of the Tokenized Graph Transformer following "Pure Transformers are Powerful Graph Learners" (https://arxiv.org/pdf/2207.02505). Includes support for both Laplacian eigenvectors and ORF node identifiers (implemented via a simple data Transform object). A graph regression example is also included.

For a detailed blog post about the implementation, see https://medium.com/stanford-cs224w/pyg-implementation-tokengt-e4aa74dc867b.

@michailmelonas
Copy link
Copy Markdown
Author

@wsad1 @EdisonLeeeee @akihironitta any thoughts on when this contribution will get reviewed? :)

@puririshi98
Copy link
Copy Markdown
Contributor

@michailmelonas this is cool, ill review and help merge soon as my time allows,

@puririshi98 puririshi98 self-requested a review January 14, 2025 20:56
@puririshi98
Copy link
Copy Markdown
Contributor

this looks good, will do a deep review soon

@michailmelonas
Copy link
Copy Markdown
Author

@puririshi98 apologies for only getting back to you now - have been swamped at work.

TokenGT requires specifying n_nodes orthogonal vectors ("node identifiers"). This is infeasible for the ogbn-papers100M dataset which has over 100M nodes. Therefore, rather than amending ogbn_train.py, I instead added token_gt_ogbn.py: a script that makes it easy to benchmark TokenGT against GCN on the ogbg-molhiv dataset (ideally, I'd like to run the model on PCQM4Mv2 as in the paper, but given my computational resources this was the best I could do). Running said script, I get slightly worse (but comparable) results for TokenGT vs GCN: the former has a validation ROC-AUC of 0.774 and the latter has 0.819.

@puririshi98
Copy link
Copy Markdown
Contributor

puririshi98 commented Jan 28, 2025

i think as a sanity check to get this merged, you should make an example which uses some opensource dataset(check relbench or ogb) to show higher accuracy than gcn and sage (with an argparser to choose between the three, defaulting to your graphtransformer). it will be a good research experience for you

@michailmelonas
Copy link
Copy Markdown
Author

Okay, will do. Will most likely only get to this next week. Apologies that this is dragging.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.39%. Comparing base (aa6cf80) to head (e5db369).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9834      +/-   ##
==========================================
- Coverage   86.79%   86.39%   -0.41%     
==========================================
  Files         490      492       +2     
  Lines       32436    32594     +158     
==========================================
+ Hits        28154    28159       +5     
- Misses       4282     4435     +153     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@puririshi98
Copy link
Copy Markdown
Contributor

Okay, will do. Will most likely only get to this next week. Apologies that this is dragging.

no problem, looking forward to seeing what you can do :)

@puririshi98
Copy link
Copy Markdown
Contributor

checking in @michailmelonas hows it going?

@puririshi98
Copy link
Copy Markdown
Contributor

puririshi98 commented Mar 1, 2025

c2bbb41

please ensure you follow this

@michailmelonas
Copy link
Copy Markdown
Author

@puririshi98 really sorry for the late response - between coursework (https://web.stanford.edu/class/cs234/) and working full time I've not had a chance to get to this. I think the PCQM4Mv2 dataset (https://ogb.stanford.edu/docs/lsc/pcqm4mv2/) would be best to benchmark TokenGT against GCN/GraphSAGE (this is what was used in the original paper). I've obtained some GPU credits to run this experiment. Realistically, I won't be able to start with this in the next two weeks, but will get to it asap post 18/03.

@puririshi98
Copy link
Copy Markdown
Contributor

@michailmelonas hows it going?

@puririshi98
Copy link
Copy Markdown
Contributor

please update examples/readme, see this for example
https://github.com/pyg-team/pytorch_geometric/pull/9908/files

@puririshi98
Copy link
Copy Markdown
Contributor

@michailmelonas eta on this?

@Krecharles Krecharles mentioned this pull request Oct 20, 2025
@puririshi98
Copy link
Copy Markdown
Contributor

After discussing w charles kremmer, i found that tokenGT has extreme computational limitations and signifcantly underperforms the old graphGPS model. there are lots of new things coming in graph transformers and i want to avoid having infinite options for users. as such i am closin this PR as well as that of charles. feel free to reach out w questions.
if you want to contribute graph trans work help w these:
#9783
#10409

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.

4 participants