Skip to content

Add Triton support for KNN and Nearest; remove deprecated torch.ji.script#264

Open
denix56 wants to merge 48 commits intorusty1s:masterfrom
denix56:master
Open

Add Triton support for KNN and Nearest; remove deprecated torch.ji.script#264
denix56 wants to merge 48 commits intorusty1s:masterfrom
denix56:master

Conversation

@denix56
Copy link
Copy Markdown

@denix56 denix56 commented Jan 30, 2026

Hi everyone,

I have implemented Triton versions of KNN and Nearest that achieve up to 2x times faster performance (especially on bigger data). The triton implementation is behind a flag use_triton.
This implementation will be particularly useful for NNs that usually have fixed shapes, providing a noticeable speedup.

Here are the metrics (respective benchmarks are included in project):
benchmarks.rtf

Also I have removed now deprecated torch.jit.script and replaced operator registration with TORCH_LIBRARY. Moreover, I have added fake kernels for every op in the library, allowing to use them in with torch.compile.

Use sorted batch pointers for Triton masks
Add Triton-based variants of KNN and Nearest search algorithms
* Compute split-N tile counts via heuristics

* Add Triton support

* Add Triton support
* Compute split-N tile counts via heuristics

* Add Triton support

* Add Triton support

* Add Triton support
remove triton from dependencies
* Compute split-N tile counts via heuristics

* Add Triton support

* Add Triton support

* Add Triton support

* Fix flake8 errors
remove triton from dependencies
remove triton from dependencies
* Compute split-N tile counts via heuristics

* Add Triton support

* Add Triton support

* Add Triton support

* Fix flake8 errors
remove triton from dependencies

* Remove meaningless comments
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 30, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 13.74502% with 433 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.64%. Comparing base (f2d9919) to head (2d5f204).
⚠️ Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
torch_cluster/triton/_kernels.py 0.00% 272 Missing ⚠️
torch_cluster/triton/radius.py 0.00% 35 Missing ⚠️
torch_cluster/triton/nearest.py 0.00% 34 Missing ⚠️
torch_cluster/triton/segmented.py 0.00% 31 Missing ⚠️
torch_cluster/radius.py 33.33% 24 Missing ⚠️
torch_cluster/graclus.py 22.22% 7 Missing ⚠️
torch_cluster/triton/knn.py 0.00% 7 Missing ⚠️
torch_cluster/nearest.py 53.84% 6 Missing ⚠️
torch_cluster/sampler.py 25.00% 6 Missing ⚠️
torch_cluster/knn.py 73.68% 5 Missing ⚠️
... and 3 more
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #264       +/-   ##
===========================================
- Coverage   97.32%   37.64%   -59.68%     
===========================================
  Files          11       17        +6     
  Lines         224      704      +480     
===========================================
+ Hits          218      265       +47     
- Misses          6      439      +433     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@denix56
Copy link
Copy Markdown
Author

denix56 commented Feb 1, 2026

Some benchmarks
Matplotlib Chart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants