Skip to content

Add scatter with reduction support#9379

Open
denix56 wants to merge 1 commit intotriton-lang:mainfrom
denix56:scatter
Open

Add scatter with reduction support#9379
denix56 wants to merge 1 commit intotriton-lang:mainfrom
denix56:scatter

Conversation

@denix56
Copy link
Copy Markdown
Contributor

@denix56 denix56 commented Feb 5, 2026

Why
Triton doesn’t currently support scatter, which is needed for index-based writes and parity with common tensor frameworks. This PR adds scatter support with broadcastable indices
and optional reduction semantics (via combine_fn and include_self).

What

  • Add scatter support in the compiler lowering and runtime.
  • Allow broadcastable index in scatter (broadcast to src shape in semantic layer).
  • Add reduction support via combine_fn, with include_self controlling whether original dst values participate.
  • Add unit tests.

Testing

  • python -m pytest -vv python/test/unit/language/test_core.py::test_scatter
  • python -m pytest -vv python/test/unit/language/test_core.py::test_scatter_broadcast_index
  • python -m pytest -vv python/test/unit/language/test_core.py::test_scatter_reduce

New contributor declaration

  • I am not making a trivial change, such as fixing a typo in a comment.

  • I have written a PR description following these
    rules.

  • I have run pre-commit run --from-ref origin/main --to-ref HEAD.

  • Select one of the following.

    • I have added tests.
      • /test for lit tests
      • /unittest for C++ tests
      • /python/test for end-to-end tests
    • This PR does not need a test because FILL THIS IN.
  • Select one of the following.

    • I have not added any lit tests.
    • The lit tests I have added follow these best practices,
      including the "tests should be minimal" section. (Usually running Python code
      and using the instructions it generates is not minimal.)

@denix56 denix56 force-pushed the scatter branch 3 times, most recently from a36137f to 4e117a3 Compare February 9, 2026 01:32
@denix56
Copy link
Copy Markdown
Contributor Author

denix56 commented Feb 9, 2026

I would appreciate any suggestions, especially regarding match_any implementations as I don't have access to AMD gpu for testing.

@denix56 denix56 changed the title WIP: Add scatter with reduction support, and IR-reduced lowering Add scatter with reduction support Feb 9, 2026
Copy link
Copy Markdown
Collaborator

@ThomasRaoux ThomasRaoux left a comment

Choose a reason for hiding this comment

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

I think this is out of scope for what we want in Triton unless there are real life use cases for the scatter in ML.

@denix56
Copy link
Copy Markdown
Contributor Author

denix56 commented Feb 13, 2026

I think this is out of scope for what we want in Triton unless there are real life use cases for the scatter in ML.

I can immediately think of GNNs, K-nearest neighbors for neural networks working on point clouds, sparse tensor ops.

@CRobeck
Copy link
Copy Markdown
Contributor

CRobeck commented Feb 16, 2026

@denix56 is this something you would consider implementing as an extension?
https://github.com/triton-lang/triton/tree/main/examples/plugins
https://github.com/triton-lang/triton-ext
cc: @plotfi @sjw36

@denix56
Copy link
Copy Markdown
Contributor Author

denix56 commented Feb 17, 2026

@denix56 is this something you would consider implementing as an extension? https://github.com/triton-lang/triton/tree/main/examples/plugins https://github.com/triton-lang/triton-ext cc: @plotfi @sjw36

yes, sounds like a good idea!

@CRobeck
Copy link
Copy Markdown
Contributor

CRobeck commented Feb 17, 2026

@denix56 is this something you would consider implementing as an extension? https://github.com/triton-lang/triton/tree/main/examples/plugins https://github.com/triton-lang/triton-ext cc: @plotfi @sjw36

yes, sounds like a good idea!

I have a draft PR that I need to finish up for custom top level DSL ops but it can be done in stages with just adding the ops at the TTGIR level first and invoking with IR over rides. The existing infrastructure should support that today.

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.

3 participants