diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 701536b..cc454e4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: # macos-13 is x86 # macos-latest is arm64 # ubuntu-latest is x64 - os: [macos-latest] + os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} @@ -25,10 +25,7 @@ jobs: # Build (and test) Lean. Tests are all via #guard macros # now so you can't really build without testing. - uses: leanprover/lean-action@v1 - with: - lake-package-directory: ./Lean - name: Run tests - working-directory: ./Lean run: lake exe klr # Run pytest - uses: actions/setup-python@v5 @@ -36,12 +33,12 @@ jobs: python-version: '3.x' cache: 'pip' - name: Install dependencies - working-directory: ./Python + working-directory: ./interop run: | python -m pip install --upgrade pip pip install -r requirements.txt - name: Run pytest - working-directory: ./Python + working-directory: ./interop run: | pytest - name: Make a wheel diff --git a/Lean/Export.lean b/Export.lean similarity index 100% rename from Lean/Export.lean rename to Export.lean diff --git a/Lean/KLR.lean b/KLR.lean similarity index 100% rename from Lean/KLR.lean rename to KLR.lean diff --git a/Lean/KLR/Core.lean b/KLR/Core.lean similarity index 100% rename from Lean/KLR/Core.lean rename to KLR/Core.lean diff --git a/Lean/KLR/Core/Basic.lean b/KLR/Core/Basic.lean similarity index 100% rename from Lean/KLR/Core/Basic.lean rename to KLR/Core/Basic.lean diff --git a/Lean/KLR/Core/Encode.lean b/KLR/Core/Encode.lean similarity index 100% rename from Lean/KLR/Core/Encode.lean rename to KLR/Core/Encode.lean diff --git a/Lean/KLR/Core/Oper.lean b/KLR/Core/Oper.lean similarity index 100% rename from Lean/KLR/Core/Oper.lean rename to KLR/Core/Oper.lean diff --git a/Lean/KLR/Core/Pretty.lean b/KLR/Core/Pretty.lean similarity index 100% rename from Lean/KLR/Core/Pretty.lean rename to KLR/Core/Pretty.lean diff --git a/Lean/KLR/Python.lean b/KLR/Python.lean similarity index 100% rename from Lean/KLR/Python.lean rename to KLR/Python.lean diff --git a/Lean/KLR/Trace.lean b/KLR/Trace.lean similarity index 100% rename from Lean/KLR/Trace.lean rename to KLR/Trace.lean diff --git a/Lean/KLR/Trace/Basic.lean b/KLR/Trace/Basic.lean similarity index 100% rename from Lean/KLR/Trace/Basic.lean rename to KLR/Trace/Basic.lean diff --git a/Lean/KLR/Trace/Builtin.lean b/KLR/Trace/Builtin.lean similarity index 100% rename from Lean/KLR/Trace/Builtin.lean rename to KLR/Trace/Builtin.lean diff --git a/Lean/KLR/Trace/NKI.lean b/KLR/Trace/NKI.lean similarity index 100% rename from Lean/KLR/Trace/NKI.lean rename to KLR/Trace/NKI.lean diff --git a/Lean/KLR/Trace/Python.lean b/KLR/Trace/Python.lean similarity index 100% rename from Lean/KLR/Trace/Python.lean rename to KLR/Trace/Python.lean diff --git a/Lean/KLR/Trace/Tensor.lean b/KLR/Trace/Tensor.lean similarity index 100% rename from Lean/KLR/Trace/Tensor.lean rename to KLR/Trace/Tensor.lean diff --git a/Lean/KLR/Trace/Types.lean b/KLR/Trace/Types.lean similarity index 100% rename from Lean/KLR/Trace/Types.lean rename to KLR/Trace/Types.lean diff --git a/Lean/KLR/Util.lean b/KLR/Util.lean similarity index 100% rename from Lean/KLR/Util.lean rename to KLR/Util.lean diff --git a/Lean/Main.lean b/Main.lean similarity index 100% rename from Lean/Main.lean rename to Main.lean diff --git a/bin/klr b/bin/klr index 0165271..9fa7d3d 100755 --- a/bin/klr +++ b/bin/klr @@ -2,4 +2,4 @@ ROOT=$(dirname $(dirname $(readlink -f $0))) -$ROOT/Lean/.lake/build/bin/klr $@ +$ROOT/.lake/build/bin/klr $@ diff --git a/bin/make-wheel b/bin/make-wheel index 80eab68..b49f339 100755 --- a/bin/make-wheel +++ b/bin/make-wheel @@ -4,19 +4,13 @@ trap "kill 0" SIGINT SIGTERM ROOT=$(dirname $(dirname $(readlink -f $0))) WHEEL_DIR=$ROOT/.wheel/ -LEAN_DIR=$ROOT/Lean -PYTHON_DIR=$ROOT/Python +PYTHON_DIR=$ROOT/interop rm -rf $WHEEL_DIR mkdir -p $WHEEL_DIR/{klr,bin} - -# Build Lean code -pushd . -cd $LEAN_DIR lake build -popd # Get klr binary -cp $LEAN_DIR/.lake/build/bin/klr $WHEEL_DIR/bin/klr +cp .lake/build/bin/klr $WHEEL_DIR/bin/klr # Get Python packages cp -R $PYTHON_DIR/* $WHEEL_DIR diff --git a/Python/MANIFEST.in b/interop/MANIFEST.in similarity index 100% rename from Python/MANIFEST.in rename to interop/MANIFEST.in diff --git a/Python/README.md b/interop/README.md similarity index 100% rename from Python/README.md rename to interop/README.md diff --git a/Python/klr/__init__.py b/interop/klr/__init__.py similarity index 100% rename from Python/klr/__init__.py rename to interop/klr/__init__.py diff --git a/Python/klr/parser.py b/interop/klr/parser.py similarity index 98% rename from Python/klr/parser.py rename to interop/klr/parser.py index 0d42202..7fdc6c9 100644 --- a/Python/klr/parser.py +++ b/interop/klr/parser.py @@ -20,7 +20,7 @@ def up(f, n): for _ in range(n): d = os.path.dirname(d) return d - + def run_klr(infile, outfile): # For development, pick up the klr binary from the project dir @@ -29,8 +29,7 @@ def run_klr(infile, outfile): if not os.path.isfile(bin): # For regular pip users, pick up the klr from the wheel. While the type of `bin` here is # PosixPath rather than string, they both work as the first argument to subprocess.run - #bin = files('klr').joinpath('bin/klr') - raise Exception("no file: " + bin) + bin = files('klr').joinpath('bin/klr') subprocess.run([bin, 'parse-json', infile.name], stdout=outfile, check=True) diff --git a/Python/nki/__init__.py b/interop/nki/__init__.py similarity index 100% rename from Python/nki/__init__.py rename to interop/nki/__init__.py diff --git a/Python/nki/isa/__init__.py b/interop/nki/isa/__init__.py similarity index 100% rename from Python/nki/isa/__init__.py rename to interop/nki/isa/__init__.py diff --git a/Python/nki/language/__init__.py b/interop/nki/language/__init__.py similarity index 100% rename from Python/nki/language/__init__.py rename to interop/nki/language/__init__.py diff --git a/Python/noop.c b/interop/noop.c similarity index 100% rename from Python/noop.c rename to interop/noop.c diff --git a/Python/pyproject.toml b/interop/pyproject.toml similarity index 72% rename from Python/pyproject.toml rename to interop/pyproject.toml index 9fc85c4..8cf5ff9 100644 --- a/Python/pyproject.toml +++ b/interop/pyproject.toml @@ -12,7 +12,6 @@ authors = [ ] description = "Intermediate langauge for tensor compilers" readme = "README.md" -requires-python = ">=3.8" license = { file = "LICENSE" } keywords = ["trainium", "tpu", "pallas", "triton", "gpu"] @@ -37,8 +36,12 @@ testpaths = [ ] [tool.setuptools] -packages = ["bin", "klr", "nki", 'nki.isa', 'nki.language'] # Required to have 2 top level packages +packages = ["bin", "klr", "nki", 'nki.isa', 'nki.language'] # This field is tequired to have more than 1 top level packages (nki/klr). It's not beautiful but it works. +# Build a fake C file to trick the `build` command to make an arch-specific wheel +# We need this because we hide our `klr` Lean binary in the wheel but Python tools +# don't know about it. I couldn't find another way to stop Python from generating +# a generic `any` wheel. [[tool.setuptools.ext-modules]] name = "noop" sources = ["noop.c"] diff --git a/Python/requirements.txt b/interop/requirements.txt similarity index 100% rename from Python/requirements.txt rename to interop/requirements.txt diff --git a/Python/tests/examples/__init__.py b/interop/test/examples/__init__.py similarity index 100% rename from Python/tests/examples/__init__.py rename to interop/test/examples/__init__.py diff --git a/Python/tests/examples/average_pool.py b/interop/test/examples/average_pool.py similarity index 100% rename from Python/tests/examples/average_pool.py rename to interop/test/examples/average_pool.py diff --git a/Python/tests/examples/fused_mamba.py b/interop/test/examples/fused_mamba.py similarity index 100% rename from Python/tests/examples/fused_mamba.py rename to interop/test/examples/fused_mamba.py diff --git a/Python/tests/examples/getting_started.py b/interop/test/examples/getting_started.py similarity index 100% rename from Python/tests/examples/getting_started.py rename to interop/test/examples/getting_started.py diff --git a/Python/tests/examples/index.py b/interop/test/examples/index.py similarity index 100% rename from Python/tests/examples/index.py rename to interop/test/examples/index.py diff --git a/Python/tests/examples/layernorm.py b/interop/test/examples/layernorm.py similarity index 100% rename from Python/tests/examples/layernorm.py rename to interop/test/examples/layernorm.py diff --git a/Python/tests/examples/layout.py b/interop/test/examples/layout.py similarity index 100% rename from Python/tests/examples/layout.py rename to interop/test/examples/layout.py diff --git a/Python/tests/examples/matmul.py b/interop/test/examples/matmul.py similarity index 100% rename from Python/tests/examples/matmul.py rename to interop/test/examples/matmul.py diff --git a/Python/tests/examples/mm.py b/interop/test/examples/mm.py similarity index 100% rename from Python/tests/examples/mm.py rename to interop/test/examples/mm.py diff --git a/Python/tests/examples/prof.py b/interop/test/examples/prof.py similarity index 100% rename from Python/tests/examples/prof.py rename to interop/test/examples/prof.py diff --git a/Python/tests/examples/rmsnorm.py b/interop/test/examples/rmsnorm.py similarity index 100% rename from Python/tests/examples/rmsnorm.py rename to interop/test/examples/rmsnorm.py diff --git a/Python/tests/examples/sd_attention.py b/interop/test/examples/sd_attention.py similarity index 100% rename from Python/tests/examples/sd_attention.py rename to interop/test/examples/sd_attention.py diff --git a/Python/tests/examples/tensor_addition.py b/interop/test/examples/tensor_addition.py similarity index 100% rename from Python/tests/examples/tensor_addition.py rename to interop/test/examples/tensor_addition.py diff --git a/Python/tests/examples/transpose2d.py b/interop/test/examples/transpose2d.py similarity index 100% rename from Python/tests/examples/transpose2d.py rename to interop/test/examples/transpose2d.py diff --git a/Python/tests/test_basic.py b/interop/test/test_basic.py similarity index 100% rename from Python/tests/test_basic.py rename to interop/test/test_basic.py diff --git a/Python/tests/test_examples.py b/interop/test/test_examples.py similarity index 100% rename from Python/tests/test_examples.py rename to interop/test/test_examples.py diff --git a/Lean/lake-manifest.json b/lake-manifest.json similarity index 100% rename from Lean/lake-manifest.json rename to lake-manifest.json diff --git a/Lean/lakefile.lean b/lakefile.lean similarity index 100% rename from Lean/lakefile.lean rename to lakefile.lean diff --git a/Lean/lean-toolchain b/lean-toolchain similarity index 100% rename from Lean/lean-toolchain rename to lean-toolchain