diff --git a/.github/workflows/build-run-kernel.yml b/.github/workflows/build-run-kernel.yml index 5dcd81ff..590d9a48 100644 --- a/.github/workflows/build-run-kernel.yml +++ b/.github/workflows/build-run-kernel.yml @@ -8,15 +8,15 @@ on: jobs: build-and-run-kernels: - runs-on: ubuntu-latest - container: - image: ghcr.io/kuleuven-micas/snax:v0.2.7 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 - - name: Install snax-mlir - run: python3 -m pip install '-e.[dev]' + - uses: prefix-dev/setup-pixi@v0.8.1 + with: + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - name: Build and run kernels - run: make allrun + run: pixi run make allrun working-directory: kernels/${{ matrix.kernel }} strategy: matrix: diff --git a/.github/workflows/build-run-mlperf-tiny.yml b/.github/workflows/build-run-mlperf-tiny.yml index acd698b3..4816bbd1 100644 --- a/.github/workflows/build-run-mlperf-tiny.yml +++ b/.github/workflows/build-run-mlperf-tiny.yml @@ -9,9 +9,7 @@ on: jobs: build-and-run-networks: - runs-on: ubuntu-latest - container: - image: ghcr.io/kuleuven-micas/snax:v0.2.7 + runs-on: ubuntu-24.04 strategy: matrix: model: @@ -25,15 +23,16 @@ jobs: dir: kernels/mlperf_tiny_kws steps: - uses: actions/checkout@v3 - - name: Install snax-mlir - run: | - python3 -m pip install '-e.[dev,nn]' + - uses: prefix-dev/setup-pixi@v0.8.1 + with: + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - name: snax-opt network compilation run: | - make ${{ matrix.model.name }}.o + pixi run make ${{ matrix.model.name }}.o working-directory: ${{ matrix.model.dir }} - name: vanilla network compilation run: | - make ${{ matrix.model.name }}.no-snax-opt.o + pixi run make ${{ matrix.model.name }}.no-snax-opt.o working-directory: ${{ matrix.model.dir }} diff --git a/.github/workflows/code-formatting.yml b/.github/workflows/code-formatting.yml index 1ad627b0..69627140 100644 --- a/.github/workflows/code-formatting.yml +++ b/.github/workflows/code-formatting.yml @@ -6,7 +6,7 @@ on: jobs: code-formatting: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -17,4 +17,4 @@ jobs: - name: Run code formatting checks with pre-commit uses: pre-commit/action@v3.0.0 - \ No newline at end of file + diff --git a/.github/workflows/lit-tests.yml b/.github/workflows/lit-tests.yml index 4af3597a..d49d05a0 100644 --- a/.github/workflows/lit-tests.yml +++ b/.github/workflows/lit-tests.yml @@ -12,18 +12,16 @@ permissions: jobs: python-tests: - runs-on: ubuntu-latest - container: - image: ghcr.io/kuleuven-micas/snax:v0.2.7 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 - - name: Install snax-mlir - shell: bash - run: | - python3 -m pip install '-e.[dev]' + - uses: prefix-dev/setup-pixi@v0.8.1 + with: + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - name: Test with lit shell: bash run: | - lit tests/filecheck -v + pixi run lit tests/filecheck -v diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 24294480..201b2279 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -12,18 +12,16 @@ permissions: jobs: python-tests: - runs-on: ubuntu-latest - container: - image: ghcr.io/kuleuven-micas/snax:v0.2.7 + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v3 - - name: Install snax-mlir - shell: bash - run: | - python3 -m pip install '-e.[dev]' + - uses: prefix-dev/setup-pixi@v0.8.1 + with: + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - name: Test with pytest shell: bash run: | - python3 -m pytest . + pixi run python -m pytest . diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index e2bb394e..cfadc143 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -10,14 +10,13 @@ on: jobs: run-benchmarks: - runs-on: ubuntu-latest - container: - image: ghcr.io/kuleuven-micas/snax:v0.2.7 + runs-on: ubuntu-24.04 steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Install snax-mlir - run: python3 -m pip install '-e.[dev,viz]' + - uses: actions/checkout@v4 + - uses: actions/prefix-dev/setup-pixi@v0.8.1 + with: + cache: true + cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }} - name: Run benchmarks run: python3 genbenchmark.py working-directory: benchmarks/${{ matrix.kernel }} diff --git a/compiler/tools/snax_opt_main.py b/compiler/tools/snax_opt_main.py index 7141fe7c..76e72bb0 100644 --- a/compiler/tools/snax_opt_main.py +++ b/compiler/tools/snax_opt_main.py @@ -45,6 +45,9 @@ from compiler.transforms.test.debug_to_func import DebugToFuncPass from compiler.transforms.test.insert_debugs import InsertDebugPass from compiler.transforms.test.test_add_mcycle_around_launch import AddMcycleAroundLaunch +from compiler.transforms.test.test_transform_dialect_erase_schedule import ( + TestTransformDialectEraseSchedule, +) from compiler.transforms.test_add_mcycle_around_loop import AddMcycleAroundLoopPass from compiler.transforms.test_remove_memref_copy import RemoveMemrefCopyPass @@ -124,6 +127,10 @@ def __init__( super().register_pass(SnaxBufferize.name, lambda: SnaxBufferize) super().register_pass(FuseStreamingRegions.name, lambda: FuseStreamingRegions) super().register_pass(AllocToGlobalPass.name, lambda: AllocToGlobalPass) + super().register_pass( + TestTransformDialectEraseSchedule.name, + lambda: TestTransformDialectEraseSchedule, + ) # arg handling arg_parser = argparse.ArgumentParser(description=description) diff --git a/compiler/transforms/test/test_transform_dialect_erase_schedule.py b/compiler/transforms/test/test_transform_dialect_erase_schedule.py new file mode 100644 index 00000000..c3db3e0c --- /dev/null +++ b/compiler/transforms/test/test_transform_dialect_erase_schedule.py @@ -0,0 +1,31 @@ +from xdsl.context import MLContext +from xdsl.dialects import builtin, transform +from xdsl.passes import ModulePass +from xdsl.pattern_rewriter import ( + PatternRewriter, + PatternRewriteWalker, + RewritePattern, + op_type_rewrite_pattern, +) + + +class RemoveSchedule(RewritePattern): + @op_type_rewrite_pattern + def match_and_rewrite( + self, + op: transform.NamedSequenceOp | transform.SequenceOp, + rewriter: PatternRewriter, + /, + ): + rewriter.erase_matched_op() + + +class TestTransformDialectEraseSchedule(ModulePass): + """ + Copy of the test-transform-dialect-erase-schedule pass in MLIR + """ + + name = "test-transform-dialect-erase-schedule" + + def apply(self, ctx: MLContext, op: builtin.ModuleOp) -> None: + PatternRewriteWalker(RemoveSchedule()).rewrite_module(op) diff --git a/kernels/streamer_matmul/Makefile b/kernels/streamer_matmul/Makefile index 1e3e4afc..4ec78d27 100644 --- a/kernels/streamer_matmul/Makefile +++ b/kernels/streamer_matmul/Makefile @@ -9,7 +9,7 @@ TESTS = TESTS += quantized_matmul.x TESTS += tiled_quantized_matmul.x -SNAXOPTFLAGS = -p convert-linalg-to-kernel,insert-accfg-op{accelerator=snax_gemmx},dispatch-kernels,convert-linalg-to-stream,fuse-streaming-regions,snax-bufferize,alloc-to-global,set-memory-space,set-memory-layout,realize-memref-casts,insert-sync-barrier,dispatch-regions{nb_cores=2},convert-stream-to-snax-stream,convert-linalg-to-accfg,convert-accfg-to-csr,snax-copy-to-dma,memref-to-snax,snax-to-func,clear-memory-space +SNAXOPTFLAGS = -p test-transform-dialect-erase-schedule,convert-linalg-to-kernel,insert-accfg-op{accelerator=snax_gemmx},dispatch-kernels,convert-linalg-to-stream,fuse-streaming-regions,snax-bufferize,alloc-to-global,set-memory-space,set-memory-layout,realize-memref-casts,insert-sync-barrier,dispatch-regions{nb_cores=2},convert-stream-to-snax-stream,convert-linalg-to-accfg,convert-accfg-to-csr,snax-copy-to-dma,memref-to-snax,snax-to-func,clear-memory-space CFLAGS += -std=gnu11 CFLAGS += -Wall -Wextra diff --git a/pixi.lock b/pixi.lock index c2a5431d..0e8616d3 100644 --- a/pixi.lock +++ b/pixi.lock @@ -96,6 +96,7 @@ environments: - pypi: https://files.pythonhosted.org/packages/05/a6/094a2640be576d760baa34c902dcb8199d89bce9ed7dd7a6af74dcbbd62d/protobuf-4.25.5-cp37-abi3-manylinux2014_x86_64.whl - pypi: https://files.pythonhosted.org/packages/f7/3f/01c8b82017c199075f8f788d0d906b9ffbbc5a47dc9918a945e13d5a2bda/pygments-2.18.0-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/be/ec/2eb3cd785efd67806c46c13a17339708ddc346cbb684eade7a6e6f79536a/pyparsing-3.2.0-py3-none-any.whl + - pypi: https://files.pythonhosted.org/packages/43/20/3f492ca789fb17962ad23619959c7fa642082621751514296c58de3bb801/pyright-1.1.390-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/11/92/76a1c94d3afee238333bc0a42b82935dd8f9cf8ce9e336ff87ee14d9e1cf/pytest-8.3.4-py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/ec/57/56b9bcc3c9c6a792fcbaf139543cee77261f3651ca9da0c93f5c1221264b/python_dateutil-2.9.0.post0-py2.py3-none-any.whl - pypi: https://files.pythonhosted.org/packages/11/c3/005fcca25ce078d2cc29fd559379817424e94885510568bc1bc53d7d5846/pytz-2024.2-py2.py3-none-any.whl @@ -1095,6 +1096,18 @@ packages: - railroad-diagrams ; extra == 'diagrams' - jinja2 ; extra == 'diagrams' requires_python: '>=3.9' +- pypi: https://files.pythonhosted.org/packages/43/20/3f492ca789fb17962ad23619959c7fa642082621751514296c58de3bb801/pyright-1.1.390-py3-none-any.whl + name: pyright + version: 1.1.390 + sha256: ecebfba5b6b50af7c1a44c2ba144ba2ab542c227eb49bc1f16984ff714e0e110 + requires_dist: + - nodeenv>=1.6.0 + - typing-extensions>=4.1 + - twine>=3.4.1 ; extra == 'all' + - nodejs-wheel-binaries ; extra == 'all' + - twine>=3.4.1 ; extra == 'dev' + - nodejs-wheel-binaries ; extra == 'nodejs' + requires_python: '>=3.7' - pypi: https://files.pythonhosted.org/packages/11/92/76a1c94d3afee238333bc0a42b82935dd8f9cf8ce9e336ff87ee14d9e1cf/pytest-8.3.4-py3-none-any.whl name: pytest version: 8.3.4 @@ -1263,7 +1276,7 @@ packages: - pypi: . name: snax-mlir version: 0.2.2 - sha256: 5b4e1f7e134a6d6de9c6e8e515deec1f28d88014f9067e4580d327e1864bb772 + sha256: 7c41b96e15b5e6e39f853207f1befdf935473eb6048c371d859020dda4cd8fee requires_dist: - xdsl @ git+https://github.com/xdslproject/xdsl.git@d72f46d92ec4b03ae05b91e70d75f93735e94393 - pre-commit ; extra == 'dev' @@ -1271,6 +1284,7 @@ packages: - lit ; extra == 'dev' - numpy<2.0.0 ; extra == 'dev' - pytest ; extra == 'dev' + - pyright ; extra == 'dev' - pandas ; extra == 'viz' - matplotlib ; extra == 'viz' - tensorflow-cpu==2.16.2 ; extra == 'nn' diff --git a/pyproject.toml b/pyproject.toml index fbeb04f0..082980ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,7 @@ dev = [ "lit", "numpy<2.0.0", "pytest", + "pyright", ] # All optional dependencies for graphical plotting diff --git a/runtime/Makefile.rules b/runtime/Makefile.rules index 40fb1781..1ca12406 100644 --- a/runtime/Makefile.rules +++ b/runtime/Makefile.rules @@ -75,7 +75,7 @@ LDFLAGS += -lsnRuntime # TRANSFORM Pre-Preprocessing -MLIRTRANSFORM = --pass-pipeline='builtin.module(transform-interpreter{debug-bind-trailing-args=linalg.quantized_matmul}, test-transform-dialect-erase-schedule)' +MLIRTRANSFORM = --pass-pipeline='builtin.module(transform-interpreter{debug-bind-trailing-args=linalg.quantized_matmul})' %.mlir: %.transform.mlir $(MLIROPT) $(MLIRTRANSFORM) -o $@ $<