Skip to content

tvm: support external microkernels - #133

Merged
guillon merged 1 commit into
xtc-tools:mainfrom
guillon:dev/cguillon/external_at
Sep 16, 2026
Merged

guillon merged 1 commit into
xtc-tools:mainfrom
guillon:dev/cguillon/external_at

Conversation

@guillon

@guillon guillon commented Sep 8, 2026

Copy link
Copy Markdown
Member

Motivation

Allow TVM schedules to delegate an inner computation tile to a user-provided C-ABI microkernel.

Description

Add the external_at schedule operation and lower externalized loop tiles to T.call_extern.

The external ABI passes output and input pointers, inner-loop extents, and projected strides—including zero strides for invariant dimensions. Reduction initialization is separated from externally implemented updates.

Add support for compiling and linking additional C sources into TVM shared-library and archive outputs, or forwarding them with C-source outputs.

Add executable matmul and Conv2D examples covering spatial tiles, strip-mined reductions, multidimensional reductions, OpenMP SIMD, and aligned AVX-512 microkernels.

Commits

  • tvm: implement external_at for tvm schedule

Discussion

Current limitations include one output, perfectly nested externalized loops.

TODO:

  • Implement external_at for the MLIR backend.
  • Consider a memref-compatible external ABI.

Testing

  • External matmul and Conv2D FileCheck tests
  • pytest -q tests/pytest/unit — 53 passed
  • Pyright and Mypy checks

@guillon
guillon force-pushed the dev/cguillon/external_at branch from fc4698d to 162a517 Compare September 8, 2026 18:07
@guillon guillon self-assigned this Sep 8, 2026
@guillon
guillon requested a review from qaco September 8, 2026 18:07
@guillon

guillon commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

@qaco for information, may be useful if you want to call hand-optimized kernel tiles (or generated with another tool), xtc can mange the external memory tiling and call a C-abi compatible fast L1 resident tile for instance for matmul or conv2d.

This is actually the long waited tentative implementation of the external_call/tensorize.

I would appreciate a first feedback. Refer to the examples in tests/.

@guillon
guillon force-pushed the dev/cguillon/external_at branch 2 times, most recently from be048d1 to dcee49c Compare September 9, 2026 10:50
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@guillon
guillon force-pushed the dev/cguillon/external_at branch 3 times, most recently from 7cc7ffe to 2ef43f3 Compare September 14, 2026 16:19
@guillon
guillon force-pushed the dev/cguillon/external_at branch from 2ef43f3 to 8f56c34 Compare September 16, 2026 12:27
@guillon
guillon marked this pull request as ready for review September 16, 2026 17:32
@guillon

guillon commented Sep 16, 2026

Copy link
Copy Markdown
Member Author

Merging pull request, you may comment later @qaco

@guillon
guillon merged commit 9409cb5 into xtc-tools:main Sep 16, 2026
9 checks passed
@guillon
guillon deleted the dev/cguillon/external_at branch September 16, 2026 17:33
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