Skip to content

Pipe primitives#289

Open
zoecarver wants to merge 21 commits intomainfrom
zoecarver/pipes-poc
Open

Pipe primitives#289
zoecarver wants to merge 21 commits intomainfrom
zoecarver/pipes-poc

Conversation

@zoecarver
Copy link
Contributor

@zoecarver zoecarver commented Jan 28, 2026

Still mostly a poc, but adds primitives to start testing pipe functionality. These can later be used to implement the full spec implementation.

Fairly self contained (added lowering), but does modify copy lowering.

The pipe lowering targets these TTKernel operations:

  • Multicast writes: NocAsyncWriteMulticastOp writes data from source to all destinations in a rectangular region. NocAsyncWriteMulticastLoopbackSrcOp is the variant used when the source core is within the destination range
  • Address computation: GetNocMulticastAddrOp computes the NOC address for a multicast destination region. ConvertLogicalXToTranslatedOp/ConvertLogicalYToTranslatedOp convert logical core coordinates to NOC-translated coordinates
  • Semaphore signaling: NocSemaphoreIncOp atomically increments a remote semaphore (used for gather patterns). NocSemaphoreSetMulticastOp multicasts a semaphore set to all destinations. NocSemaphoreWaitMinOp waits for semaphore to reach a threshold
  • Barriers: NocAsyncWriteBarrierOp ensures writes complete before signaling
  • Core identity: MyLogicalXOp/MyLogicalYOp return current core coordinates for if_src/if_dst conditionals

PipeGraph and Semaphore Setup:

  • Before lowering, PipeGraph::build() walks the module to find all Pipe->CB copy operations (the receiver side). For each pipe, it records the receiver's CB index and the pipe's source coordinates. This information is emitted to a json file (like the dataflow analysis for auto profiler).
  • The Python kernel_runner reads the pipe graph and determines the maximum semaphore index needed (max(p.srcX for p in pipe_graph)). It then creates SemaphoreDescriptor objects for indices 0 through max, all initialized to 0, and passes them to ttnn.ProgramDescriptor

Risk:

Almost entirely self-contained; adds new types (PipeType), new ops (create_pipe, if_src, if_dst), and new lowering patterns. The only modification to existing code is in CopyLowering which adds detection for pipe operands at the start of matchAndRewrite before falling through to existing tensor/CB copy logic. The pipe codepath is fully separate from existing copy lowering.

@zoecarver zoecarver force-pushed the zoecarver/pipes-poc branch from 07e73ff to bc8a391 Compare February 2, 2026 16:00
@zoecarver zoecarver marked this pull request as ready for review February 2, 2026 16:18
@zoecarver zoecarver requested a review from a team as a code owner February 2, 2026 16:18
@zoecarver zoecarver changed the title [draft] pipes poc Pipe primitives Feb 2, 2026
@@ -0,0 +1,118 @@
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC
Copy link
Contributor Author

Choose a reason for hiding this comment

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

move the pipe tests into their own directory

@zoecarver zoecarver force-pushed the zoecarver/pipes-poc branch from e7536da to ed9aba2 Compare February 2, 2026 16:49
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.

1 participant