Skip to content

Integrate Counter and General lowering into Synapse - #9

Merged
ShangkunLi merged 3 commits into
mainfrom
feature/counter-dataflow-integration
Oct 12, 2026
Merged

ShangkunLi merged 3 commits into
mainfrom
feature/counter-dataflow-integration

Conversation

@ShangkunLi

@ShangkunLi ShangkunLi commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Replaces the subprocess backend with an in-process MLIR pass pipeline. Synapse applies patterns before and after Linalg-to-Affine conversion, lowers remaining computations through Counter or General dataflow, and maps each kernel while preserving memref dependencies between tasks.

mapped = synapse.compile(
    task_ir,
    target="neura",
    architecture_spec="architecture.yaml",
)

For example, one task graph can combine all three lowering paths:

Task Lowering Mapping
Named GEMM Linalg template Template, spatial-only
Generic GEMM with commuted multiply Affine template Template, spatial-only
Elementwise increment Counter Heuristic, spatial-temporal
SCF conditional General dataflow Heuristic, spatial-temporal

GEMM replacement removes the consumed zero initialization. All placed TileArray programs carry template metadata for automatic mapping strategy selection. The redundant public replace() wrapper is removed.

For now, the overall lowering process is as follows:

TileArray Python program                Memref-linked Taskflow IR
         |                                 (Linalg / Affine / SCF)
         v                                           |
  Frontend lowering                                  v
         |                                    Apply patterns
         |                                           |
         |                         matched ------------+ 
         |                            |              |
         |                            |         remaining IR
         |                            |              |
         |                            |              v
         |                            |      Linalg -> Affine
         |                            |              |
         |                            |              v
         |                            |       Apply patterns
         |                            |              |
         |                         matched ------------+
         |                            |              |
         v                            v         remaining IR
  +--------------------------------------+           |
  |       Placed Template kernels        |           v
  +--------------------------------------+   Counter / General
                    |                      kernel construction
                    |                               |
                    |                               v
                    |                       Neura operations +
                    |                      control-to-dataflow
                    |                               |
                    +---------------+---------------+
                                    |
                                    v
                         Constant folding, predication
                            and data movement
                                    |
                                    v
                           Map each kernel
                            /           \
                           /             \
                  Template kernel    Counter / General kernel
                         |                    |
                         v                    v
                  TemplateMapping      HeuristicMapping
                   spatial-only        spatial-temporal
                         |                    |
                         +---------+----------+
                                   |
                                   v
                      Mapped multi-task Taskflow IR

@ShangkunLi ShangkunLi self-assigned this Oct 10, 2026
@ShangkunLi ShangkunLi added enhancement New feature or request new feature labels Oct 10, 2026
@tancheng

Copy link
Copy Markdown

Template kernel

The "Template kernel" is mapped or provided with the spatial-only mapping. We don't need to emphasize this in the paper though, as it is orthogonal, i mean spatial-temporal is also theoretically possible. Am I right?

Memref-linked Taskflow IR

The right side of your diagram is about PUPA, right? Didn't we talk about graph-rewrite? e.g., CONV -> im2col + matmul? or some graph-rewrite you mentioned for the GPU work? That can improve the novelty/contributions of PUPA. Otherwise, only pattern matching in PUPA is not compelling enough. Moreover, we mentioned on-the-fly (or offline) generate kernel using agent before/during pattern matching (just as a use case to demo PUPA's potential).

PUPA

Is PUPA a standalone repo?

@ShangkunLi

Copy link
Copy Markdown
Collaborator Author

Template kernel

The "Template kernel" is mapped or provided with the spatial-only mapping. We don't need to emphasize this in the paper though, as it is orthogonal, i mean spatial-temporal is also theoretically possible. Am I right?

For now, we restrict template kernels to spatial-only mapping. Using templates with spatio-temporal mapping needs further discussion.

Memref-linked Taskflow IR

The right side of your diagram is about PUPA, right? Didn't we talk about graph-rewrite? e.g., CONV -> im2col + matmul? or some graph-rewrite you mentioned for the GPU work? That can improve the novelty/contributions of PUPA. Otherwise, only pattern matching in PUPA is not compelling enough. Moreover, we mentioned on-the-fly (or offline) generate kernel using agent before/during pattern matching (just as a use case to demo PUPA's potential).

We have a local fixed-point rewrite framework under development. I’ll include a CONV rewrite case, such as CONV → im2col + matmul, in the next PR, and add agent integration in the PR after that.

PUPA

Is PUPA a standalone repo?

PUPA is implemented within Synapse using the Amoeba/Neura backends. There is no standalone PUPA repo.

@ShangkunLi
ShangkunLi merged commit fde59be into main Oct 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Reimplement the compiler integration to enable in-process compiler run

2 participants